12 string m_sTaskDescription;
15 SCR_ESFTaskType m_eTypeOfTask = SCR_ESFTaskType.DEFAULT;
18 ResourceName m_sTaskPrefab;
20 [
Attribute(
desc:
"Marker on map is placed directly on the task subject Slot or on layer Slot",
category:
"Task")]
21 bool m_bPlaceMarkerOnSubjectSlot;
24 string m_sOverrideObjectDisplayName;
27 ref array<ref SCR_ScenarioFrameworkActionBase> m_aTriggerActionsOnFinish;
29 SCR_ScenarioFrameworkSlotTask m_SlotTask;
33 bool m_bTaskResolvedBeforeLoad;
35 static const ref ScriptInvoker s_OnTaskSetup =
new ScriptInvoker();
39 protected bool m_bShowDebugShapesInWorkbench;
46 return m_eLayerTaskState;
53 return m_bTaskResolvedBeforeLoad;
60 m_eLayerTaskState = state;
82 return m_sOverrideObjectDisplayName;
90 m_sOverrideObjectDisplayName = name;
104 return m_sTaskDescription;
111 if (!m_sOverrideObjectDisplayName.IsEmpty() && m_SlotTask && m_SlotTask.GetOverridenObjectDisplayName().IsEmpty())
112 m_SlotTask.SetOverridenObjectDisplayName(m_sOverrideObjectDisplayName);
114 return m_sTaskDescription;
121 return m_eTypeOfTask;
126 override void RestoreToDefault(
bool includeChildren =
false,
bool reinitAfterRestoration =
false)
128 foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aTriggerActionsOnFinish)
130 activationAction.m_iNumberOfActivations = 0;
135 m_SupportEntity =
null;
137 m_bTaskResolvedBeforeLoad =
false;
139 super.RestoreToDefault(includeChildren, reinitAfterRestoration);
145 Init(
null, SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT);
164 if (!activationCondition.Init(
GetOwner()))
177 child.DynamicDespawn(
this);
192 override void Init(
SCR_ScenarioFrameworkArea area =
null, SCR_ScenarioFrameworkEActivationType activation = SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
202 SCR_GameModeSFManager gameModeComp = SCR_GameModeSFManager.Cast(
GetGame().
GetGameMode().FindComponent(SCR_GameModeSFManager));
204 area = gameModeComp.GetParentArea(
GetOwner());
209 bool previouslyRandomized;
211 previouslyRandomized =
true;
219 Print(
"ScenarioFramework: Task manager not found in the world, tasks won't be created!", LogLevel.ERROR);
236 m_eLayerTaskState = newState;
238 if (newState ==
SCR_TaskState.FINISHED && !m_bTaskResolvedBeforeLoad)
240 foreach (SCR_ScenarioFrameworkActionBase triggerAction : m_aTriggerActionsOnFinish)
242 triggerAction.OnActivate(
GetOwner());
250 if (!m_SupportEntity.GetTaskPrefab())
252 if (m_sTaskPrefab.IsEmpty())
254 Print(
"ScenarioFramework: Task prefab not set, task won't be created!", LogLevel.ERROR);
258 m_SupportEntity.SetTaskPrefab(m_sTaskPrefab);
268 m_SlotTask = slotTask;
283 Print(
"ScenarioFramework: Default Task support entity not found in the world, task won't be created!", LogLevel.ERROR);
299 m_SlotTask =
m_Task.GetSlotTask();
311 Print(
string.Format(
"ScenarioFramework: %1 could not reinit task due to missing m_SlotTask!",
GetOwner().
GetName()), LogLevel.ERROR);
317 if (m_bPlaceMarkerOnSubjectSlot && m_SlotTask)
318 vOrigin = m_SlotTask.GetOwner().GetOrigin();
322 m_SupportEntity.MoveTask(vOrigin,
m_Task.GetTaskID());
329 m_bTaskResolvedBeforeLoad =
true;
330 m_SlotTask.SetTaskResolvedBeforeLoad(
true);
331 m_SupportEntity.FinishTask(
m_Task);
335 m_SlotTask.SetTaskResolvedBeforeLoad(
true);
336 m_SupportEntity.FailTask(
m_Task);
340 m_SlotTask.SetTaskResolvedBeforeLoad(
true);
341 m_SupportEntity.CancelTask(
m_Task.GetTaskID());
355 Print(
string.Format(
"ScenarioFramework: %1 could not init task due to missing m_SlotTask!",
GetOwner().
GetName()), LogLevel.ERROR);
362 m_Task.SetLayerTask(
this);
368 m_bTaskResolvedBeforeLoad =
true;
369 m_SlotTask.SetTaskResolvedBeforeLoad(
true);
370 m_SupportEntity.FinishTask(
m_Task);
374 m_SlotTask.SetTaskResolvedBeforeLoad(
true);
375 m_SupportEntity.FailTask(
m_Task);
379 m_SlotTask.SetTaskResolvedBeforeLoad(
true);
380 m_SupportEntity.CancelTask(
m_Task.GetTaskID());
394 Print(
string.Format(
"ScenarioFramework: Creating of task %1 failed! Task manager refused to create it.", m_sTaskTitle), LogLevel.ERROR);
398 array<Faction> aPlayableFactions = {};
400 FactionManager manager =
GetGame().GetFactionManager();
403 Print(
string.Format(
"ScenarioFramework: Creating of task %1 failed! Faction manager doesn't exist", m_sTaskTitle), LogLevel.ERROR);
407 manager.GetFactionsList(aPlayableFactions);
413 foreach (
Faction faction : aPlayableFactions)
426 if (faction == testFaction)
434 if (!factionSelected)
436 Print(
string.Format(
"ScenarioFramework: Creating of task %1 failed for %2! No playable faction available", m_sTaskTitle,
GetOwner().
GetName()), LogLevel.ERROR);
440 m_Task.SetSlotTask(m_SlotTask);
441 m_SupportEntity.SetTargetFaction(
m_Task, factionSelected);
443 if (m_bPlaceMarkerOnSubjectSlot && m_SlotTask)
444 vOrigin = m_SlotTask.GetOwner().GetOrigin();
448 m_SupportEntity.MoveTask(vOrigin,
m_Task.GetTaskID());
457 if (!m_sTaskTitle.IsEmpty())
458 m_SupportEntity.SetTaskTitle(
m_Task, m_sTaskTitle);
460 if (!m_sTaskDescription.IsEmpty())
466 m_SupportEntity.SetSpawnedEntityName(
m_Task, m_SlotTask.GetSpawnedEntityDisplayName());
468 if (!m_SlotTask.GetTaskTitle().IsEmpty())
469 m_SupportEntity.SetTaskTitle(
m_Task, m_SlotTask.GetTaskTitle());
471 if (!m_SlotTask.GetTaskDescription().IsEmpty())
472 m_SupportEntity.SetTaskDescription(
m_Task, m_SlotTask.GetTaskDescription());
474 m_SupportEntity.SetTaskExecutionBriefing(
m_Task, m_SlotTask.GetTaskExecutionBriefing());
475 m_Task.m_sTaskIntroVoiceline = m_SlotTask.m_sTaskIntroVoiceline;
479 Print(
string.Format(
"ScenarioFramework - LayerTask: Task Subject not found doesn't exist for %1. Task won't be spawned!",
GetOwner().
GetName()), LogLevel.ERROR);
482 s_OnTaskSetup.Invoke(
m_Task);
483 Print(
string.Format(
"ScenarioFramework: -> LayerTask: SlotTask %1 - generating task %2. Description: %3", m_SlotTask.GetOwner().GetName(), WidgetManager.Translate(
m_Task.GetTitle()),
string.Format(WidgetManager.Translate(
m_Task.GetDescription(), WidgetManager.Translate(
m_Task.GetSpawnedEntityName())))), LogLevel.NORMAL);
488 override void _WB_AfterWorldUpdate(IEntity owner,
float timeSlice)
494 override bool _WB_OnKeyChanged(IEntity owner, BaseContainer src,
string key, BaseContainerList ownerContainers, IEntity parent)
496 if (key ==
"m_bShowDebugShapesInWorkbench")