Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayableFactionKillingAttributeDynamicDescription.c
Go to the documentation of this file.
1
4[BaseContainerProps(), BaseContainerCustomStringTitleField("Players will be killed warning (CUSTOM)")]
6{
7 protected int m_iPlayersWillBeKilled = 0;
8 protected ref array<int> m_aStartingDisabledFactions = {};
9
10 protected FactionManager m_FactionManager;
13
14 protected SCR_RespawnSystemComponent m_RespawnSystemComponent;
16
17 //------------------------------------------------------------------------------------------------
18 override void InitDynamicDescription(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
19 {
20 super.InitDynamicDescription(attribute);
21
22 if (!attribute.IsInherited(SCR_PlayableFactionEditorAttribute) && !attribute.IsInherited(SCR_PlayableFactionsEditorAttribute))
23 {
24 Print("'SCR_PlayableFactionDisabledAttributeDynamicDescription' is not attached to the 'SCR_PlayableFactionEditorAttribute' nor 'SCR_PlayableFactionsEditorAttribute'!", LogLevel.ERROR);
25 return;
26 }
27
28 if (attribute.IsInherited(SCR_PlayableFactionsEditorAttribute))
29 {
31 if (!buttonBoxUI)
32 {
33 Print("'SCR_PlayableFactionDisabledAttributeDynamicDescription' is used for 'SCR_PlayableFactionsEditorAttribute' but attribute UI does not inherent from SCR_ButtonBoxAttributeUIComponent!", LogLevel.ERROR);
34 return;
35 }
36
39 {
40 Print("'SCR_PlayableFactionDisabledAttributeDynamicDescription' is used for 'SCR_PlayableFactionsEditorAttribute' but could not find SCR_ToolboxComponent!", LogLevel.ERROR);
41 return;
42 }
43
44 m_ButtonBoxData = buttonBoxUI.GetButtonBoxData();
45 if (!m_ButtonBoxData)
46 {
47 Print("'SCR_PlayableFactionDisabledAttributeDynamicDescription' is used for 'SCR_PlayableFactionsEditorAttribute' but could not find m_ButtonBoxData!", LogLevel.ERROR);
48 return;
49 }
50 }
51
53 m_FactionManager = GetGame().GetFactionManager();
54
56 m_RespawnSystemComponent = SCR_RespawnSystemComponent.GetInstance();
57
60
61 //~ Get factions that started out disabled
64 }
65
66 //------------------------------------------------------------------------------------------------
67 override bool IsValid(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
68 {
69 if (!super.IsValid(attribute, attributeUi))
70 return false;
71
72 if (!attribute.IsInherited(SCR_PlayableFactionEditorAttribute) && !attribute.IsInherited(SCR_PlayableFactionsEditorAttribute))
73 return false;
74
76 return false;
77
78 if (attribute.IsInherited(SCR_PlayableFactionsEditorAttribute))
79 {
81 return false;
82 }
83
85 return false;
86
88
89 return m_iPlayersWillBeKilled > 0;
90 }
91
92 //------------------------------------------------------------------------------------------------
93 override void GetDescriptionData(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi, out SCR_EditorAttributeUIInfo uiInfo, out string param1 = string.Empty, out string param2 = string.Empty, out string param3 = string.Empty)
94 {
96
98 param1 = m_iPlayersWillBeKilled.ToString();
99 }
100
101 //------------------------------------------------------------------------------------------------
103 {
104 array<int> disabledFactions = {};
106
108 if (!var)
109 return;
110
111 //~ Get idisabled factions
112 GetDisabledFactions(attribute, disabledFactions);
113
114 Faction playerFaction;
115
116 if (!disabledFactions.IsEmpty())
117 {
119 if (!factionManager) // factions and player factions depend on such faction manager
120 return;
121
122 array<int> players = new array<int>;
123 GetGame().GetPlayerManager().GetPlayers(players);
124 SCR_EditablePlayerDelegateComponent playerEditorDelegate;
125
126 foreach (int playerId: players)
127 {
128 //If has player entity
129 if(!SCR_PossessingManagerComponent.GetPlayerMainEntity(playerId))
130 continue;
131
132 playerFaction = factionManager.GetPlayerFaction(playerId);
133 if (!playerFaction)
134 continue;
135
136 int factionIndex = factionManager.GetFactionIndex(playerFaction);
137
138 if (!disabledFactions.Contains(factionIndex) || m_aStartingDisabledFactions.Contains(factionIndex))
139 continue;
140
141 //Ignore GM
142 /*if (m_PlayerDelegateManager)
143 {
144 playerEditorDelegate = m_PlayerDelegateManager.GetDelegate(playerId);
145
146 if (playerEditorDelegate)
147 {
148 if (!playerEditorDelegate.HasLimitedEditor())
149 continue;
150 }
151 }*/
152
154 }
155 }
156 }
157
158 //------------------------------------------------------------------------------------------------
159 protected void GetDisabledFactions(SCR_BaseEditorAttribute attribute, notnull out array<int> disabledFactions)
160 {
162 if (!var)
163 return;
164
165 //~ Single faction get if disabled
166 if (attribute.IsInherited(SCR_PlayableFactionEditorAttribute))
167 {
168 vector value = var.GetVector();
169
170 if (value[0] == 0)
171 disabledFactions.Insert((int)value[1]);
172 }
173 //~ Multiple factions get all disabled faction
174 else
175 {
177 return;
178
179 //Get all disabled buttonts and the faction associated with it and make sure the system adds a Attribute explanation if any players will die on Accept
180 int count = m_ButtonBoxData.GetValueCount();
181
182 int factionIndex;
183 Faction faction;
184 SCR_Faction scrFaction;
185
186 for(int i = 0; i < count; i++)
187 {
188 if (!m_ToolBoxComponent.IsItemSelected(i))
189 {
190 factionIndex = m_ButtonBoxData.GetEntryFloatValue(i);
191
192 faction = m_FactionManager.GetFactionByIndex(factionIndex);
193
194 scrFaction = SCR_Faction.Cast(faction);
195
196 //Check if currently playable
197 if (scrFaction && scrFaction.IsPlayable())
198 disabledFactions.Insert(factionIndex);
199 }
200 }
201 }
202 }
203};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_BaseEditorAttributeFloatStringValues(array< ref SCR_EditorAttributeFloatStringValueHolder > values)
void SCR_FactionManager(IEntitySource src, IEntity parent)
class SCR_HitZoneGroupNameHolder BaseContainerCustomStringTitleField("USE INHERITED VERSION ONLY!")
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
sealed SCR_BaseEditorAttributeVar GetVariableOrCopy()
SCR_BaseEditorAttributeFloatStringValues GetButtonBoxData()
UIInfo used by editor attribute system.
bool IsPlayable()
override void GetDescriptionData(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi, out SCR_EditorAttributeUIInfo uiInfo, out string param1=string.Empty, out string param2=string.Empty, out string param3=string.Empty)
override bool IsValid(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
void GetDisabledFactions(SCR_BaseEditorAttribute attribute, notnull out array< int > disabledFactions)
override void InitDynamicDescription(notnull SCR_BaseEditorAttribute attribute, notnull SCR_BaseEditorAttributeUIComponent attributeUi)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
T3 param3
Definition tuple.c:93
T2 param2
Definition tuple.c:92
Tuple param1