5 protected int m_iHours = -1;
6 protected int m_iMinutes = -1;
7 protected int m_iSeconds = -1;
8 protected bool m_bMatchOver;
9 protected string m_sWeatherState;
11 protected ref array<ref SCR_ScenarioFrameworkAreaStruct> m_aAreasStructs = {};
14 override bool Serialize()
16 SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(
GetGame().
GetGameMode().FindComponent(SCR_GameModeSFManager));
22 m_aAreasStructs.Clear();
25 TimeAndWeatherManagerEntity timeManager = world.GetTimeAndWeatherManager();
32 if (transitionManager)
33 m_sWeatherState = transitionManager.GetCurrentState().GetStateName();
37 StoreAreaStates(manager, m_aAreasStructs);
38 ClearEmptyAreaStructs(m_aAreasStructs);
44 override bool Deserialize()
46 if (m_aAreasStructs.IsEmpty())
49 SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(
GetGame().
GetGameMode().FindComponent(SCR_GameModeSFManager));
57 SCR_TimeAndWeatherHandlerComponent timeHandler = SCR_TimeAndWeatherHandlerComponent.GetInstance();
62 GetGame().GetCallqueue().Remove(timeHandler.SetupDaytimeAndWeather);
67 LoadAreaStates(manager, m_aAreasStructs);
75 void StoreAreaStates(notnull SCR_GameModeSFManager manager, out notnull array<ref SCR_ScenarioFrameworkAreaStruct> outEntries)
77 if (!manager.m_aAreas)
81 for (
int i = manager.m_aAreas.Count() - 1; i >= 0; i--)
84 struct.StoreState(manager.m_aAreas[i],
struct);
85 outEntries.Insert(
struct);
92 void LoadAreaStates(notnull SCR_GameModeSFManager manager, notnull array<ref SCR_ScenarioFrameworkAreaStruct> loadedAreaStruct)
98 entity =
GetGame().GetWorld().FindEntityByName(areaStruct.GetName());
106 LoadAreaStructs(manager, area, areaStruct);
107 LoadNestedAreaStructs(areaStruct);
114 if (areaStruct.GetAreaSelected())
116 manager.m_aAreasTasksToSpawn.Insert(areaStruct.GetName());
117 manager.m_aLayersTaskToSpawn.Insert(areaStruct.GetLayerTaskname());
120 if (areaStruct.GetDeliveryPointNameForItem())
121 area.StoreDeliveryPoint(areaStruct.GetDeliveryPointNameForItem());
123 if (areaStruct.GetRandomlySpawnedChildren())
124 area.SetRandomlySpawnedChildren(areaStruct.GetRandomlySpawnedChildren());
126 LoadRepeatedSpawnAreaStructs(area, areaStruct);
133 if (areaStruct.GetEnableRepeatedSpawn())
135 area.SetEnableRepeatedSpawn(areaStruct.GetEnableRepeatedSpawn());
136 if (areaStruct.GetRepeatedSpawnNumber())
137 area.SetRepeatedSpawnNumber(areaStruct.GetRepeatedSpawnNumber());
144 if (areaStruct.GetLayerStructs())
145 LoadLayer(areaStruct.GetLayerStructs());
147 if (areaStruct.GetLogicStructs())
148 LoadLogic(areaStruct.GetLogicStructs());
152 protected void LoadLayer(notnull array<ref SCR_ScenarioFrameworkLayerStruct> loadedLayerStruct)
156 BaseWorld world =
GetGame().GetWorld();
159 entity = world.FindEntityByName(layerStruct.GetName());
167 LoadLayerStructs(layer, layerStruct);
168 LoadNestedLayerStructs(layerStruct);
175 if (layerStruct.GetActivationType() != -1)
176 layer.SetActivationType(layerStruct.GetActivationType());
178 if (layerStruct.GetIsTerminated())
180 layer.SetIsTerminated(layerStruct.GetIsTerminated());
184 LoadRepeatedSpawnLayerStructs(layer, layerStruct);
185 LoadLayerStructSlots(layer, layerStruct);
188 SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(layer);
190 layerTask.SetLayerTaskState(layerStruct.GetLayerTaskState());
192 if (layerStruct.GetRandomlySpawnedChildren())
193 layer.SetRandomlySpawnedChildren(layerStruct.GetRandomlySpawnedChildren());
195 LoadNestedLayerStructs(layerStruct);
201 if (!layerStruct.GetEnableRepeatedSpawn())
204 layer.SetEnableRepeatedSpawn(
true);
205 layer.SetRepeatedSpawnNumber(layerStruct.GetRepeatedSpawnNumber());
219 if (layerStruct.GetAIPrefabsForRemoval())
220 slotAI.SetAIPrefabsForRemoval(layerStruct.GetAIPrefabsForRemoval());
223 if (layerStruct.GetRandomlySpawnedObject())
224 slot.SetRandomlySpawnedObject(layerStruct.GetRandomlySpawnedObject());
231 if (layerStruct.GetLayerStructs())
232 LoadLayer(layerStruct.GetLayerStructs());
234 if (layerStruct.GetLogicStructs())
235 LoadLogic(layerStruct.GetLogicStructs());
239 protected void LoadLogic(notnull array<ref SCR_ScenarioFrameworkLogicStruct> entries)
242 BaseWorld world =
GetGame().GetWorld();
243 SCR_ScenarioFrameworkLogic logic;
244 SCR_ScenarioFrameworkLogicCounter logicCounter;
247 entity = world.FindEntityByName(logicInfo.GetName());
251 logic = SCR_ScenarioFrameworkLogic.Cast(entity);
255 if (logicInfo.GetIsTerminated())
257 logic.SetIsTerminated(logicInfo.GetIsTerminated());
261 logicCounter = SCR_ScenarioFrameworkLogicCounter.Cast(entity);
265 logicCounter.SetCounterValue(logicInfo.GetCounterValue());
270 protected void ClearEmptyAreaStructs(notnull array<ref SCR_ScenarioFrameworkAreaStruct> areaStructsToClear)
272 array<ref SCR_ScenarioFrameworkAreaStruct> areasStructsCopy = {};
275 areasStructsCopy.Insert(areaStructToCopy);
280 if (areaStruct.GetStructVarCount() < 1)
282 areaStructsToClear.RemoveItem(areaStruct);
293 RegV(
"m_bMatchOver");
294 RegV(
"m_sWeatherState");
295 RegV(
"m_eGameOverType");
296 RegV(
"m_aAreasStructs");
303 protected bool m_bAreaSelected;
304 protected string m_sItemDeliveryPointName;
305 protected string m_sLayerTaskName;
313 if (area.GetName().IsEmpty())
319 areaStruct.SetName(area.GetName());
321 StoreSelectedArea(area, areaStruct);
322 StoreDeliveryPoint(area, areaStruct);
324 StoreActivationTypeStatus(area, areaStruct);
325 StoreTerminationStatus(area, areaStruct);
326 StoreRepeatedSpawn(area, areaStruct);
327 StoreLayerTask(area, areaStruct);
329 StoreChildren(area, areaStruct);
330 StoreLogic(area, areaStruct);
332 CleanEmptyStoredLayers(areaStruct);
333 CleanEmptyStoredLogic(areaStruct);
334 CleanAreaStructs(areaStruct);
341 if (area.m_bAreaSelected)
343 areaStruct.IncreaseStructVarCount();
344 areaStruct.SetAreaSelected(1);
348 areaStruct.UnregV(
"m_bAreaSelected");
356 if (!area.m_sItemDeliveryPointName.IsEmpty())
358 areaStruct.IncreaseStructVarCount();
359 areaStruct.SetDeliveryPointNameForItem(area.GetDeliveryPointName());
363 areaStruct.UnregV(
"m_sItemDeliveryPointName");
371 if (area.GetActivationType() != area.GetActivationType())
373 areaStruct.SetActivationType(area.GetActivationType());
374 areaStruct.IncreaseStructVarCount();
378 areaStruct.UnregV(
"m_eActivationType");
386 if (area.GetIsTerminated())
388 areaStruct.IncreaseStructVarCount();
389 areaStruct.SetIsTerminated(
true);
393 areaStruct.UnregV(
"m_bIsTerminated");
401 if (area.GetEnableRepeatedSpawn())
403 areaStruct.IncreaseStructVarCount();
404 areaStruct.SetEnableRepeatedSpawn(area.GetEnableRepeatedSpawn());
405 if (area.GetRepeatedSpawnNumber() != -1)
407 areaStruct.IncreaseStructVarCount();
408 areaStruct.SetRepeatedSpawnNumber(area.GetRepeatedSpawnNumber());
412 areaStruct.UnregV(
"m_iRepeatedSpawnNumber");
417 areaStruct.UnregV(
"m_bEnableRepeatedSpawn");
418 areaStruct.UnregV(
"m_iRepeatedSpawnNumber");
426 if (area.m_LayerTask)
428 areaStruct.SetLayerTaskName(area.GetLayerTaskName());
429 areaStruct.IncreaseStructVarCount();
433 areaStruct.UnregV(
"m_sLayerTaskName");
441 array<SCR_ScenarioFrameworkLayerBase> children = {};
442 area.GetChildren(children);
444 if (children.IsEmpty())
446 areaStruct.UnregV(
"m_aLayersStructs");
452 array<SCR_ScenarioFrameworkLayerBase> m_aRandomlySpawnedChildrenLayerBases = area.GetRandomlySpawnedChildren();
455 areaStruct.InsertRandomlySpawnedChildren(child.GetName());
457 if (!m_aRandomlySpawnedChildrenLayerBases.IsEmpty())
458 areaStruct.IncreaseStructVarCount();
462 areaStruct.UnregV(
"m_aRandomlySpawnedChildren");
467 areaStruct.StoreLayerState(layer);
472 if (childLayerStruct.GetStructVarCount() >= 1)
474 areaStruct.IncreaseStructVarCount();
484 array<SCR_ScenarioFrameworkLogic> logics = {};
485 area.GetLogics(logics);
487 if (logics.IsEmpty())
489 areaStruct.UnregV(
"m_aLogicStructs");
493 foreach (SCR_ScenarioFrameworkLogic logic : logics)
495 areaStruct.StoreLogicState(logic);
499 areaStruct.IncreaseStructVarCount();
507 if (areaStruct.GetLayerStructs())
509 if (areaStruct.GetLayerStructs().IsEmpty())
510 areaStruct.UnregV(
"m_aLayersStructs");
514 areaStruct.UnregV(
"m_aLayersStructs");
522 if (areaStruct.GetLogicStructs())
524 if (areaStruct.GetLogicStructs().IsEmpty())
525 areaStruct.UnregV(
"m_aLogicStructs");
529 areaStruct.UnregV(
"m_aLogicStructs");
537 areaStruct.ClearEmptyLayerStructs(areaStruct.GetLayerStructs());
538 areaStruct.ClearEmptyLogicStructs(areaStruct.GetLogicStructs());
540 areaStruct.UnregV(
"m_aAIPrefabsForRemoval");
541 areaStruct.UnregV(
"m_sRandomlySpawnedObject");
542 areaStruct.UnregV(
"m_iLayerTaskState");
546 bool GetAreaSelected()
548 return m_bAreaSelected;
552 string GetDeliveryPointNameForItem()
554 return m_sItemDeliveryPointName;
558 string GetLayerTaskname()
560 return m_sLayerTaskName;
564 void SetAreaSelected(
bool selected)
566 m_bAreaSelected = selected;
570 void SetDeliveryPointNameForItem(
string name)
572 m_sItemDeliveryPointName = name;
576 void SetLayerTaskName(
string layerTaskName)
578 m_sLayerTaskName = layerTaskName;
584 RegV(
"m_bAreaSelected");
585 RegV(
"m_sLayerTaskName");
586 RegV(
"m_sItemDeliveryPointName");
593 protected string m_sName;
594 protected ResourceName m_sRandomlySpawnedObject;
595 protected ref array<ref SCR_ScenarioFrameworkLayerStruct> m_aLayersStructs = {};
596 protected ref array<ref SCR_ScenarioFrameworkLogicStruct> m_aLogicStructs = {};
597 protected ref array<SCR_ScenarioFrameworkLayerBase> m_aChildren = {};
598 protected ref array<SCR_ScenarioFrameworkLogic> m_aLogic = {};
599 protected ref array<ResourceName> m_aAIPrefabsForRemoval = {};
600 protected ref array<string> m_aRandomlySpawnedChildren = {};
601 protected int m_iLayerTaskState;
602 protected SCR_ScenarioFrameworkEActivationType m_eActivationType = -1;
603 protected bool m_bIsTerminated;
604 protected int m_iRepeatedSpawnNumber;
605 protected bool m_bEnableRepeatedSpawn;
606 protected int m_iStructVarCount;
614 if (layer.GetName().IsEmpty())
620 layerStruct.SetName(layer.GetName());
622 StoreActivationTypeStatus(layer, layerStruct);
623 StoreTerminationStatus(layer, layerStruct);
624 StoreRepeatedSpawn(layer, layerStruct);
625 StoreLayerTask(layer, layerStruct);
627 StoreChildren(layer, layerStruct);
628 StoreLogic(layer, layerStruct);
630 StoreSlotAndRandomObject(layer, layerStruct);
632 CleanEmptyStoredLayers(layer, layerStruct);
633 CleanEmptyStoredLogic(layer, layerStruct);
636 if (layerStruct && layerStruct.GetStructVarCount() > 0)
637 m_aLayersStructs.Insert(layerStruct);
646 if (layer.GetActivationType() != layer.GetActivationType())
648 layerStruct.SetActivationType(layer.GetActivationType());
649 layerStruct.IncreaseStructVarCount();
653 layerStruct.UnregV(
"m_eActivationType");
661 if (layer.GetIsTerminated())
663 layerStruct.SetIsTerminated(
true);
664 layerStruct.IncreaseStructVarCount();
668 layerStruct.UnregV(
"m_bIsTerminated");
676 if (layer.GetEnableRepeatedSpawn())
678 layerStruct.SetEnableRepeatedSpawn(layer.GetEnableRepeatedSpawn());
679 layerStruct.IncreaseStructVarCount();
680 if (layer.GetRepeatedSpawnNumber() != -1)
682 layerStruct.IncreaseStructVarCount();
683 layerStruct.SetRepeatedSpawnNumber(layer.GetRepeatedSpawnNumber());
687 layerStruct.UnregV(
"m_iRepeatedSpawnNumber");
692 layerStruct.UnregV(
"m_bEnableRepeatedSpawn");
693 layerStruct.UnregV(
"m_iRepeatedSpawnNumber");
701 SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(layer);
702 if (layerTask && layerTask.GetLayerTaskState() != 0)
704 layerStruct.SetLayerTaskState(layerTask.GetLayerTaskState());
705 layerStruct.IncreaseStructVarCount();
709 layerStruct.UnregV(
"m_iLayerTaskState");
720 layerStruct.UnregV(
"m_aLayersStructs");
726 array <SCR_ScenarioFrameworkLayerBase> m_aRandomlySpawnedChildrenLayerBases = layer.GetRandomlySpawnedChildren();
729 layerStruct.InsertRandomlySpawnedChildren(child.GetName());
732 if (!m_aRandomlySpawnedChildrenLayerBases.IsEmpty())
733 layerStruct.IncreaseStructVarCount();
736 layerStruct.UnregV(
"m_aRandomlySpawnedChildren");
740 layerStruct.StoreLayerState(layerToCycle);
746 if (childLayerStruct.GetStructVarCount() >= 1)
749 layerStruct.IncreaseStructVarCount();
762 layerStruct.UnregV(
"m_aLogicStructs");
766 foreach (SCR_ScenarioFrameworkLogic logic :
m_aLogic)
768 layerStruct.StoreLogicState(logic);
772 layerStruct.IncreaseStructVarCount();
784 if (slotAI && !slotAI.GetAIPrefabsForRemoval().IsEmpty() && !slotAI.GetIsTerminated())
786 layerStruct.SetAIPrefabsForRemoval(slotAI.GetAIPrefabsForRemoval());
787 layerStruct.IncreaseStructVarCount();
791 layerStruct.UnregV(
"m_aAIPrefabsForRemoval");
794 if (slot.GetRandomlySpawnedObject())
796 layerStruct.SetRandomlySpawnedObject(slot.GetRandomlySpawnedObject());
797 layerStruct.IncreaseStructVarCount();
801 layerStruct.UnregV(
"m_sRandomlySpawnedObject");
806 layerStruct.UnregV(
"m_aAIPrefabsForRemoval");
807 layerStruct.UnregV(
"m_sRandomlySpawnedObject");
815 if (layerStruct.GetLayerStructs())
817 if (layerStruct.GetLayerStructs().IsEmpty())
818 layerStruct.UnregV(
"m_aLayersStructs");
822 layerStruct.UnregV(
"m_aLayersStructs");
830 if (layerStruct.GetLogicStructs())
832 if (layerStruct.GetLogicStructs().IsEmpty())
833 layerStruct.UnregV(
"m_aLogicStructs");
837 layerStruct.UnregV(
"m_aLogicStructs");
842 void CleanEmptyStructs()
845 ClearEmptyLayerStructs(m_aLayersStructs);
848 ClearEmptyLogicStructs(m_aLogicStructs);
853 void StoreLogicState(notnull SCR_ScenarioFrameworkLogic logic)
857 SCR_ScenarioFrameworkLogicCounter logicCounter = SCR_ScenarioFrameworkLogicCounter.Cast(logic);
861 if (logicCounter.GetName())
863 logicStruct.IncreaseStructVarCount();
864 logicStruct.SetName(logicCounter.GetName());
872 StoreLogicCounterValue(logicCounter, logicStruct);
873 StoreLogicCounterTermination(logicCounter, logicStruct);
875 if (logicStruct && logicStruct.GetStructVarCount() > 1)
877 m_aLogicStructs.Insert(logicStruct);
889 if (logicCounter.GetCounterValue() == 0)
891 logicStruct.UnregV(
"m_iCounterValue");
895 logicStruct.IncreaseStructVarCount();
896 logicStruct.SetCounterValue(logicCounter.GetCounterValue());
904 if (logicCounter.GetIsTerminated())
906 logicStruct.IncreaseStructVarCount();
907 logicStruct.SetIsTerminated(
true);
911 logicStruct.UnregV(
"m_bIsTerminated");
916 void ClearEmptyLayerStructs(notnull array<ref SCR_ScenarioFrameworkLayerStruct> layerStructsToClear)
918 array<ref SCR_ScenarioFrameworkLayerStruct> layersStructsCopy = {};
921 layersStructsCopy.Insert(layerStructToCopy);
926 if (layerStruct.GetStructVarCount() < 1)
927 layerStructsToClear.RemoveItem(layerStruct);
929 ClearEmptyLayerStructs(layerStruct.GetLayerStructs());
934 void ClearEmptyLogicStructs(notnull array<ref SCR_ScenarioFrameworkLogicStruct> logicStructsToClear)
936 array<ref SCR_ScenarioFrameworkLogicStruct> logicsStructsCopy = {};
939 logicsStructsCopy.Insert(logicStructToCopy);
944 if (logicStruct.GetStructVarCount() <= 1)
945 logicStructsToClear.RemoveItem(logicStruct);
950 void IncreaseStructVarCount()
952 m_iStructVarCount += 1;
956 void DecreaseStructVarCount()
958 m_iStructVarCount -= 1;
962 array<ref SCR_ScenarioFrameworkLayerStruct> GetLayerStructs()
964 return m_aLayersStructs;
968 array<ref SCR_ScenarioFrameworkLogicStruct> GetLogicStructs()
970 return m_aLogicStructs;
974 array<string> GetRandomlySpawnedChildren()
980 int GetStructVarCount()
982 return m_iStructVarCount;
986 SCR_ScenarioFrameworkEActivationType GetActivationType()
992 bool GetIsTerminated()
998 ref array<ResourceName> GetAIPrefabsForRemoval()
1010 int GetLayerTaskState()
1012 return m_iLayerTaskState;
1016 ResourceName GetRandomlySpawnedObject()
1018 return m_sRandomlySpawnedObject;
1022 int GetRepeatedSpawnNumber()
1028 bool GetEnableRepeatedSpawn()
1036 void InsertRandomlySpawnedChildren(
string child)
1042 void SetActivationType(SCR_ScenarioFrameworkEActivationType
type)
1048 void SetIsTerminated(
bool state)
1054 void SetName(
string name)
1060 void SetLayerTaskState(
int state)
1062 m_iLayerTaskState = state;
1066 void SetAIPrefabsForRemoval(array<ResourceName> arrayForRemoval)
1072 void SetRandomlySpawnedObject(ResourceName name)
1074 m_sRandomlySpawnedObject = name;
1078 void SetRepeatedSpawnNumber(
int number)
1084 void SetEnableRepeatedSpawn(
bool value)
1093 RegV(
"m_sRandomlySpawnedObject");
1094 RegV(
"m_eActivationType");
1095 RegV(
"m_bIsTerminated");
1096 RegV(
"m_aLayersStructs");
1097 RegV(
"m_aLogicStructs");
1098 RegV(
"m_iRepeatedSpawnNumber");
1099 RegV(
"m_aAIPrefabsForRemoval");
1100 RegV(
"m_bEnableRepeatedSpawn");
1101 RegV(
"m_aRandomlySpawnedChildren");
1102 RegV(
"m_iLayerTaskState");
1109 protected string m_sName;
1110 protected int m_iCounterValue;
1111 protected bool m_bIsTerminated;
1113 protected int m_iStructVarCount;
1116 void IncreaseStructVarCount()
1118 m_iStructVarCount += 1;
1122 int GetStructVarCount()
1124 return m_iStructVarCount;
1128 bool GetIsTerminated()
1140 int GetCounterValue()
1142 return m_iCounterValue;
1148 void SetIsTerminated(
bool state)
1154 void SetName(
string name)
1160 void SetCounterValue(
int value)
1162 m_iCounterValue = value;
1169 RegV(
"m_bIsTerminated");
1170 RegV(
"m_iCounterValue");