Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GameOverFactionsEditorAttribute.c
Go to the documentation of this file.
3 {
4 
5  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
6  {
7  SCR_RespawnComponent respawnComponent = SCR_RespawnComponent.Cast(item);
8  if (!respawnComponent)
9  return null;
10 
11  BaseGameMode gameMode = GetGame().GetGameMode();
12  if (!gameMode)
13  return null;
14 
15  SCR_GameOverScreenManagerComponent gameOverManager = SCR_GameOverScreenManagerComponent.Cast(gameMode.FindComponent(SCR_GameOverScreenManagerComponent));
16  if (!gameOverManager)
17  return null;
18 
19  super.ReadVariable(item, manager);
20 
21  SCR_DelegateFactionManagerComponent delegateFactionManager = SCR_DelegateFactionManagerComponent.GetInstance();
22  if (!delegateFactionManager)
23  return null;
24 
25  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
26  if (!factionManager)
27  return null;
28 
29  SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>;
30  int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
31 
32 
33  SCR_Faction scrFaction;
34  int playableFactionsCount = 0;
35 
36  for(int i = 0; i < count; ++i)
37  {
38  scrFaction = SCR_Faction.Cast(factionDelegates.Get(i).GetFaction());
39 
40  if (!scrFaction || !scrFaction.IsPlayable())
41  continue;
42 
43  playableFactionsCount++;
44  AddOrderedState(false);
45  }
46 
47  if (playableFactionsCount <= 0)
48  return null;
49 
50  return SCR_BaseEditorAttributeVar.CreateVector(GetFlagVector());
51  }
52 
53  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
54  {
55  super.WriteVariable(item, var, manager, playerID);
56 
58  if (!gamemode)
59  return;
60 
61  SCR_GameOverScreenManagerComponent gameOverManager = SCR_GameOverScreenManagerComponent.Cast(gamemode.FindComponent(SCR_GameOverScreenManagerComponent));
62  if (!gameOverManager)
63  return;
64 
65  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
66  if (!factionManager)
67  return;
68 
69  SCR_DelegateFactionManagerComponent delegateFactionManager = SCR_DelegateFactionManagerComponent.GetInstance();
70  if (!delegateFactionManager)
71  return;
72 
73  SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>;
74  int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
75 
76  array <int> selectedFactions = new array<int>;
77  SCR_Faction scrFaction;
78 
79  //Get all selected factions
80  for(int i = 0; i < count; ++i)
81  {
82  scrFaction = SCR_Faction.Cast(factionDelegates.Get(i).GetFaction());
83 
84  if (!scrFaction || !scrFaction.IsPlayable() || !GetOrderedState())
85  continue;
86 
87  selectedFactions.Insert(factionManager.GetFactionIndex(scrFaction));
88  }
89 
90  gameOverManager.SetEditorGameOverFactions(selectedFactions);
91  }
92 
93  protected int GetEditorGameOverInfoArray(notnull array <SCR_BaseGameOverScreenInfo> gameOverScreens, notnull out array <SCR_BaseGameOverScreenInfo> editorGameOverScreens)
94  {
95  SCR_BaseGameOverScreenInfoEditor editorOptional;
96 
97  foreach (SCR_BaseGameOverScreenInfo screen: gameOverScreens)
98  {
99  editorOptional = screen.GetEditorOptionalParams();
100 
101  if (!editorOptional || !editorOptional.m_bCanBeSetByGameMaster)
102  continue;
103 
104  editorGameOverScreens.Insert(screen);
105  }
106 
107  return editorGameOverScreens.Count();
108  }
109 
110  override protected void CreatePresets()
111  {
112  SCR_DelegateFactionManagerComponent delegateFactionManager = SCR_DelegateFactionManagerComponent.GetInstance();
113  if (!delegateFactionManager)
114  return;
115 
116  FactionManager factionManager = GetGame().GetFactionManager();
117  if (!factionManager)
118  return;
119 
120  m_aValues.Clear();
121 
122  SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>;
123  int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
124 
125  SCR_Faction scrFaction;
126 
127  for(int i = 0; i < count; ++i)
128  {
129  scrFaction = SCR_Faction.Cast(factionDelegates.Get(i).GetFaction());
130 
131  if (!scrFaction || !scrFaction.IsPlayable())
132  continue;
133 
135  value.SetWithUIInfo(scrFaction.GetUIInfo(), factionManager.GetFactionIndex(factionDelegates.Get(i).GetFaction()));
136  m_aValues.Insert(value);
137  }
138  }
139 };
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
SCR_BaseGameOverScreenInfo
Definition: SCR_BaseGameOverScreenInfo.c:2
SCR_RespawnComponent
void SCR_RespawnComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_RespawnComponent.c:576
m_aValues
SCR_BaseEditorAttributeEntryTimeSlider m_aValues
SCR_BaseGameOverScreenInfoEditor
Definition: SCR_BaseGameOverScreenInfo.c:391
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_BaseMultiSelectPresetsEditorAttribute
Definition: SCR_BaseMultiSelectPresetsEditorAttribute.c:4
SCR_EditorAttributeFloatStringValueHolder
Definition: SCR_BaseFloatValueHolderEditorAttribute.c:17
SCR_GameOverFactionsEditorAttribute
Definition: SCR_GameOverFactionsEditorAttribute.c:2
SCR_DelegateFactionManagerComponent
Definition: SCR_DelegateFactionManagerComponent.c:15
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
SCR_Faction
Definition: SCR_Faction.c:6
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468