Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkActionsInputs.c
Go to the documentation of this file.
1 // TODO: make this a generic action which can be used anywhere anytime (i.e. on task finished, etc)
4 {
5  protected SCR_ScenarioFrameworkLogicInput m_Input;
6 
7  //------------------------------------------------------------------------------------------------
10  void Init(SCR_ScenarioFrameworkLogicInput input)
11  {
12  m_Input = input;
13  }
14 }
15 
17 class SCR_ScenarioFrameworkActionInputOnTaskEventIncreaseCounter : SCR_ScenarioFrameworkActionInputBase
18 {
19  [Attribute(desc: "Insert name of the task layer or leave empty for any task")];
20  protected string m_sTaskLayerName;
21 
22  [Attribute("1", UIWidgets.ComboBox, "Task state", "", ParamEnumArray.FromEnum(SCR_TaskState))];
23  protected SCR_TaskState m_eEventName;
24 
25  protected int m_iActionsInput;
26 
27  //------------------------------------------------------------------------------------------------
28  override void Init(SCR_ScenarioFrameworkLogicInput input)
29  {
30  super.Init(input);
31  SCR_GameModeSFManager gameModeComp = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
32  if (!gameModeComp)
33  return;
34 
35  gameModeComp.GetOnTaskStateChanged().Insert(OnActivate);
36  }
37 
38  //------------------------------------------------------------------------------------------------
42  {
43  if (task.GetTaskState() != m_eEventName || !m_Input)
44  return;
45 
46  SCR_ScenarioFrameworkLayerTask taskLayer;
47  string sTaskLayerName = "";
48  if (SCR_ScenarioFrameworkTask.Cast(task))
49  {
50  taskLayer = SCR_ScenarioFrameworkTask.Cast(task).GetLayerTask();
51  if (taskLayer)
52  {
53  sTaskLayerName = taskLayer.GetOwner().GetName();
54  if (taskLayer.GetLayerTaskResolvedBeforeLoad())
55  return;
56  }
57  }
58 
59  if (m_sTaskLayerName.IsEmpty() || m_sTaskLayerName == sTaskLayerName)
60  {
61  if (!(mask & SCR_ETaskEventMask.TASK_ASSIGNEE_CHANGED))
62  m_Input.OnActivate(1, null);
63 
64  if (mask & SCR_ETaskEventMask.TASK_PROPERTY_CHANGED && !(mask & SCR_ETaskEventMask.TASK_CREATED) && !(mask & SCR_ETaskEventMask.TASK_FINISHED) && !(mask & SCR_ETaskEventMask.TASK_ASSIGNEE_CHANGED))
65  {
66  if (taskLayer)
67  {
68  SCR_ScenarioFrameworkSlotTask slotTask = taskLayer.GetSlotTask();
69  if (slotTask)
70  slotTask.OnTaskStateChanged(m_eEventName)
71  }
72  }
73  }
74  }
75 }
76 
77 enum SCR_EScenarioFrameworkComparisonOperator
78 {
79  LESS_THAN,
80  LESS_OR_EQUAL,
81  GREATER_THEN,
82  GREATER_OR_EQUAL,
83  EQUAL
84 }
85 
87 class SCR_ScenarioFrameworkActionInputCheckEntitiesInTrigger : SCR_ScenarioFrameworkActionInputBase
88 {
89  [Attribute(desc: "Trigger")];
90  protected ref SCR_ScenarioFrameworkGet m_Getter;
91 
92  [Attribute("0", UIWidgets.ComboBox, "Operator", "", ParamEnumArray.FromEnum(SCR_EScenarioFrameworkComparisonOperator))]
93  protected SCR_EScenarioFrameworkComparisonOperator m_eComparisonOperator;
94 
95  [Attribute(desc: "Value")];
96  protected int m_iValue;
97 
98  protected SCR_CharacterTriggerEntity m_Trigger;
99 
100  //------------------------------------------------------------------------------------------------
101  override void Init(SCR_ScenarioFrameworkLogicInput input)
102  {
103  super.Init(input);
104  if (!m_Getter)
105  return;
106 
107  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
108  if (!entityWrapper)
109  {
110  PrintFormat("ScenarioFramework: Selected getter %1 is not suitable for this operation", m_Getter.ClassName(), LogLevel.ERROR);
111  return;
112  }
113 
114  IEntity entity = entityWrapper.GetValue();
115  if (!entity)
116  {
117  PrintFormat("ScenarioFramework: Selected getter entity is null", m_Getter.ClassName(), LogLevel.ERROR);
118  return;
119  }
120 
122  if (!layer)
123  return;
124 
125  SCR_CharacterTriggerEntity trigger = SCR_CharacterTriggerEntity.Cast(layer.GetSpawnedEntity());
126  if (!trigger)
127  return; //TODO: add a universal method for informing user about errors
128 
129  m_Trigger = trigger;
130  //We want to give trigger enough time to be properly set up and not to get OnChange called prematurely
131  GetGame().GetCallqueue().CallLater(RegisterOnChange, 5000);
132  }
133 
134  //------------------------------------------------------------------------------------------------
136  void RegisterOnChange()
137  {
138  if (m_Trigger)
139  m_Trigger.GetOnChange().Insert(OnActivate);
140  }
141 
142  //------------------------------------------------------------------------------------------------
144  void OnActivate(SCR_ScenarioFrameworkParam<IEntity> param)
145  {
146  if (!m_Trigger)
147  return;
148 
149  array<IEntity> aEntities = {};
150  int iNrOfEnts = m_Trigger.GetCountEntitiesInside();
151 
152  if (
153  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.LESS_THAN) && (iNrOfEnts < m_iValue)) ||
154  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.LESS_OR_EQUAL) && (iNrOfEnts <= m_iValue)) ||
155  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.EQUAL) && (iNrOfEnts == m_iValue)) ||
156  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.GREATER_OR_EQUAL) && (iNrOfEnts >= m_iValue)) ||
157  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.GREATER_THEN) && (iNrOfEnts > m_iValue))
158  )
159  {
160  m_Input.OnActivate(true, m_Trigger);
161  }
162  }
163 
164 }
165 
167 class SCR_ScenarioFrameworkActionInputCheckEntitiesInAreaTrigger : SCR_ScenarioFrameworkActionInputCheckEntitiesInTrigger
168 {
169  //------------------------------------------------------------------------------------------------
170  override void Init(SCR_ScenarioFrameworkLogicInput input)
171  {
172  super.Init(input);
173  if (!m_Getter)
174  return;
175 
176  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
177  if (!entityWrapper)
178  {
179  PrintFormat("ScenarioFramework: Selected getter %1 is not suitable for this operation", m_Getter.ClassName(), LogLevel.ERROR);
180  return;
181  }
182 
183  IEntity entity = entityWrapper.GetValue();
184  if (!entity)
185  {
186  PrintFormat("ScenarioFramework: Selected getter entity is null", m_Getter.ClassName(), LogLevel.ERROR);
187  return;
188  }
189 
191  if (!layer)
192  return;
193 
195  if (!area)
196  return;
197 
198  SCR_CharacterTriggerEntity trigger = SCR_CharacterTriggerEntity.Cast(area.GetTrigger());
199  if (!trigger)
200  return;
201 
202  m_Trigger = trigger;
203  //We want to give trigger enough time to be properly set up and not to get OnChange called prematurely
204  GetGame().GetCallqueue().CallLater(RegisterOnChange, 5000);
205  }
206 }
BaseContainerProps
class SCR_ScenarioFrameworkActionInputBase BaseContainerProps()
m_Input
CharacterInputContext m_Input
Definition: SCR_CharacterCommandSwim.c:217
m_Input
protected SCR_ScenarioFrameworkLogicInput m_Input
Definition: SCR_ScenarioFrameworkActionsInputs.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_iValue
protected int m_iValue
Definition: SCR_VotingBase.c:3
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
Init
void Init(SCR_ScenarioFrameworkLogicInput input)
Definition: SCR_ScenarioFrameworkActionsInputs.c:7
OnActivate
override void OnActivate()
Definition: SCR_CharacterCommandLoiter.c:23
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ContainerActionTitle
SCR_ContainerActionTitle BaseContainerCustomTitle SCR_ContainerActionTitle()] class SCR_ScenarioFrameworkActionBase
Definition: SCR_ScenarioFrameworkActions.c:43
SCR_ScenarioFrameworkArea
Definition: SCR_ScenarioFrameworkArea.c:24
EQUAL
@ EQUAL
Definition: SCR_Comparer.c:4
SCR_ScenarioFrameworkActionInputBase
Definition: SCR_ScenarioFrameworkActionsInputs.c:3
SCR_ScenarioFrameworkLogicInput
Definition: SCR_ScenarioFrameworkLogic.c:2
SCR_ETaskEventMask
SCR_ETaskEventMask
Definition: SCR_BaseTaskManager.c:13
SCR_CharacterTriggerEntity
Definition: SCR_CharacterTriggerEntity.c:17
SCR_TaskState
SCR_TaskState
Definition: SCR_TaskState.c:2
SCR_ScenarioFrameworkLayerBase
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkLayerBase.c:875
LESS_THAN
@ LESS_THAN
Definition: SCR_ValueAttributeDynamicDescription.c:98
SCR_ScenarioFrameworkTask
Definition: SCR_ScenarioFrameworkTask.c:7
SCR_ScenarioFrameworkGet
Definition: SCR_ScenarioFrameworkActionsGetters.c:26