Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_LoadoutSaveBlackListHolder.c
Go to the documentation of this file.
1[BaseContainerProps(configRoot: true)]
3{
4 [Attribute(desc: "List of blacklist entries. Each blacklist becomes a button in attributes which the GM can enable and/or disable and is a set of items/item types which cannot be saved in loadout if the blacklist is activate")]
5 protected ref array<ref SCR_LoadoutSaveBlackList> m_LoadoutSaveBlackLists;
6
7 [Attribute(desc: "List of Items that are black listed regardless of the other black list rules. Players with the item in their inventory can never save their loadout")]
8 protected ref array<ref SCR_LoadoutSaveBlackListItem> m_aSaveBlackListItems;
9
10 //------------------------------------------------------------------------------------------------
12 void Init()
13 {
14 for (int i = m_LoadoutSaveBlackLists.Count() - 1; i >= 0; i--)
15 {
16 //~ Removed disabled lists
18 {
19 m_LoadoutSaveBlackLists.RemoveOrdered(i);
20 continue;
21 }
22 }
23 }
24
25 //------------------------------------------------------------------------------------------------
29 int GetLoadoutSaveBlackLists(out notnull array<SCR_LoadoutSaveBlackList> loadoutSaveBlackLists)
30 {
31 loadoutSaveBlackLists.Clear();
32
34 {
35 loadoutSaveBlackLists.Insert(blackList);
36 }
37
38 return loadoutSaveBlackLists.Count();
39 }
40
41 //------------------------------------------------------------------------------------------------
44 {
45 return m_LoadoutSaveBlackLists.Count();
46 }
47
48 //------------------------------------------------------------------------------------------------
53 {
55 return true;
56
57 //~ Check if the specific item is blacklisted
59 {
60 if (blackListItem.m_bEnabled && blackListItem.m_sSaveBlackListItem == prefab)
61 return true;
62 }
63
64 //~ Check if the item type is black listed
66 {
67 if (!blackList || !blackList.IsActive())
68 continue;
69
70 //~ Prefab in blacklist so not allowed to save
71 if (blackList.DoesBlackListContaintPrefab(prefab))
72 return true;
73 }
74
75 //~ Prefab not in an enabled blacklist
76 return false;
77 }
78
79 //------------------------------------------------------------------------------------------------
80 //! Get if black list is active
81 //! \param[in] index Index of black list
82 //! \return True if active
84 {
85 if (!m_LoadoutSaveBlackLists.IsIndexValid(index))
86 {
87 Print("'SCR_LoadoutSaveBlackListHolder' function 'IsBlackListEnabled' given index is invalid", LogLevel.ERROR);
88 return false;
89 }
90
91 return m_LoadoutSaveBlackLists[index].IsActive();
92 }
93
94 //------------------------------------------------------------------------------------------------
97 //! \param[in] active True if setting blacklist active
98 void SetBlackListActive(int index, bool active)
99 {
100 if (!m_LoadoutSaveBlackLists.IsIndexValid(index))
101 {
102 Print("'SCR_LoadoutSaveBlackListHolder' function 'SetBlackListEnabled' given index is invalid", LogLevel.ERROR);
103 return;
105
106 m_LoadoutSaveBlackLists[index].SetActive(active);
107 }
108
109 //------------------------------------------------------------------------------------------------
111
113 int GetOrderedBlackListsActive(out notnull array<bool> orderedBlackListActive)
114 {
115 orderedBlackListActive.Clear();
116
117 array<SCR_LoadoutSaveBlackList> loadoutSaveBlackLists = {};
118 GetLoadoutSaveBlackLists(loadoutSaveBlackLists);
119
120 foreach (SCR_LoadoutSaveBlackList blackList : loadoutSaveBlackLists)
121 {
122 orderedBlackListActive.Insert(blackList.IsActive());
123 }
124
125 return orderedBlackListActive.Count();
126 }
127
128 //------------------------------------------------------------------------------------------------
131 void SetOrderedBlackListsActive(notnull array<bool> orderedBlackListActive)
132 {
133 for (int i = 0, count = orderedBlackListActive.Count(); i < count; i++)
134 {
135 SetBlackListActive(i, orderedBlackListActive[i]);
136 }
137 }
138};
139
140//------------------------------------------------------------------------------------------------
143{
144 [Attribute("1", "If blacklist is enabled or not. Disabled blacklists are removed on init and is used for mods")]
145 protected bool m_bEnabled;
146
147 [Attribute("0", "If blacklist is active or not. If active than the items within the prefab list can never be saved in loadouts")]
148 protected bool m_bBlackListActive;
149
150 [Attribute(desc: "Ui info to display in editor to set blacklist saving or not")]
151 protected ref SCR_UIInfo m_UIInfo;
152
153 [Attribute(desc: "List of entities that are blacklisted and can never be saved when player saves their loadout. Is cleared on init and any prefabs are added to a faster set.", uiwidget: UIWidgets.ResourcePickerThumbnail, params: "et")]
154 protected ref array<ResourceName> m_aBlackListedPrefabs;
155
156 [Attribute(desc: "List of item type and mode that cannot be saved in loadout. This list is cleared on init and any prefabs that fit the set up are added to a faster set.")]
157 protected ref array<ref SCR_LoadoutSaveBlackListItemType> m_BlackListedItemTypes;
158
159 //~ List of resource names that are black listed
160 protected ref set<ResourceName> m_BlackListedPrefabs = new set<ResourceName>();
161
162 //------------------------------------------------------------------------------------------------
165 bool Init()
166 {
167 foreach (ResourceName prefab : m_aBlackListedPrefabs)
168 {
169 m_BlackListedPrefabs.Insert(prefab);
170 }
171
172 //~ Delete the array list as it is no longer needed
174
175 SCR_EntityCatalogManagerComponent catalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
176
177 if (!catalogManager && !m_BlackListedItemTypes.IsEmpty())
178 {
179 Debug.Error2("SCR_LoadoutSaveBlackList", "Black lists need the 'SCR_EntityCatalogManagerComponent' to set the the prefabs who are blacklisted. The blacklist will be disabled if the custom prefab blacklist is empty");
181
182 //~ No items in the black list so set disabled
183 if (m_BlackListedPrefabs.IsEmpty())
184 {
185 m_bEnabled = false;
186 return false;
187 }
188
189 return true;
190 }
191
192 array<SCR_ArsenalItem> filteredArsenalItems = {};
193
194 //~ Find arsenal items for each filter (Intensive search)
195 foreach (SCR_LoadoutSaveBlackListItemType blackList : m_BlackListedItemTypes)
196 {
197 //~ Get list of arsenal items either with or without mode
198 if (blackList.m_bIgnoreItemMode)
199 catalogManager.GetAllArsenalItems(filteredArsenalItems, blackList.m_eItemType);
200 else
201 catalogManager.GetAllArsenalItems(filteredArsenalItems, blackList.m_eItemType, blackList.m_eItemMode);
202
203 //~ Get the Prefab resourcename form arsenal item
204 foreach (SCR_ArsenalItem arsenalItem : filteredArsenalItems)
205 {
206 m_BlackListedPrefabs.Insert(arsenalItem.GetItemResourceName());
207 }
208 }
209
210 //~ Delete the array list as no longer needed
212 return true;
213 }
214
215 //------------------------------------------------------------------------------------------------
218 {
219 return m_bEnabled;
220 }
221
222 //------------------------------------------------------------------------------------------------
224 bool IsActive()
225 {
226 return m_bBlackListActive;
227 }
228
229 //------------------------------------------------------------------------------------------------
232 void SetActive(bool active)
233 {
234 m_bBlackListActive = active
235 }
236
237 //------------------------------------------------------------------------------------------------
242 {
243 return m_BlackListedPrefabs.Contains(prefab);
244 }
245
246 //------------------------------------------------------------------------------------------------
249 {
250 if (!m_UIInfo)
251 return new SCR_UIInfo();
252
253 return m_UIInfo;
254 }
255}
256
258class SCR_LoadoutSaveBlackListItemType
259{
260 [Attribute("2", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EArsenalItemType))]
262
263 [Attribute("-1", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EArsenalItemMode))]
265
266 [Attribute("1", desc: "If true than the ItemMode will be ignored and any items that have the type regardless of the mode will be blacklisted", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EArsenalItemMode))]
267 bool m_bIgnoreItemMode;
268}
269
272{
273 [Attribute(desc: "Item prefabs that are not allowed to be saved in the players loadout", UIWidgets.ResourcePickerThumbnail, params: "et")]
274 ResourceName m_sSaveBlackListItem;
275
276 [Attribute("1", desc: "If the item is actively blacklisted")]
277 bool m_bEnabled;
278}
SCR_EArsenalItemMode m_eItemMode
SCR_EArsenalItemType m_eItemType
class SCR_ArsenalGameModeUIDataHolder SCR_BaseContainerCustomTitleUIInfo("m_UIInfo")
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_EArsenalItemMode
SCR_EArsenalItemType
class SCR_LoadoutSaveBlackList BaseContainerProps()
class SCR_LoadoutSaveBlackList SCR_BaseContainerCustomTitleEnum(SCR_EArsenalItemType, "m_eItemType")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Debug.c:13
int GetLoadoutSaveBlackLists(out notnull array< SCR_LoadoutSaveBlackList > loadoutSaveBlackLists)
void SetBlackListActive(int index, bool active)
ref array< ref SCR_LoadoutSaveBlackList > m_LoadoutSaveBlackLists
ref array< ref SCR_LoadoutSaveBlackListItem > m_aSaveBlackListItems
int GetOrderedBlackListsActive(out notnull array< bool > orderedBlackListActive)
void Init()
Init black lists, this will make sure each blacklist has a list to items that are blacklisted.
void SetOrderedBlackListsActive(notnull array< bool > orderedBlackListActive)
ref array< ResourceName > m_aBlackListedPrefabs
ref array< ref SCR_LoadoutSaveBlackListItemType > m_BlackListedItemTypes
bool DoesBlackListContaintPrefab(ResourceName prefab)
ref set< ResourceName > m_BlackListedPrefabs
static bool IsEmptyOrWhiteSpace(string input)
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
SCR_FieldOfViewSettings Attribute
bool IsEnabled()
Returns true if the light is enabled.