6 static array<float> GetAttachmentMasses(notnull
BaseContainer weaponContainer)
8 array<IEntityComponentSource> componentSources = {};
12 array<float> result = {};
17 if (!componentSource.GetObject(
"AttachmentSlot") || !componentSource.GetObject(
"AttachmentSlot").Get(
"Prefab", attachmentPrefab) || !attachmentPrefab)
20 resource =
Resource.Load(attachmentPrefab);
21 if (!resource.IsValid())
33 static array<string> GetAttachmentNames(notnull
BaseContainer weaponContainer)
35 array<IEntityComponentSource> componentSources = {};
39 array<string> result = {};
43 if (!componentSource.GetObject(
"AttachmentSlot") || !componentSource.GetObject(
"AttachmentSlot").Get(
"Prefab", attachmentPrefab) || !attachmentPrefab)
48 result.Insert(itemName);
57 static float GetInitialSpeedCoefficient(notnull
BaseContainer weaponContainer)
60 if (!muzzleComponentSource)
64 muzzleComponentSource.Get(
"BulletInitSpeedCoef", result);
74 foreach (
float mass : GetAttachmentMasses(weaponContainer))
86 static float GetMaxRateOfFire(notnull
BaseContainer weaponContainer)
89 if (!muzzleComponentSource)
92 BaseContainerList baseContainerList = muzzleComponentSource.GetObjectArray(
"FireModes");
93 if (!baseContainerList)
97 for (
int i, count = baseContainerList.Count(); i < count; ++i)
100 if (baseContainerList.Get(i).Get(
"RoundsPerMinute", rpm) && result < rpm)
110 static array<string> GetFireModes(notnull
BaseContainer weaponContainer)
113 if (!muzzleComponentSource)
116 BaseContainerList baseContainerList = muzzleComponentSource.GetObjectArray(
"FireModes");
117 if (!baseContainerList)
120 array<string> result = {};
122 for (
int i, count = baseContainerList.Count(); i < count; ++i)
124 weaponContainer = baseContainerList.Get(i);
126 if (weaponContainer.Get(
"UIName", fireMode) && fireMode)
129 if (weaponContainer.Get(
"MaxBurst", maxBurst) && maxBurst > 1)
130 result.Insert(
string.Format(
"%1 (%2)", fireMode, maxBurst));
132 result.Insert(fireMode);
145 if (!muzzleComponentSource)
149 muzzleComponentSource.Get(
"MagazineTemplate", result);
156 static typename GetMagazineWell(notnull
BaseContainer weaponContainer)
159 if (!muzzleComponentSource)
160 return typename.Empty;
162 BaseContainer baseContainer = muzzleComponentSource.GetObject(
"MagazineWell");
164 return typename.Empty;
166 return baseContainer.GetClassName().ToType();
175 if (!componentSource)
179 if (!componentSource.Get(
"Enabled", enabled) || !enabled)
183 componentSource.Get(
"WeaponTemplate", result);
190 static array<float> GetStaticWeaponAngles(notnull
BaseContainer weaponContainer)
193 if (!componentSource)
194 return { 0, 0, 0, 0 };
196 array<float> result = { 0, 0, 0, 0 };
199 componentSource.Get(
"LimitsHoriz", values);
200 result[0] = values[0];
201 result[1] = values[1];
203 componentSource.Get(
"LimitsVert", values);
204 result[2] = values[0];
205 result[3] = values[1];
213 static array<string> GetAllTurretNames(notnull
BaseContainer vehicleContainer)
215 array<string> result = {};
217 array<IEntityComponentSource> componentSources = {};
218 if (
SCR_BaseContainerTools.FindComponentSourcesOfClass(vehicleContainer, SlotManagerComponent,
false, componentSources) > 0)
225 baseContainerList = componentSource.GetObjectArray(
"Slots");
226 if (!baseContainerList)
229 for (
int i, count = baseContainerList.Count(); i < count; ++i)
231 baseContainer = baseContainerList.Get(i);
236 if (!baseContainer.Get(
"Enabled", enabled) || !enabled)
243 if (resource.IsValid())
244 result.InsertAll(GetAllTurretNames(resource.GetResource().ToBaseContainer()));
259 if (resource.IsValid())
261 array<string> turrets = GetAllTurretNames(resource.GetResource().ToBaseContainer());
262 if (turrets.IsEmpty())
270 result.InsertAll(turrets);
287 array<IEntityComponentSource> componentSources = {};
291 return componentSources[0];