Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditableTaskComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor (Editables)", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3{
4 [Attribute("#AR-Tasks_Objective", desc: "Name of objective type eg: Attack objective. Used among in, among other things, in notifications", category: "Visualization")]
6
7 //------------------------------------------------------------------------------------------------
14}
15
17
20{
21 protected SCR_EditorTask m_Task;
23 protected int m_iTextIndex;
24
27
28 [RplProp(onRplName: "OnAttachedToId")]
30
31
32 //------------------------------------------------------------------------------------------------
35 protected void AttachTo(SCR_EditableEntityComponent attachedTo)
36 {
37 //++ Remove from the existing parent first
38 if (GetOwner().GetParent())
39 m_AttachableTask.GetParent().RemoveChild(m_AttachableTask, true);
40
41
42 //++ Add to the new parent (when defined)
43 if (attachedTo)
44 {
45
46 //++ Do not allow to attach if target exceeds attached entities number
47 if (attachedTo.GetAttachedEntities().Count() >= EditorConstants.MAX_ATTACHED_ENTITIES)
48 {
49 SCR_NotificationsComponent.SendLocal(ENotification.EDITOR_PLACING_BLOCKED, SCR_PlayerController.GetLocalPlayerId());
50 return;
51 }
52
53 m_AttachableTask.SetOrigin(vector.Zero);
54 attachedTo.GetOwner().AddChild(m_AttachableTask, -1);
55 m_AttachableTask.SetTarget(attachedTo);
56 attachedTo.Attach(this);
57 }
58 else
59 {
60 m_AttachableTask.SetTarget(null);
61 if (m_AttachedTo)
62 m_AttachedTo.Detach(this);
63 }
64
65 m_AttachedTo = attachedTo;
67 UpdateText();
68 }
69
70
71 //------------------------------------------------------------------------------------------------
73 protected void OnAttachedToId()
74 {
76 AttachTo(attachedTo);
77 }
78
79 //------------------------------------------------------------------------------------------------
84
85 //------------------------------------------------------------------------------------------------
88 ETaskTextType GetTextType()
89 {
90 return m_Task.GetTextType();
91 }
92
93 //------------------------------------------------------------------------------------------------
97 {
98 return m_iTextIndex;
99 }
100
101 //------------------------------------------------------------------------------------------------
109
110 //------------------------------------------------------------------------------------------------
111 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
112 protected void SetTextIndexBroadcast(int index)
113 {
115 m_Task.SetTextIndex(index);
116 UpdateText();
117 }
118
119 //------------------------------------------------------------------------------------------------
123 {
124 return m_Task.GetTaskCompletionType();
125 }
126
127 //------------------------------------------------------------------------------------------------
131 {
132 if (m_Task.GetTaskCompletionType() == completionType)
133 return;
134
135 SetTaskCompletionTypeBroadcast(completionType);
136 Rpc(SetTaskCompletionTypeBroadcast, completionType);
137 }
138
139 //------------------------------------------------------------------------------------------------
140 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
142 {
143 m_Task.SetTaskCompletionType(completionType);
144 }
145
146 //------------------------------------------------------------------------------------------------
147 protected void UpdateText()
148 {
150
151 m_Task.SetTextIndex(m_iTextIndex);
152 m_Task.SetLocationName(m_UIInfoDescriptor.GetLocationName());
153
155 if (!textsComponent)
156 return;
157
158 SCR_UIDescription info = textsComponent.GetText(m_Task.GetTextType(), m_Task.GetTextIndex());
159 m_Task.SetTaskName(info.GetUnformattedName(), {m_Task.GetLocationName()});
160 m_Task.SetTaskDescription(info.GetUnformattedDescription());
161 m_Task.SetTaskIconPath(m_UIInfoDescriptor.GetIconPath());
162 m_Task.SetTaskIconSetName(m_UIInfoDescriptor.GetIconSetName());
163
164 UpdateInfo(m_Task.GetTaskUIInfo());
165 }
166
167 //------------------------------------------------------------------------------------------------
168 override protected void GetOnLocationChange(SCR_EditableEntityComponent nearestLocation)
169 {
170 UpdateText();
171 }
172
173 //------------------------------------------------------------------------------------------------
175 {
176 return m_TargetFaction;
177 }
178
179 //------------------------------------------------------------------------------------------------
180 void SetTargetFaction(notnull Faction faction)
181 {
182 m_TargetFaction = faction;
183 }
184
185 //------------------------------------------------------------------------------------------------
186 override bool SetTransform(vector transform[4], bool changedByUser = false)
187 {
188 //--- If it is moved by the user and has attached task, unlink it
189
190 if (m_AttachableTask && changedByUser)
191 AttachTo(null);
192
193 if (!super.SetTransform(transform, changedByUser))
194 return false;
195
197 return true;
198 }
199
200 //------------------------------------------------------------------------------------------------
202 {
203 return Event_OnUIRefresh;
204 }
205
206 //------------------------------------------------------------------------------------------------
207 override bool RplSave(ScriptBitWriter writer)
208 {
209 if (!super.RplSave(writer))
210 return false;
211
212 int factionIndex;
213 if (GetGame().GetFactionManager())
214 factionIndex = GetGame().GetFactionManager().GetFactionIndex(m_TargetFaction);
215
216 writer.WriteInt(factionIndex);
217 writer.WriteInt(m_iTextIndex);
218 writer.WriteRplId(m_AttachedToId);
219
220 return true;
221 }
222
223 //------------------------------------------------------------------------------------------------
224 override bool RplLoad(ScriptBitReader reader)
225 {
226 if (!super.RplLoad(reader))
227 return false;
228
229 int factionIndex;
230 reader.ReadInt(factionIndex);
231 if (GetGame().GetFactionManager())
232 m_TargetFaction = GetGame().GetFactionManager().GetFactionByIndex(factionIndex);
233
234 reader.ReadInt(m_iTextIndex);
235 reader.ReadRplId(m_AttachedToId);
237
238 m_Task.SetTextIndex(m_iTextIndex);
239
240 UpdateText();
241
242 return true;
243 }
244
245 //------------------------------------------------------------------------------------------------
247 {
248 if (recipient)
249 {
250 m_TargetFaction = recipient.GetFaction();
251 if (m_TargetFaction)
252 {
254 m_Task.SetTaskOwnership(SCR_ETaskOwnership.FACTION);
255 m_Task.SetTaskVisibility(SCR_ETaskVisibility.FACTION);
256 m_Task.AddOwnerFactionKey(m_TargetFaction.GetFactionKey());
257 }
258 }
259 return this;
260 }
261
262 //------------------------------------------------------------------------------------------------
263 override void OnParentEntityChanged(SCR_EditableEntityComponent parentEntity, SCR_EditableEntityComponent parentEntityPrev, bool changedByUser)
264 {
266 {
267 AttachTo(parentEntity);
268
269 m_AttachedToId = Replication.FindItemId(parentEntity);
270 Replication.BumpMe();
271
272 super.OnParentEntityChanged(null, null, changedByUser); //--- Needed to continue entity registration
273 }
274 else
275 {
276 super.OnParentEntityChanged(parentEntity, parentEntityPrev, changedByUser);
277 }
278 }
279
280 //------------------------------------------------------------------------------------------------
286 {
287 m_Task = SCR_EditorTask.Cast(ent);
289 }
290
291 //------------------------------------------------------------------------------------------------
292 override bool Delete(bool changedByUser = false, bool updateNavmesh = true)
293 {
294 if (m_Task)
295 m_Task.ShowTaskNotification(ENotification.EDITOR_TASK_DELETED, true);
296
297 return super.Delete(changedByUser, updateNavmesh);
298 }
299
300 //------------------------------------------------------------------------------------------------
301 override bool IsAttachable()
302 {
303 return true;
304 }
305
306 //------------------------------------------------------------------------------------------------
307 override bool IsAttached()
308 {
309 if (GetAttachedTo())
310 return true;
311
312 return false;
313 }
314}
SCR_EAIThreatSectorFlags flags
EEditorPlacingFlags
EEditorTaskCompletionType
Way of determening if a task is completed automaticly, manually or always manually (In the latter cas...
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
override bool RplSave(ScriptBitWriter writer)
SCR_CampaignFaction GetFaction()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
override void OnParentEntityChanged(SCR_EditableEntityComponent parentEntity, SCR_EditableEntityComponent parentEntityPrev, bool changedByUser)
override SCR_EditableEntityComponent EOnEditorPlace(out SCR_EditableEntityComponent parent, SCR_EditableEntityComponent recipient, EEditorPlacingFlags flags, bool isQueue, int playerID=0)
override bool SetTransform(vector transform[4], bool changedByUser=false)
override bool Delete(bool changedByUser=false, bool updateNavmesh=true)
override ScriptInvoker GetOnUIRefresh()
void SCR_EditableDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_EditableEntityComponent m_NearestLocation
ref SCR_EditableDescriptorUIInfo m_UIInfoDescriptor
void GetOnLocationChange(SCR_EditableEntityComponent nearestLocation)
bool UpdateNearestLocation(vector pos=vector.Zero)
void UpdateInfo(SCR_UIDescription from=null)
ref ScriptInvoker Event_OnUIRefresh
ETaskTextType GetTextType()
SCR_AttachableTask m_AttachableTask
void SCR_EditableTaskComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
RplId m_AttachedToId
override SCR_EditableEntityComponent GetAttachedTo()
Faction m_TargetFaction
void SetTextIndex(int index)
void SetTaskCompletionType(EEditorTaskCompletionType completionType)
override bool IsAttachable()
void SetTextIndexBroadcast(int index)
int GetTextIndex()
void OnAttachedToId()
Runs when an ID is attached.
void SetTaskCompletionTypeBroadcast(EEditorTaskCompletionType completionType)
SCR_EditableEntityComponent m_AttachedTo
void SetTargetFaction(notnull Faction faction)
EEditorTaskCompletionType GetTaskCompletionType()
override bool IsAttached()
Faction GetParent()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_ETaskVisibility
Definition SCR_Task.c:24
void SCR_TextsTaskManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Main replication API.
Definition Replication.c:14
Replication item identifier.
Definition RplId.c:14
set< SCR_EditableEntityComponent > GetAttachedEntities()
void Attach(notnull SCR_EditableEntityComponent attachable)
void AddChild(SCR_EditableEntityComponent entity)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
LocalizedString GetUnformattedDescription()
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_EditableTaskComponentClass m_Task
Editable SCR_BaseTask.
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134