6 enum SCR_ScenarioFrameworkEActivationType
40 [
Attribute(UIWidgets.Auto,
desc:
"Actions that will be activated after tasks are initialized",
category:
"Tasks")];
43 [
Attribute(
desc:
"List of Core Areas that are essential for the Scenario to spawn alongside Debug Areas",
category:
"Debug")];
46 [
Attribute(
desc:
"List of Areas that will be spawned (Optionally with desired Layer Task) as opposed to leaving it to random generation",
category:
"Debug")];
47 protected ref array<ref SCR_ScenarioFrameworkDebugArea>
m_aDebugAreas;
49 [
Attribute(
desc:
"Should the dynamic Spawn/Despawn based on distance from player characters be enabled for the whole GameMode?",
category:
"Dynamic Spawn/Despawn")];
52 [
Attribute(defvalue:
"4", UIWidgets.Slider,
params:
"0 600 1",
desc:
"How frequently is dynamic spawn/despawn being checked in seconds",
category:
"Dynamic Spawn/Despawn")]
65 ref array<SCR_ScenarioFrameworkArea>
m_aAreas = {};
75 protected ref array<ref Tuple3<SCR_ScenarioFrameworkArea, vector, int>>
m_aSpawnedAreas = {};
76 protected ref array<ref Tuple3<SCR_ScenarioFrameworkArea, vector, int>>
m_aDespawnedAreas = {};
83 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
89 IEntity entity =
GetGame().GetWorld().FindEntityByID(pEntID);
93 SoundComponent pSndComp = SoundComponent.Cast(entity.FindComponent(SoundComponent));
97 pSndComp.SoundEvent(sSndName);
134 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
141 PlayerController playerController =
GetGame().GetPlayerController();
142 if (!playerController)
145 if (playerID != playerController.GetPlayerId())
151 entity =
GetGame().GetWorld().FindEntityByID(entityID);
157 entity = playerManager.GetPlayerControlledEntity(playerID);
162 SignalsManagerComponent signalComp = SignalsManagerComponent.Cast(entity.FindComponent(SignalsManagerComponent));
168 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"PlanName"), 0);
178 Math.Randomize(seed);
179 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"PlanName"), Math.RandomIntInclusive(0, 2));
187 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"Objective1"), 1);
192 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"Objective2"), 2);
197 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"Objective3"), 3);
202 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"Objective4"), 4);
207 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"Objective5"), 5);
212 signalComp.SetSignalValue(signalComp.AddOrFindSignal(
"Objective6"), 6);
214 SoundComponent soundComp = SoundComponent.Cast(entity.FindComponent(SoundComponent));
218 soundComp.SoundEvent(eventName);
225 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
228 IEntity
object = IEntity.Cast(Replication.FindItem(objectID));
233 if (!soundManagerEntity)
236 SCR_AudioSourceConfiguration audioConfig =
new SCR_AudioSourceConfiguration();
237 audioConfig.m_sSoundProject = soundFile;
238 audioConfig.m_sSoundEventName = soundEventName;
240 soundManagerEntity.CreateAndPlayAudioSource(
object, audioConfig);
250 RplId objectID = Replication.FindId(
object);
251 if (!objectID.IsValid())
291 Faction faction = task.GetTargetFaction();
293 PopUpMessage(task.GetTitle(),
"#AR-CampaignTasks_NewObjectivesAvailable-UC", faction.GetFactionKey());
295 PopUpMessage(task.GetTitle(),
"#AR-CampaignTasks_NewObjectivesAvailable-UC");
306 Faction faction = task.GetTargetFaction();
317 PopUpMessage(task.GetTitle(),
"#AR-Workshop_ButtonUpdate", faction.GetFactionKey());
319 PopUpMessage(task.GetTitle(),
"#AR-Workshop_ButtonUpdate");
322 SCR_ScenarioFrameworkSlotTask subject = taskLayer.GetSlotTask();
389 float fMinDistance =
float.MAX;
391 for (
int i = 0, count =
m_aAreas.Count(); i < count; i++)
393 if (!
m_aAreas[i].GetIsTaskSuitableForArea(eTaskType))
397 if (fDistance < fMinDistance)
399 fMinDistance = fDistance;
412 RplComponent comp = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
416 return !comp.IsProxy();
443 if (area.GetDynamicDespawnEnabled())
452 SCR_ScenarioFrameworkLayerTask layerTask;
455 area = debugArea.GetForcedArea();
462 if (!area.GetDynamicDespawnEnabled())
465 layerTask = debugArea.GetForcedLayerTask();
476 entity =
GetGame().GetWorld().FindEntityByName(coreArea);
481 if (area && !area.GetDynamicDespawnEnabled())
486 SCR_ScenarioFrameworkLayerTask.s_OnTaskSetup.Insert(
OnTaskCreated);
522 SCR_ESFTaskType taskType = layerTask.GetTaskType();
539 layerTask.SetParentLayer(layerTask.GetParentLayer());
540 layerTask.Init(area, SCR_ScenarioFrameworkEActivationType.ON_TASKS_INIT);
541 area.SetLayerTask(layerTask);
542 area.SetAreaSelected(
true);
559 Print(
string.Format(
"ScenarioFramework: Creating area %1 with Layer Task %2", area.GetOwner().GetName(), layerTask.GetOwner().GetName()), LogLevel.NORMAL);
569 Print(
"ScenarioFramework: Available tasks are empty, no new tasks will be generated.", LogLevel.NORMAL);
575 Print(
"ScenarioFramework: There are no Areas to generate tasks from", LogLevel.NORMAL);
579 Print(
"ScenarioFramework: ---------------------- Generating tasks -------------------", LogLevel.NORMAL);
589 Print(
"ScenarioFramework: ---------------------- Generation of tasks completed -------------------", LogLevel.NORMAL);
597 array<SCR_ScenarioFrameworkLayerTask> layerTasksToRandomize = {};
598 array<SCR_ScenarioFrameworkLayerTask> layerTasks = {};
606 area.GetAllLayerTasks(layerTasks);
607 layerTasksToRandomize.InsertAll(layerTasks);
616 forcedArea = debugArea.GetForcedArea();
621 if (debugArea.GetForcedLayerTask())
624 forcedArea.GetAllLayerTasks(layerTasks);
625 layerTasksToRandomize.InsertAll(layerTasks);
636 for (
int i = layerTasksToRandomize.Count() - 1; i >= 0; i--)
639 layerTasksToRandomize.Remove(i);
643 for (
int i = layerTasksToRandomize.Count() - 1; i >= 0; i--)
645 if (layerTasksToRandomize[i].
GetActivationType() != SCR_ScenarioFrameworkEActivationType.ON_TASKS_INIT)
646 layerTasksToRandomize.Remove(i);
681 Print(
"ScenarioFramework: ---------------------- Generation of tasks completed -------------------", LogLevel.NORMAL);
713 array<string> stringValues = {};
714 SCR_Enum.GetEnumNames(targetEnum, stringValues);
716 int index = stringValues.Find(targetString);
732 layerTask.DynamicDespawn(
null);
737 afterTasksInitActions.Init(
m_aAreas.GetRandomElement().GetOwner());
750 IEntity layerEntity =
GetGame().GetWorld().FindEntityByName(targetLayer);
754 SCR_ScenarioFrameworkLayerTask taskComponent = SCR_ScenarioFrameworkLayerTask.Cast(layerEntity.FindComponent(SCR_ScenarioFrameworkLayerTask));
760 IEntity areaEntity =
GetGame().GetWorld().FindEntityByName(targetArea);
762 areaEntity = layerEntity.GetParent();
771 area.SetAreaSelected(
true);
772 taskComponent.SetActivationType(SCR_ScenarioFrameworkEActivationType.ON_TASKS_INIT);
774 area.Create(taskComponent);
775 Print(
string.Format(
"ScenarioFramework: Creating area %1", area.GetOwner().GetName()), LogLevel.NORMAL);
776 Print(
"ScenarioFramework: ---------------------------------------------------------------", LogLevel.NORMAL);
790 array<SCR_ScenarioFrameworkArea> aAreasCopy = {};
792 for (
int i = 0, count =
m_aAreas.Count(); i < count; i++)
795 selectedArea = aAreasCopy.GetRandomElement();
796 if (!selectedArea.GetIsAreaSelected() && selectedArea.GetIsTaskSuitableForArea(eTaskType))
798 selectedArea.SetAreaSelected(
true);
803 aAreasCopy.RemoveItem(selectedArea);
819 IEntity entity = child.GetParent();
826 entity = entity.GetParent();
838 int despawnRange = area.GetDynamicDespawnRange();
843 m_aDespawnedAreas.Insert(
new Tuple3<SCR_ScenarioFrameworkArea, vector, int>(area, area.GetOwner().GetOrigin(), (despawnRange * despawnRange)));
844 area.DynamicDespawn(
null);
848 m_aSpawnedAreas.Insert(
new Tuple3<SCR_ScenarioFrameworkArea, vector, int>(area, area.GetOwner().GetOrigin(), (despawnRange * despawnRange)));
858 int despawnRange = area.GetDynamicDespawnRange();
862 area.DynamicDespawn(
null);
867 if (area == areaInfo.param1)
873 Tuple3<SCR_ScenarioFrameworkArea, vector, int> areaInfo =
m_aSpawnedAreas[i];
874 if (area == areaInfo.param1)
890 if (!area.GetDynamicDespawnEnabled())
893 int despawnRange = area.GetDynamicDespawnRange();
894 m_aDespawnedAreas.Insert(
new Tuple3<SCR_ScenarioFrameworkArea, vector, int>(area, area.GetOwner().GetOrigin(), (despawnRange * despawnRange)));
896 area.DynamicDespawn(
null);
907 array<int> playerIds = {};
910 SCR_DamageManagerComponent damageManager;
911 playerManager.GetPlayers(playerIds);
913 foreach (
int playerId : playerIds)
915 player = playerManager.GetPlayerControlledEntity(playerId);
919 damageManager = SCR_DamageManagerComponent.GetDamageManager(player);
920 if (damageManager && damageManager.GetState() !=
EDamageState.DESTROYED)
937 if (vector.DistanceSqXZ(observerPos, areaInfo.param2) < areaInfo.param3)
939 areaInfo.param1.DynamicReinit();
954 Tuple3<SCR_ScenarioFrameworkArea, vector, int> areaInfo =
m_aSpawnedAreas[i];
955 bool observerInRange;
958 if (vector.DistanceSqXZ(observerPos, areaInfo.param2) < areaInfo.param3)
960 observerInRange =
true;
965 if (!observerInRange)
967 areaInfo.param1.DynamicDespawn(
null);
978 GetGame().GetCallqueue().CallLater(
Init,1000,
false);
994 void ShowHint(
string sTitle,
string sSubtitle,
int timeOut, FactionKey factionKey =
"",
int playerID = -1)
996 Rpc(
RpcDo_ShowHint, sTitle, sSubtitle, timeOut, factionKey, playerID);
1007 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
1008 void RpcDo_ShowHint(
string sTitle,
string sSubtitle,
int timeOut, FactionKey factionKey,
int playerID)
1018 PlayerController playerController =
GetGame().GetPlayerController();
1019 if (!playerController)
1022 if (playerID != playerController.GetPlayerId())
1026 SCR_HintUIInfo info =
SCR_HintUIInfo.CreateInfo(WidgetManager.Translate(sTitle), WidgetManager.Translate(sSubtitle), timeOut, 0, 0,
true);
1028 SCR_HintManagerComponent.ShowHint(info);
1037 void PopUpMessage(
string sTitle,
string sSubtitle, FactionKey factionKey =
"",
int playerID = -1)
1049 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
1060 PlayerController playerController =
GetGame().GetPlayerController();
1061 if (!playerController)
1064 if (playerID != playerController.GetPlayerId())