6 static ref array<string> m_AllRebuildableTypes;
7 static ref array<string> m_RebuildableTypesUsed = {};
9 static float m_Dist = 10.0;
10 static int m_LastIdx = -1;
11 static bool m_IsSpawned;
13 static vector m_SpawnPos;
15 static int m_DbgLockCounter;
17 static void StartRebuildablesSpawning(
bool loop =
false, array<string> overrides = null)
20 StopRebuildablesSpawning();
24 if (!m_AllRebuildableTypes)
25 InitAllRebuildableTypes();
27 m_RebuildableTypesUsed.Copy(m_AllRebuildableTypes);
31 m_RebuildableTypesUsed.Copy(overrides);
34 if (
g_Game.IsDedicatedServer())
43 m_Rebuidable.DeleteSafe();
47 static void StopRebuildablesSpawning()
50 m_Rebuidable.DeleteSafe();
56 protected static void InitAllRebuildableTypes()
58 string basePath =
"cfgVehicles";
60 m_AllRebuildableTypes =
new array<string>();
61 int count =
g_Game.ConfigGetChildrenCount(basePath);
62 for (
int q = 0; q < count; ++q)
64 g_Game.ConfigGetChildName(basePath, q, typeName);
65 string cfgPath =
"cfgVehicles " + typeName +
" Construction";
66 if (
g_Game.ConfigIsExisting(cfgPath) && !
g_Game.IsKindOf(typeName,
"BaseBuildingBase"))
67 m_AllRebuildableTypes.
Insert(typeName);
71 protected static void ProcessRebuildablesSpawning()
75 m_Rebuidable.DeleteSafe();
77 if (m_LastIdx >= m_RebuildableTypesUsed.Count() - 1)
89 if (m_LastIdx >= m_RebuildableTypesUsed.Count())
92 SpawnAndRebuildAllParts(m_RebuildableTypesUsed[m_LastIdx]);
97 protected static void SpawnAndRebuildAllParts(
string type)
104 con.BuildPartServerEx(null,
name, -1);
117 GetCLIParam(
"RBLDRebuildEverythingWithLocks", tmp);
118 int maxTotalLockCount = tmp.
ToInt();
119 GameInventory inv = ent.GetInventory();
123 array<ConstructionPart> constructionPartArray = con.GetConstructionPartArray();
126 if (part.IsUtilityPart())
129 string partName = part.GetPartName();
132 con.BuildPartServerEx(null, partName, -1);
142 wallsWindowed.Insert(partName);
144 wallsDoored.Insert(partName);
146 wallsSimple.Insert(partName);
150 doors.Insert(partName);
152 else if (partName.
Contains(
"window"))
154 windows.Insert(partName);
159 foreach (
string wallWithDoors : wallsDoored)
161 if (!con.HasConflictPart(wallWithDoors))
162 con.BuildPartServerEx(null, wallWithDoors, -1);
166 foreach (
string wallWithWindows : wallsWindowed)
168 if (!con.HasConflictPart(wallWithWindows))
169 con.BuildPartServerEx(null, wallWithWindows, -1);
173 foreach (
string wallSimple : wallsSimple)
175 if (!con.HasConflictPart(wallSimple))
176 con.BuildPartServerEx(null, wallSimple, -1);
180 foreach (
string door : doors)
182 if (!con.HasConflictPart(door) && con.HasRequiredPart(door))
184 con.BuildPartServerEx(null, door, -1);
186 if (m_DbgLockCounter > maxTotalLockCount)
189 int idx1 = door.IndexOf(
"door") + 4;
190 int idx2 = door.IndexOf(
"_wood");
191 string attSlotName = door.Substring(idx1, idx2 - idx1);
192 attSlotName =
string.
Format(
"Att_CodeLock%1_Wood", attSlotName);
193 int slotID = InventorySlots.GetSlotIdFromString(attSlotName);
200 else if (!lock && Class.CastTo(lock, inv.
CreateAttachmentEx(
"DigitalCodeLock", slotID)))
209 foreach (
string window : windows)
211 if (!con.HasConflictPart(door) && con.HasRequiredPart(window))
212 con.BuildPartServerEx(null, window, -1);
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void ConstructionBase(EntityAI parent)
void ConstructionPart(string name, string part_name, string main_part_name, int id, bool is_built, bool is_base, bool is_gate, array< string > required_parts)
override void OnDebugSpawn()
proto native EntityAI CreateAttachmentEx(string typeName, int slotId)
Create Entity of specified type as attachment of entity.
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)
class array< Class T > TStringArray
proto native int ToInt()
Converts string to integer.
proto void Insert(int index, string input)
Inserts a string into the n-th index, increasing the string length by the size of the input.
bool Contains(string sample)
Returns true if sample is substring of string.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto bool GetCLIParam(string param, out string val)
Returns command line argument.