Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_UserContextAction.c
Go to the documentation of this file.
3 {
4  protected SCR_EditableEntityComponent m_HoveredEntity;
5 
6  override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
7  {
8  if (!hoveredEntity)
9  return false;
10 
11  //--- DIRTY HACK - get the entity itself, not the composition the entity is in. ToDo: CLEANER!
12  if (!IsServer())
13  {
14  hoveredEntity = SCR_BaseEditableEntityFilter.GetFirstEntity(EEditableEntityState.HOVER);
15  m_HoveredEntity = hoveredEntity;
16 
17  //~ Tried to set new hovered entity but it was null
18  if (!hoveredEntity)
19  return false;
20  }
21 
22  BaseActionsManagerComponent actionsManager = BaseActionsManagerComponent.Cast(hoveredEntity.GetOwnerScripted().FindComponent(BaseActionsManagerComponent));
23  if (!actionsManager || actionsManager.GetActionsCount() != 1)
24  return false;
25 
26  ScriptedUserAction action = ScriptedUserAction.Cast(actionsManager.GetFirstAction());
27  if (!action || !action.CanBePerformed(SCR_EditorManagerEntity.GetInstance()))
28  return false;
29 
30  //--- Update info with action name
32  if (info)
33  info.SetName(action.GetActionName());
34 
35  return true;
36  }
37  override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
38  {
39  return CanBeShown(hoveredEntity, selectedEntities, cursorWorldPosition, flags);
40  }
41  override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags, int param = -1)
42  {
43  if (!hoveredEntity)
44  return;
45 
46  //--- DIRTY HACK - use cached entity from CanBeShown (at this moment entity under cursor may differ). ToDo: CLEANER!
47  if (!IsServer() && hoveredEntity)
48  {
49  hoveredEntity = m_HoveredEntity;
50 
51  //~ Tried to set new hovered entity but it was null
52  if (!hoveredEntity)
53  return;
54  }
55 
56  IEntity owner = hoveredEntity.GetOwnerScripted();
57  if (!owner)
58  return;
59 
60  BaseActionsManagerComponent actionsManager = BaseActionsManagerComponent.Cast(owner.FindComponent(BaseActionsManagerComponent));
61  if (!actionsManager || actionsManager.GetActionsCount() != 1)
62  return;
63 
64  ScriptedUserAction action = ScriptedUserAction.Cast(actionsManager.GetFirstAction());
65  if (!action || !action.CanBePerformed(SCR_EditorManagerEntity.GetInstance()))
66  return;
67 
69  if (manager)
70  manager.PerformFirstAction(owner);
71  }
72 };
EEditableEntityState
EEditableEntityState
Definition: EEditableEntityState.c:37
ScriptedUserAction
Definition: ScriptedUserAction.c:12
SCR_BaseContextAction
Definition: SCR_BaseContextAction.c:7
m_Info
protected ref SCR_HintUIInfo m_Info
Definition: SCR_BaseHintCondition.c:3
m_HoveredEntity
protected SCR_EditableEntityComponent m_HoveredEntity
Definition: SCR_BaseActionsEditorComponent.c:154
SCR_BaseEditableEntityFilter
Definition: SCR_BaseEditableEntityFilter.c:13
SCR_WorldEntityDelegateEditorComponent
Definition: SCR_WorldEntityDelegateEditorComponent.c:13
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_OverridableUIInfo
Definition: SCR_OverridableUIInfo.c:4
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
SCR_UserContextAction
Definition: SCR_UserContextAction.c:2
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26