20 [
Attribute(
"#AR-Tasks_TaskCompletionConditions")]
42 return extendedData.m_sCustomSubtaskDescription;
62 extendedData.m_sCustomSubtaskDescription = subTaskDescription;
79 return childTasks && !childTasks.IsEmpty();
91 return extendedData.m_aChildTasks.Count();
111 return extendedData.m_iNodeDepth;
120 if (!extendedData || !extendedData.m_ParentTask)
123 RplComponent rpl = RplComponent.Cast(
Replication.FindItem(extendedData.m_ParentTask));
127 return SCR_Task.Cast(rpl.GetEntity());
133 RplComponent rpl = RplComponent.Cast(parentTask.FindComponent(RplComponent));
137 RplId rplID = rpl.Id();
149 RplComponent rpl = RplComponent.Cast(
Replication.FindItem(parentTaskRplID));
154 if (!extendedParentTask)
162 if (parentTaskData.m_bLinkDataToRelatedTasks)
169 extendedData.m_ParentTask = parentTaskRplID;
170 extendedData.m_iNodeDepth = extendedParentTask.
GetNodeDepth() + 1;
179 if (!extendedData || !extendedData.m_aChildTasks)
185 array<SCR_Task> childTasks = {};
186 foreach (
RplId rplID : extendedData.m_aChildTasks)
188 rpl = RplComponent.Cast(
Replication.FindItem(rplID));
196 childTasks.Insert(
task);
216 RplComponent rpl = RplComponent.Cast(extendedTask.FindComponent(RplComponent));
220 RplId rplID = rpl.Id();
236 if (!extendedData || !taskRplID)
239 if (!extendedData.m_aChildTasks)
240 extendedData.m_aChildTasks =
new array<RplId>();
242 if (extendedData.m_aChildTasks.Contains(taskRplID))
245 extendedData.m_aChildTasks.Insert(taskRplID);
247 RplComponent rpl = RplComponent.Cast(
Replication.FindItem(taskRplID));
273 RplComponent rpl = RplComponent.Cast(extendedTask.FindComponent(RplComponent));
277 RplId rplID = rpl.Id();
281 array<ref SCR_TaskExecutor> assignees = extendedTask.GetTaskAssignees();
282 if (assignees && !assignees.IsEmpty())
300 if (!extendedData || !taskRplID)
303 if (!extendedData.m_aChildTasks || !extendedData.m_aChildTasks.Contains(taskRplID))
306 extendedData.m_aChildTasks.RemoveItem(taskRplID);
308 RplComponent rpl = RplComponent.Cast(
Replication.FindItem(taskRplID));
329 return extendedData.m_fProgress;
339 if (!extendedData || percentage == extendedData.m_fProgress)
348 float previousProgress = extendedData.m_fProgress;
355 if (extendedData.m_fProgress >= previousProgress)
381 if (!extendedData.m_bLinkDataToRelatedTasks)
390 previousProgress /= childTaskCount;
393 percentage /= childTaskCount;
405 extendedData.m_fProgress = percentage;
418 if (!extendedData || percentage <= 0)
441 if (!extendedData.m_bLinkDataToRelatedTasks)
457 if (!extendedData || percentage <= 0)
460 extendedData.m_fProgress += percentage;
463 m_OnProgressChanged.Invoke(extendedData.m_fProgress - percentage, extendedData.m_fProgress);
473 if (!extendedData || percentage <= 0)
476 if (percentage > extendedData.m_fProgress)
477 percentage = extendedData.m_fProgress;
490 if (!extendedData.m_bLinkDataToRelatedTasks)
506 if (!extendedData || percentage <= 0)
509 extendedData.m_fProgress -= percentage;
512 m_OnProgressChanged.Invoke(extendedData.m_fProgress + percentage, extendedData.m_fProgress);
524 return extendedData.m_bEnableProgress;
549 extendedData.m_bEnableProgress = enable;
562 if (!super.AddTaskAssignee(executor, listenToInvokers, requesterID))
570 if (parent && !parent.
AddTaskAssignee(executor, listenToInvokers, requesterID))
586 if (!super.RemoveTaskAssignee(executor, listenToInvokers, requesterID))
603 if (!childTasks || childTasks.IsEmpty())
607 foreach (
SCR_Task childTask : childTasks)
623 super.Rpc_AddOwnerFactionKey(factionKey);
629 if (!extendedData.m_bLinkDataToRelatedTasks)
633 if (!childTasks || childTasks.IsEmpty())
637 foreach (
SCR_Task childTask : childTasks)
643 child.AddOwnerFactionKey(factionKey);
651 super.Rpc_RemoveOwnerFactionKey(factionKey);
657 if (!extendedData.m_bLinkDataToRelatedTasks)
661 if (!childTasks || childTasks.IsEmpty())
665 foreach (
SCR_Task childTask : childTasks)
671 child.RemoveOwnerFactionKey(factionKey);
679 super.Rpc_AddOwnerGroupID(groupID);
685 if (!extendedData.m_bLinkDataToRelatedTasks)
689 if (!childTasks || childTasks.IsEmpty())
693 foreach (
SCR_Task childTask : childTasks)
699 child.AddOwnerGroupID(groupID);
707 super.Rpc_RemoveOwnerGroupID(groupID);
713 if (!extendedData.m_bLinkDataToRelatedTasks)
717 if (!childTasks || childTasks.IsEmpty())
721 foreach (
SCR_Task childTask : childTasks)
727 child.RemoveOwnerGroupID(groupID);
737 if (!super.AddOwnerExecutor(executor))
744 if (!extendedData.m_bLinkDataToRelatedTasks)
748 if (!childTasks || childTasks.IsEmpty())
752 foreach (
SCR_Task childTask : childTasks)
770 if (!super.RemoveOwnerExecutor(executor))
777 if (!extendedData.m_bLinkDataToRelatedTasks)
781 if (!childTasks || childTasks.IsEmpty())
785 foreach (
SCR_Task childTask : childTasks)
800 super.SetTaskState(state);
809 if (!extendedData.m_bLinkDataToRelatedTasks)
817 if (!extendedDataParent)
820 if (!extendedDataParent.m_bEnableProgress)
831 super.Rpc_SetTaskOwnership(ownership);
837 if (!extendedData.m_bLinkDataToRelatedTasks)
841 if (!childTasks || childTasks.IsEmpty())
845 foreach (
SCR_Task childTask : childTasks)
851 if (child.GetTaskOwnership() > ownership)
852 child.SetTaskOwnership(ownership);
860 super.Rpc_SetTaskVisibility(visibility);
866 if (!extendedData.m_bLinkDataToRelatedTasks)
870 if (!childTasks || childTasks.IsEmpty())
874 foreach (
SCR_Task childTask : childTasks)
880 if (child.GetTaskVisibility() > visibility)
881 child.SetTaskVisibility(visibility);
920 override void _WB_AfterWorldUpdate(
float timeSlice)
928 override protected bool RplSave(ScriptBitWriter writer)
930 if (!super.RplSave(writer))
936 writer.WriteBool(
false);
940 writer.WriteBool(
true);
941 writer.WriteRplId(extendedData.m_ParentTask);
942 writer.WriteInt(extendedData.m_iNodeDepth);
944 writer.WriteBool(extendedData.m_bLinkDataToRelatedTasks);
946 writer.WriteFloat(extendedData.m_fProgress);
947 writer.WriteBool(extendedData.m_bEnableProgress);
949 writer.WriteString(extendedData.m_sCustomSubtaskDescription);
951 int childTaskCount = 0;
952 if (extendedData.m_aChildTasks)
953 childTaskCount = extendedData.m_aChildTasks.Count();
955 writer.WriteInt(childTaskCount);
956 if (childTaskCount > 0)
958 foreach (
RplId rplID : extendedData.m_aChildTasks)
960 writer.WriteRplId(rplID);
973 if (!super.RplLoad(reader))
976 bool hasExtendedData;
977 reader.ReadBool(hasExtendedData);
978 if (!hasExtendedData)
988 reader.ReadRplId(extendedData.m_ParentTask);
989 reader.ReadInt(extendedData.m_iNodeDepth);
991 reader.ReadBool(extendedData.m_bLinkDataToRelatedTasks);
993 reader.ReadFloat(extendedData.m_fProgress);
994 reader.ReadBool(extendedData.m_bEnableProgress);
996 reader.ReadString(extendedData.m_sCustomSubtaskDescription);
999 reader.ReadInt(childTaskCount);
1000 if (childTaskCount > 0)
1002 extendedData.m_aChildTasks = {};
1004 for (
int i = 0; i < childTaskCount; i++)
1007 reader.ReadRplId(rplID);
1009 if (rplID.IsValid())
1010 extendedData.m_aChildTasks.Insert(rplID);
1023 super.InitializeData();
1029 extendedData.m_ParentTask =
RplId.Invalid();
1030 extendedData.m_iNodeDepth = 0;
1032 extendedData.m_aChildTasks = {};
1045 float combinedProgress = 0;
1064 if (combinedProgress <= 0)
1077 super.EOnInit(owner);
ArmaReforgerScripted GetGame()
ScriptInvokerBase< ChildTaskInvokerDelegate > SCR_ChildTaskInvoker
func ChildTaskInvokerDelegate
void GetChildren(out array< SCR_ScenarioFrameworkLayerBase > children)
ScriptInvokerBase< ScriptInvokerFloat2Method > ScriptInvokerFloat2
void SCR_Task(IEntitySource src, IEntity parent)
ref SCR_TaskData m_TaskData
proto external IEntity GetSibling()
Replication item identifier.
const float MAX_TASK_PROGRESSION_PERCENTAGE
SCR_ChildTaskInvoker GetOnChildTaskRemoved()
SCR_ChildTaskInvoker GetOnChildTaskAdded()
void SetTaskProgress(float percentage, bool changeState=true)
override bool AddTaskAssignee(SCR_TaskExecutor executor, bool listenToInvokers=true, int requesterID=0)
void ShowTaskProgress(bool enable)
void Rpc_AddChildTask(RplId taskRplID)
void SetCustomSubtaskDescription(LocalizedString subTaskDescription)
LocalizedString GetCustomSubtaskDescription()
bool m_bLinkDataToRelatedTasks
void Rpc_RemoveOwnerFactionKey(FactionKey factionKey)
void Rpc_ShowTaskProgress(bool enable)
void RemoveTaskProgress(float percentage, bool changeState=true)
override bool RemoveOwnerExecutor(SCR_TaskExecutor executor)
array< SCR_Task > GetChildTasks()
void Rpc_SetTaskProgress(float percentage, float previousProgress)
void Rpc_SetTaskVisibility(SCR_ETaskVisibility visibility)
bool RemoveChildTask(SCR_Task task)
void Rpc_AddOwnerGroupID(int groupID)
ref SCR_ChildTaskInvoker m_OnChildTaskRemoved
override bool RemoveTaskAssignee(SCR_TaskExecutor executor, bool listenToInvokers=true, int requesterID=0)
bool AddChildTask(SCR_Task task)
ref ScriptInvokerFloat2 m_OnProgressChanged
void Rpc_SetTaskOwnership(SCR_ETaskOwnership ownership)
bool CanTaskProgressBeShown()
void Rpc_RemoveTaskProgress(float percentage)
const float MIN_TASK_PROGRESSION_PERCENTAGE
bool RplSave(ScriptBitWriter writer)
void Rpc_AddOwnerFactionKey(FactionKey factionKey)
void Rpc_RemoveOwnerGroupID(int groupID)
ref SCR_ChildTaskInvoker m_OnChildTaskAdded
void Rpc_SetCustomSubtaskDescription(LocalizedString subTaskDescription)
bool RplLoad(ScriptBitReader reader)
void InitializeChildTasks()
SCR_ETaskState m_eCachedTaskState
LocalizedString m_sCustomSubtaskDescription
override void EOnInit(IEntity owner)
void AddTaskProgress(float percentage, bool changeState=true)
override bool AddOwnerExecutor(SCR_TaskExecutor executor)
override void SetTaskState(SCR_ETaskState state)
void Rpc_RemoveChildTask(RplId taskRplID)
ScriptInvokerFloat2 GetOnProgressChanged()
void Rpc_AddTaskProgress(float percentage)
void SetParentTask(SCR_ExtendedTask parentTask)
void Rpc_SetParentTask(RplId parentTaskRplID)
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.