91 m_ContinuousInteract = null;
96 m_HealthEnabled =
true;
97 m_QuantityEnabled =
true;
101 m_DisplayInteractTarget = null;
116 m_HealthEnabled = state;
121 m_QuantityEnabled = state;
148 m_Container = w.FindAnyWidget(
"container");
149 m_ItemLeft = w.FindAnyWidget(
"item_left");
156 #ifdef PLATFORM_CONSOLE
178 bool showConsoleIcons =
false;
179 #ifdef PLATFORM_CONSOLE
194 int q_min, q_max = -1;
199 SetItemHealth(health,
"item",
"item_health_mark", m_HealthEnabled);
205 SetItemQuantity(q_type, q_cur, q_min, q_max,
"item",
"item_quantity_pb",
"item_quantity_text", m_QuantityEnabled);
206 SetInteractActionIcon(
"interact",
"interact_icon_frame",
"interact_btn_inner_icon",
"interact_btn_text");
210 SetInteractActionIcon(
"continuous_interact",
"continuous_interact_icon_frame",
"continuous_interact_btn_inner_icon",
"continuous_interact_btn_text");
235 float pos_x, pos_y = 0.0;
240 if (forceRebuild ||
m_Target.GetComponentIndex() != m_CachedObject.GetCursorCompIdx())
249 pos_x = screen_pos[0];
250 pos_y = screen_pos[1];
264 parentWdg.GetScreenSize(screen_w, screen_h);
265 m_Root.GetSize(wdg_w, wdg_h);
267 if (pos_x + wdg_w > screen_w)
268 pos_x = screen_w - wdg_w;
270 if (pos_y + wdg_h > screen_h)
271 pos_y = screen_h - wdg_h;
273 m_Root.SetPos(pos_x, pos_y);
292 m_CachedObject.Invalidate();
320 bool show_target = (
m_Target && !
m_Hidden) || m_Interact || m_ContinuousInteract;
326 show_target = m_Single.HasTarget();
331 show_target = show_target || m_Continuous.HasTarget();
338 if (
m_Target.GetObject() == null && (m_Interact || m_ContinuousInteract || m_Single ||
m_Continuous))
341 m_CachedObject.Invalidate();
344 m_FixedOnPosition =
false;
352 if (
m_Target.GetObject() != m_CachedObject.Get())
354 if (!m_FixedOnPosition)
357 m_CachedObject.Invalidate();
366 m_CachedObject.Invalidate();
369 m_FixedOnPosition =
false;
375 else if (
m_Target.GetObject() == m_CachedObject.Get())
377 if (!m_FixedOnPosition)
388 m_CachedObject.Invalidate();
391 m_FixedOnPosition =
false;
401 m_CachedObject.Invalidate();
414 m_CachedObject.Invalidate();
416 m_FixedOnPosition =
false;
425 m_MaxWidthChild = 350;
430 m_Root.FindAnyWidget(widget +
"_btn_icon_xbox").Show(show_xbox_icon);
431 m_Root.FindAnyWidget(widget +
"_btn_icon").Show(!show_xbox_icon);
438 float parent_width, parent_height;
439 vector transformed_pos, screen_pos;
444 m_Root.GetParent().GetScreenSize(parent_width, parent_height);
447 transformed_pos[0] = screen_pos[0] * parent_width;
448 transformed_pos[1] = screen_pos[1] * parent_height;
450 return transformed_pos;
455 const float DEFAULT_HANDLE_OFFSET = 0.2;
456 const string CE_CENTER_COMP_NAME =
"ce_center";
460 float pivotOffset = 0.0;
461 float memOffset = 0.0;
464 bool isTargetForced =
false;
479 compIdx =
m_Target.GetComponentIndex();
482 isTargetForced =
true;
493 compName =
object.GetActionComponentName(compIdx);
494 object.GetActionComponentNameList(compIdx, components);
496 if (
object.GetActionComponentNameList(compIdx, components) == 0 && !
object.IsInventoryItem())
498 m_FixedOnPosition =
true;
502 pivotOffset =
object.ConfigGetFloat(
"actionTargetPivotOffsetY");
503 memOffset =
object.ConfigGetFloat(
"actionTargetMemOffsetY");
506 lod =
object.GetLODByName(MEM_LOD_NAME);
513 if (MiscGameplayFunctions.IsComponentInSelection(memSelections, CE_CENTER_COMP_NAME))
515 for (
int i2 = 0; i2 < memSelections.Count(); ++i2)
517 if (memSelections[i2].
GetName() == CE_CENTER_COMP_NAME && memSelections[i2].GetVertexCount() == 1)
519 m_FixedOnPosition =
false;
520 modelPos =
object.GetSelectionPositionMS(CE_CENTER_COMP_NAME);
521 worldPos =
object.ModelToWorld(modelPos);
522 if (memOffset != 0.0)
524 worldPos[1] = worldPos[1] + memOffset;
528 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
534 m_CachedObject.Store(
object, worldPos, compIdx);
539 for (
int i1 = 0; i1 < memSelections.Count(); ++i1)
542 if (memSelections[i1].
GetName() == compName && memSelections[i1].GetVertexCount() == 1)
544 modelPos =
object.GetSelectionPositionMS(compName);
545 worldPos =
object.ModelToWorld(modelPos);
547 m_FixedOnPosition =
false;
548 if (
object.
GetType() ==
"Fence" ||
object.
GetType() ==
"Watchttower" ||
object.
GetType() ==
"GardenPlot")
549 m_FixedOnPosition =
true;
551 if (memOffset != 0.0)
553 worldPos[1] = worldPos[1] + memOffset;
557 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
562 if (memSelections[i1].
GetName() == compName && memSelections[i1].GetVertexCount() > 1)
564 for (
int j = 0; j < components.Count(); ++j)
568 modelPos =
object.GetSelectionPositionMS(components[j]);
569 worldPos =
object.ModelToWorld(modelPos);
571 m_FixedOnPosition =
false;
572 if (memOffset != 0.0)
574 worldPos[1] = worldPos[1] + memOffset;
578 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
586 m_CachedObject.Store(
object, worldPos, -1);
591 vector ladderHandlePointLS, ladderHandlePointWS;
593 float lastDistance = 0;
595 for (
int i3 = 0; i3 < memSelections.Count(); ++i3)
597 if (memSelections[i3].
GetName() == compName && memSelections[i3].GetVertexCount() > 1)
599 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, 0);
600 ladderHandlePointWS =
object.ModelToWorld(ladderHandlePointLS);
601 closestHandlePos = ladderHandlePointWS;
604 for (
int k = 1; k < memSelections[i3].GetVertexCount(); ++k)
606 ladderHandlePointLS = memSelections[i3].GetVertexPosition(lod, k);
607 ladderHandlePointWS =
object.ModelToWorld(ladderHandlePointLS);
612 closestHandlePos = ladderHandlePointWS;
616 m_FixedOnPosition =
false;
617 worldPos = closestHandlePos;
618 if (memOffset != 0.0)
620 worldPos[1] = worldPos[1] + memOffset;
624 worldPos[1] = worldPos[1] + DEFAULT_HANDLE_OFFSET;
630 m_CachedObject.Store(
object, worldPos, -1);
634 m_FixedOnPosition =
true;
639 m_FixedOnPosition =
true;
644 m_FixedOnPosition =
true;
654 isTargetForced =
false;
660 return MiscGameplayFunctions.IsComponentInSelection(selection, compName);
686 m_ContinuousInteract = null;
705 m_SelectedActionCategory =
m_AM.GetSelectedActionCategory();
709 m_DisplayInteractTarget = m_Interact.GetDisplayInteractObject(
m_Player,
m_Target);
713 m_DisplayInteractTarget = m_Single.GetDisplayInteractObject(
m_Player,
m_Target);
715 else if (m_ContinuousInteract)
717 m_DisplayInteractTarget = m_ContinuousInteract.GetDisplayInteractObject(
m_Player,
m_Target);
721 m_DisplayInteractTarget = null;
746 if (action && action.GetText())
748 desc = action.GetText();
768 if (!tgObject.IsAlive())
771 if (!tgParent || tgObject.DisplayNameRuinAttach())
772 desc = tgObject.GetDisplayName();
774 desc = tgParent.GetDisplayName();
780 if (tgParent && (tgParent.IsItemBase() || tgParent.IsTransport()))
782 targetEntity =
EntityAI.Cast(tgParent);
785 if (tgObject.IsItemBase() || tgObject.IsTransport())
787 targetEntity =
EntityAI.Cast(tgObject);
800 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, tgObject.GetActionComponentName(
m_Target.GetComponentIndex(),
LOD.
NAME_FIRE), zone))
802 desc = DamageSystem.GetDamageDisplayName(targetEntity, zone);
807 targetEntity.GetActionComponentNameList(
m_Target.GetComponentIndex(), selections,
LOD.
NAME_VIEW);
810 for (
int s = 0; s < selections.Count(); s++)
812 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, selections[s], zone))
814 desc = DamageSystem.GetDamageDisplayName(targetEntity, zone);
821 if (targetEntity && desc ==
"")
822 desc = targetEntity.GetDisplayName();
832 if (m_Interact && !m_Interact.HasTarget())
849 if (!tgObject.IsAlive())
851 health = tgObject.GetHealthLevel();
855 if (tgParent && (tgParent.IsItemBase() || tgParent.IsTransport()))
857 targetEntity =
EntityAI.Cast(tgParent);
860 if (tgObject.IsItemBase() || tgObject.IsTransport())
862 targetEntity =
EntityAI.Cast(tgObject);
867 if (!targetEntity.IsDamageDestroyed())
875 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity, tgObject.GetActionComponentName(
m_Target.GetComponentIndex(),
LOD.
NAME_FIRE), zone))
877 health = targetEntity.GetHealthLevel(zone);
883 targetEntity.GetActionComponentNameList(
m_Target.GetComponentIndex(), selections,
LOD.
NAME_VIEW);
885 for (
int s = 0; s < selections.Count(); s++)
887 if (DamageSystem.GetDamageZoneFromComponentName(targetEntity , selections[s], zone))
889 health = targetEntity.GetHealthLevel(zone);
896 health = targetEntity.GetHealthLevel();
901 health = tgObject.GetHealthLevel();
908 protected void GetItemQuantity(out
int q_type, out
float q_cur, out
int q_min, out
int q_max)
912 if (m_Interact && !m_Interact.HasTarget())
958 protected void SetItemDesc(
string descText,
int cargoCount,
string itemWidget,
string descWidget)
961 widget =
m_Root.FindAnyWidget(itemWidget);
966 string msg = playerT.GetLastUAMessage();
976 Class.
CastTo(itemName, widget.FindAnyWidget(descWidget));
981 descText =
string.
Format(
"[+] %1 %2", descText, msg);
982 itemName.SetText(descText);
986 descText =
string.
Format(
"%1 %2", descText, msg);
987 itemName.SetText(descText);
993 protected void SetItemHealth(
int health,
string itemWidget,
string healthWidget,
bool enabled)
997 widget =
m_Root.FindAnyWidget(itemWidget);
1001 ImageWidget healthMark;
1002 Class.
CastTo(healthMark, widget.FindAnyWidget(healthWidget));
1007 healthMark.GetParent().Show(
false);
1011 healthMark.SetAlpha(0.5);
1012 healthMark.GetParent().Show(
true);
1016 healthMark.SetAlpha(0.5);
1017 healthMark.GetParent().Show(
true);
1021 healthMark.SetAlpha(0.5);
1022 healthMark.GetParent().Show(
true);
1026 healthMark.SetAlpha(0.5);
1027 healthMark.GetParent().Show(
true);
1031 healthMark.SetAlpha(0.5);
1032 healthMark.GetParent().Show(
true);
1035 healthMark.SetColor(0x00FFFFFF);
1036 healthMark.SetAlpha(0.5);
1037 healthMark.GetParent().Show(
true);
1047 protected void SetItemQuantity(
int type,
float current,
int min,
int max,
string itemWidget,
string quantityPBWidget,
string quantityTextWidget,
bool enabled)
1051 widget =
m_Root.FindAnyWidget(itemWidget);
1055 ProgressBarWidget progressBar;
1057 Class.
CastTo(progressBar, widget.FindAnyWidget(quantityPBWidget));
1058 Class.
CastTo(textWidget, widget.FindAnyWidget(quantityTextWidget));
1064 progressBar.Show(
false);
1065 textWidget.Show(
false);
1066 textWidget.GetParent().Show(
false);
1069 if (max > 1 || current > 1)
1072 progressBar.Show(
false);
1073 textWidget.SetText(qty_text);
1074 textWidget.Show(
true);
1075 textWidget.GetParent().Show(
true);
1079 progressBar.Show(
false);
1080 textWidget.Show(
false);
1081 textWidget.GetParent().Show(
false);
1085 float qty_num =
Math.
Round((current / max) * 100);
1087 textWidget.Show(
false);
1088 progressBar.SetCurrent(qty_num);
1089 progressBar.Show(
true);
1090 textWidget.GetParent().Show(
true);
1105 if (action.HasTarget() &&
m_AM.GetActionState() < 1)
1108 Class.
CastTo(actionName, widget.FindAnyWidget(descWidget));
1110 if (action.GetInput().GetInputType() ==
ActionInputType.AIT_CONTINUOUS)
1112 descText = descText +
" " +
"#action_target_cursor_hold";
1113 actionName.SetText(descText);
1117 actionName.SetText(descText);
1123 actionName.GetTextSize(
x,
y);
1124 if (
x > m_MaxWidthChild);
1125 m_MaxWidthChild =
x;
1141 Widget widget, widget_not_select;
1143 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1144 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1146 if (m_InteractActionsNum > 1)
1151 widget_not_select.Show(
false);
1156 widget_not_select.Show(
true);
1162 widget_not_select.Show(
false);
1168 Widget widget, widget_not_select;
1170 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1171 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1173 if (m_ContinuousInteractActionsNum > 1)
1178 widget_not_select.Show(
false);
1183 widget_not_select.Show(
true);
1189 widget_not_select.Show(
false);
1196 Widget widget, widget_not_select;
1198 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1199 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1201 if (m_ItemActionsNum > 1)
1206 widget_not_select.Show(
false);
1211 widget_not_select.Show(
true);
1217 widget_not_select.Show(
false);
1223 Widget widget, widget_not_select;
1225 widget =
m_Root.FindAnyWidget(multiActionsWidget);
1226 widget_not_select =
m_Root.FindAnyWidget(multiActionsWidget_NotSelect);
1228 if (m_ContinuousItemActionsNum > 1)
1233 widget_not_select.Show(
false);
1238 widget_not_select.Show(
true);
1244 widget_not_select.Show(
false);
1248 protected void SetInteractActionIcon(
string actionWidget,
string actionIconFrameWidget,
string actionIconWidget,
string actionIconTextWidget)
1251 ImageWidget iconWidget;
1254 widget =
m_Root.FindAnyWidget(actionWidget);
1255 Class.
CastTo(iconWidget, widget.FindAnyWidget(actionIconWidget));
1256 Class.
CastTo(textWidget, widget.FindAnyWidget(actionIconTextWidget));
1261 iconWidget.Show(
false);
1263 textWidget.Show(
true);
1272 w.Show(entity.IsRefresherSignalingViable() &&
m_Player.IsTargetInActiveRefresherRange(entity));
1278 int attachmentsWithInventory = 0;
1286 for (
int i = 0; i < inventory.AttachmentCount(); i++)
1288 EntityAI attachment = inventory.GetAttachmentFromIndex(i);
1289 int attachmentSlotId = attachment.GetInventory().GetSlotId(0);
1291 if (attachment.GetInventory())
1293 attachmentsWithInventory += 1;
1297 return attachmentsWithInventory;
eBleedingSourceType GetType()
protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
protected void OnInputPresetChanged()
ref ActionTarget m_Target
class ActionTargets ActionTarget
protected ActionManagerBase m_AM
static bool IsComponentInSelection(array< Selection > pSelection, string pCompName)
protected Object m_CachedObject
vector GetCursorWorldPos()
protected vector m_CursorWPos
void Invalidate()
invalidate cached objec
protected vector m_ScreenPos
void Store(Object obj, vector pos, int compIdx)
cache object and its world pos
proto native Mission GetMission()
proto native Input GetInput()
proto native vector GetScreenPosRelative(vector world_pos)
Transforms position in world to position in screen in percentage (0.0 - 1.0) as x,...
represents base for cargo storage for entities
proto native int GetItemCount()
Super root of all classes in Enforce script.
const int COLOR_BADLY_DAMAGED
override bool ShowZonesHealth()
script counterpart to engine's class Inventory
override bool IsTakeable()
static const string NAME_FIRE
static const string NAME_MEMORY
proto native bool GetSelections(notnull out array< Selection > selections)
static const string NAME_VIEW
ScriptInvoker GetOnInputPresetChanged()
ScriptInvoker GetOnInputDeviceChanged()
static int HasItemQuantity(notnull EntityAI item)
static float GetItemQuantity(InventoryItem item)
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
proto native UAInput InputP()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
const int QUANTITY_PROGRESS
const int QUANTITY_HIDDEN
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int STATE_BADLY_DAMAGED
static proto float Round(float f)
Returns mathematical round of value.
static proto float AbsFloat(float f)
Returns absolute value.
static proto float Ceil(float f)
Returns ceil of value.
proto void GetScreenSize(out int x, out int y)
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto int ToUpper()
Changes string to uppercase. Returns length.
bool Contains(string sample)
Returns true if sample is substring of string.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
proto native int Length()
Returns length of string.