24 [
Attribute(
desc:
"Faction key that corresponds with the SCR_Faction set in FactionManager",
category:
"Asset")]
27 [
Attribute(defvalue:
"100",
desc:
"If the RANDOM_MULTIPLE option is selected, what's the percentage? ", UIWidgets.Graph,
"0 100 1",
category:
"Children")]
30 [
Attribute(
desc:
"When enabled, it will repeatedly spawn childern according to other parameters set",
category:
"Children")]
33 [
Attribute(defvalue:
"-1",
desc:
"If Repeated Spawn is enabled, how many times can children be spawned? If set to -1, it is unlimited",
category:
"Children")]
36 [
Attribute(defvalue:
"-1", UIWidgets.Slider,
desc:
"If Repeated Spawn is enabled, how frequently it will spawn next wave of children? Value -1 means disabled, thus children won't be spawned by the elapsed time.",
params:
"-1 86400 1",
category:
"Children")]
42 [
Attribute(
"0", uiwidget: UIWidgets.ComboBox,
"",
"", ParamEnumArray.FromEnum(SCR_ScenarioFrameworkEActivationType),
category:
"Activation")]
45 [
Attribute(
desc:
"Conditions that will be checked upon init and based on the result it will let this to finish init or not",
category:
"Activation")]
48 [
Attribute(
desc:
"Actions that will be activated when this Area gets activated",
category:
"OnActivation")]
55 protected ref array<ref SCR_ScenarioFrameworkPlugin>
m_aPlugins;
57 protected ref array<SCR_ScenarioFrameworkLayerBase>
m_aChildren = {};
59 protected ref array<SCR_ScenarioFrameworkLogic>
m_aLogic = {};
81 static const int SPAWN_DELAY = 200;
118 foreach (
string child : randomlySpawnedChildren)
120 entity =
GetGame().GetWorld().FindEntityByName(child);
142 if (factionName.IsEmpty())
143 return GetGame().GetPlayerManager().GetPlayerCount();
145 FactionManager factionManager =
GetGame().GetFactionManager();
150 array<int> aPlayerIDs = {};
152 GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
153 foreach (
int iPlayerID : aPlayerIDs)
156 if (!playerController)
159 if (playerController.GetLocalControlledEntityFaction() == factionManager.GetFactionByKey(factionName))
174 return header.m_iPlayerCount;
184 IEntity entity =
GetOwner().GetParent();
191 entity = entity.GetParent();
201 SCR_ScenarioFrameworkLayerTask layer;
202 IEntity entity =
GetOwner().GetParent();
205 layer = SCR_ScenarioFrameworkLayerTask.Cast(entity.FindComponent(SCR_ScenarioFrameworkLayerTask));
209 entity = entity.GetParent();
217 SCR_ScenarioFrameworkSlotTask
GetSlotTask(array<SCR_ScenarioFrameworkLayerBase> aLayers)
219 SCR_ScenarioFrameworkSlotTask slotTask;
222 IEntity child = layer.GetOwner();
223 slotTask = SCR_ScenarioFrameworkSlotTask.Cast(child.FindComponent(SCR_ScenarioFrameworkSlotTask));
230 slotTask = SCR_ScenarioFrameworkSlotTask.Cast(child.FindComponent(SCR_ScenarioFrameworkSlotTask));
234 child = child.GetSibling();
267 IEntity entity =
GetOwner().GetParent();
279 return m_SpawnChildren;
359 void GetChildren(out array<SCR_ScenarioFrameworkLayerBase> children)
362 array<SCR_ScenarioFrameworkLayerBase> childrenReversed = {};
364 IEntity child =
GetOwner().GetChildren();
369 childrenReversed.Insert(slotComponent);
371 child = child.GetSibling();
374 for (
int i = childrenReversed.Count() - 1; i >= 0; i--)
376 if (!children.Contains(childrenReversed[i]))
377 children.Insert(childrenReversed[i]);
383 void GetLogics(out array<SCR_ScenarioFrameworkLogic> logics)
385 IEntity child =
GetOwner().GetChildren();
386 SCR_ScenarioFrameworkLogic logic;
389 logic = SCR_ScenarioFrameworkLogic.Cast(child);
390 if (logic && !logics.Contains(logic))
391 logics.Insert(logic);
393 child = child.GetSibling();
477 int activationType = child.GetActivationType();
478 if (activationType == SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION || activationType == SCR_ScenarioFrameworkEActivationType.ON_AREA_TRIGGER_ACTIVATION
479 || activationType == SCR_ScenarioFrameworkEActivationType.ON_TASKS_INIT)
482 if (child.GetIsInitiated())
500 int activationType = child.GetActivationType();
501 if (activationType == SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION || activationType == SCR_ScenarioFrameworkEActivationType.ON_AREA_TRIGGER_ACTIVATION)
504 if (child.GetIsInitiated())
531 GetGame().GetCallqueue().CallLater(
InitChild, SPAWN_DELAY * slotCount,
false, child);
567 if (previouslyRandomized)
582 if (previouslyRandomized)
586 array<SCR_ScenarioFrameworkLayerBase> aChildren = {};
589 if (aChildren.IsEmpty())
599 if (aChildren.IsEmpty())
603 child = aChildren.GetRandomElement();
606 aChildren.RemoveItem(child);
619 child.SetParentLayer(
this);
620 child.Init(
GetParentArea(), SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT);
634 foreach (SCR_ScenarioFrameworkLogic logic :
m_aLogic)
654 activationAction.m_iNumberOfActivations = 0;
661 child.RestoreToDefault(includeChildren,
false);
674 if (reinitAfterRestoration)
696 child.DynamicDespawn(
this);
730 SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(
m_ParentLayer);
746 if (!activationCondition.Init(
GetOwner()))
757 SCR_GameModeSFManager gameModeComp = SCR_GameModeSFManager.Cast(
GetGame().
GetGameMode().FindComponent(SCR_GameModeSFManager));
759 area = gameModeComp.GetParentArea(
GetOwner());
763 bool previouslyRandomized;
765 previouslyRandomized =
true;
804 override void EOnFrame(IEntity owner,
float timeSlice)
806 super.EOnFrame(owner, timeSlice);
814 super.OnPostInit(owner);
818 SetEventMask(owner, EntityEvent.INIT | EntityEvent.FRAME);
831 Shape dbgShape =
null;
835 dbgShape = Shape.CreateSphere(
837 ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE | ShapeFlags.NOZWRITE | ShapeFlags.ONCE | ShapeFlags.NOOUTLINE,
845 override void _WB_OnCreate(IEntity owner, IEntitySource src)
847 RenameOwnerEntity(owner);
849 IEntity child =
GetOwner().GetChildren();
852 RenameOwnerEntity(child);
853 child = child.GetSibling();
860 void RenameOwnerEntity(IEntity owner)
864 WorldEditorAPI api = genericEntity._WB_GetEditorAPI();
865 if (!api.UndoOrRedoIsRestoring())
866 api.RenameEntity(api.EntityToSource(owner), api.GenerateDefaultEntityName(api.EntityToSource(owner)));
881 plugin.OnWBKeyChanged(
this);
917 [
Attribute(defvalue:
"5.0", UIWidgets.Slider,
params:
"1.0 1000.0 0.5",
desc:
"Radius of the trigger if selected",
category:
"Trigger")]
918 protected float m_fAreaRadius;
920 [
Attribute(
"0", UIWidgets.ComboBox,
"By whom the trigger is activated",
"", ParamEnumArray.FromEnum(TA_EActivationPresence),
category:
"Trigger Activation")]
926 [
Attribute(
desc:
"Which Prefabs and if their children will be detected by the trigger. Is combined with other filters using OR.",
category:
"Trigger")]
927 protected ref array<ref SCR_ScenarioFrameworkPrefabFilter>
m_aPrefabFilter;
930 protected FactionKey m_sActivatedByThisFaction;
932 [
Attribute(
desc:
"Here you can input custom trigger conditions that you can create by extending the SCR_CustomTriggerConditions", uiwidget: UIWidgets.Object)]
935 [
Attribute(defvalue:
"1", UIWidgets.CheckBox,
desc:
"If you set some vehicle to be detected by the trigger, it will also search the inventory for vehicle prefabs/classes that are set",
category:
"Trigger")]
938 [
Attribute(defvalue:
"1", UIWidgets.CheckBox,
desc:
"Activate the trigger once or everytime the activation condition is true?",
category:
"Trigger")]
941 [
Attribute(defvalue:
"1", UIWidgets.Slider,
desc:
"How frequently is the trigger updated and performing calculations. Lower numbers will decrease performance.",
params:
"0 86400 1",
category:
"Trigger")]
942 protected float m_fUpdateRate;
944 [
Attribute(defvalue:
"0", UIWidgets.Slider,
desc:
"Minimum players needed to activate this trigger when PLAYER Activation presence is selected",
params:
"0 1 0.01", precision: 2,
category:
"Trigger")]
947 [
Attribute(defvalue:
"0", UIWidgets.Slider,
desc:
"For how long the trigger conditions must be true in order for the trigger to activate. If conditions become false, timer resets",
params:
"0 86400 1",
category:
"Trigger")]
950 [
Attribute(defvalue:
"0", UIWidgets.CheckBox,
desc:
"Whether or not the notification is allowed to be displayed",
category:
"Trigger")]
953 [
Attribute(
desc:
"Notification title text that will be displayed when the PLAYER Activation presence is selected",
category:
"Trigger")]
956 [
Attribute(defvalue:
"0", UIWidgets.CheckBox,
desc:
"Whether or not the audio sound is played and affected by the trigger",
category:
"Trigger")]
970 IEntity entity =
object.GetSpawnedEntity();
979 if (!BaseGameTriggerEntity.Cast(entity))
981 Print(
"ScenarioFramework: SlotTrigger - The selected prefab is not trigger!", LogLevel.ERROR);
989 trigger.SetSphereRadius(m_fAreaRadius);
991 trigger.SetOwnerFaction(m_sActivatedByThisFaction);
997 trigger.SetUpdateRate(m_fUpdateRate);
1011 factionTrigger.SetSphereRadius(m_fAreaRadius);
1012 FactionManager factionManager =
GetGame().GetFactionManager();
1014 factionTrigger.SetOwnerFaction(factionManager.GetFactionByKey(m_sActivatedByThisFaction));
1021 super.OnWBKeyChanged(
object);
1022 object.SetDebugShapeSize(m_fAreaRadius);
1031 protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnDestroy;
1033 protected IEntity m_Asset;
1043 IEntity entity =
object.GetSpawnedEntity();
1048 SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.Cast(SCR_DamageManagerComponent.GetDamageManager(m_Asset));
1049 if (objectDmgManager)
1050 objectDmgManager.GetOnDamageStateChanged().Insert(
OnObjectDamage);
1052 PrintFormat(
"ScenarioFramework: Registering OnDestroy of entity %1 failed! The entity doesn't have damage manager", entity, LogLevel.ERROR);
1054 if (Vehicle.Cast(m_Asset))
1056 VehicleControllerComponent_SA vehicleController = VehicleControllerComponent_SA.Cast(m_Asset.FindComponent(VehicleControllerComponent_SA));
1057 if (vehicleController)
1058 vehicleController.GetOnEngineStop().Insert(CheckEngineDrowned);
1062 GetGame().GetCallqueue().CallLater(CheckEngineDrowned, 5000,
true);
1073 SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.Cast(SCR_DamageManagerComponent.GetDamageManager(m_Asset));
1074 if (objectDmgManager)
1076 objectDmgManager.GetOnDamageStateChanged().Remove(
OnObjectDamage);
1077 GetGame().GetCallqueue().Remove(CheckEngineDrowned);
1079 VehicleControllerComponent_SA vehicleController = VehicleControllerComponent_SA.Cast(m_Asset.FindComponent(VehicleControllerComponent_SA));
1080 if (vehicleController)
1081 vehicleController.GetOnEngineStop().Remove(CheckEngineDrowned);
1084 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnDestroy)
1086 action.OnActivate(m_Asset);
1092 void CheckEngineDrowned()
1097 VehicleControllerComponent_SA vehicleController = VehicleControllerComponent_SA.Cast(m_Asset.FindComponent(VehicleControllerComponent_SA));
1098 if (vehicleController && vehicleController.GetEngineDrowned())
1100 vehicleController.GetOnEngineStop().Remove(CheckEngineDrowned);
1101 GetGame().GetCallqueue().Remove(CheckEngineDrowned);
1103 SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.Cast(SCR_DamageManagerComponent.GetDamageManager(m_Asset));
1104 if (objectDmgManager)
1105 objectDmgManager.GetOnDamageStateChanged().Remove(
OnObjectDamage);
1107 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnDestroy)
1109 action.OnActivate(m_Asset);
1119 [
Attribute(UIWidgets.Auto,
desc:
"What to do once object inventory has changed by item addition")]
1120 protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnItemAdded;
1122 [
Attribute(UIWidgets.Auto,
desc:
"What to do once object inventory has changed by item removal")]
1123 protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnItemRemoved;
1125 protected IEntity m_Asset;
1134 IEntity entity =
object.GetSpawnedEntity();
1141 SCR_InventoryStorageManagerComponent storageManager1 = SCR_InventoryStorageManagerComponent.Cast(m_Asset.FindComponent(SCR_InventoryStorageManagerComponent));
1142 if (storageManager1)
1144 storageManager1.m_OnItemAddedInvoker.Insert(
OnItemAdded);
1145 storageManager1.m_OnItemRemovedInvoker.Insert(
OnItemRemoved);
1149 SCR_VehicleInventoryStorageManagerComponent storageManager2 = SCR_VehicleInventoryStorageManagerComponent.Cast(m_Asset.FindComponent(SCR_VehicleInventoryStorageManagerComponent));
1150 if (storageManager2)
1152 storageManager2.m_OnItemAddedInvoker.Insert(
OnItemAdded);
1153 storageManager2.m_OnItemRemovedInvoker.Insert(
OnItemRemoved);
1157 SCR_ArsenalInventoryStorageManagerComponent storageManager3 = SCR_ArsenalInventoryStorageManagerComponent.Cast(m_Asset.FindComponent(SCR_ArsenalInventoryStorageManagerComponent));
1158 if (storageManager3)
1160 storageManager3.m_OnItemAddedInvoker.Insert(
OnItemAdded);
1161 storageManager3.m_OnItemRemovedInvoker.Insert(
OnItemRemoved);
1167 protected void OnItemAdded(IEntity item, BaseInventoryStorageComponent storageOwner)
1169 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemAdded)
1171 action.OnActivate(m_Asset);
1176 protected void OnItemRemoved(IEntity item, BaseInventoryStorageComponent storageOwner)
1178 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemRemoved)
1180 action.OnActivate(m_Asset);
1188 [
Attribute(
"0",
desc:
"Find empty position for spawning within given radius. When none is found, entity position will be used.")]
1189 protected float m_fSpawnRadius;
1191 [
Attribute(
"US", UIWidgets.EditBox,
"Determines which faction can spawn on this spawn point."),
RplProp(onRplName:
"OnSetFactionKey")]
1192 protected string m_sFaction;
1195 protected bool m_bShowInDeployMapOnly;
1197 [
Attribute(
"0",
desc:
"Use custom timer when deploying on this spawn point. Takes the remaining respawn time from SCR_TimedSpawnPointComponent")]
1198 protected bool m_bTimedSpawnPoint;
1203 [
Attribute(
"0",
desc:
"Allow usage of Spawn Positions in range")]
1204 protected bool m_bUseNearbySpawnPositions;
1206 [
Attribute(
"100",
desc:
"Spawn position detection radius, in metres")]
1207 protected float m_fSpawnPositionUsageRange;
1209 [
Attribute(
"0",
desc:
"Additional respawn time (in seconds) when spawning on this spawn point"),
RplProp()]
1210 protected float m_fRespawnTime;
1212 [
Attribute(UIWidgets.Auto,
desc:
"What to do once Spawn Point is used",)]
1213 protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnSpawnPointUsed;
1215 protected IEntity m_Asset;
1224 m_Asset =
object.GetSpawnedEntity();
1232 spawnPoint.SetSpawnRadius(m_fSpawnRadius);
1233 spawnPoint.SetFactionKey(m_sFaction);
1234 spawnPoint.SetVisibleInDeployMapOnly(m_bShowInDeployMapOnly);
1235 spawnPoint.SetIsTimed(m_bTimedSpawnPoint);
1239 spawnPoint.LinkInfo(
m_Info);
1240 spawnPoint.SetSpawnPointName(
m_Info.GetName());
1243 spawnPoint.SetUseNearbySpawnPositions(m_bUseNearbySpawnPositions);
1244 spawnPoint.SetSpawnPositionRange(m_fSpawnPositionUsageRange);
1245 spawnPoint.SetRespawnTime(m_fRespawnTime);
1253 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnSpawnPointUsed)
1255 action.OnActivate(entity);