Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BIKIGeneralHelper.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
6 static string GetName(ResourceName itemResourceName)
7 {
8 if (!itemResourceName) // IsEmpty()
9 return string.Empty;
10
11 Resource resource = Resource.Load(itemResourceName);
12 if (!resource.IsValid())
13 return string.Empty;
14
15 BaseContainer baseContainer = resource.GetResource().ToBaseContainer();
16 if (!baseContainer)
17 return string.Empty;
18
19 return GetName(baseContainer);
20 }
21
22 //------------------------------------------------------------------------------------------------
25 static string GetName(notnull BaseContainer baseContainer)
26 {
27 BaseContainer uiInfo = GetUIInfo(baseContainer);
28 string result;
29 if (!uiInfo || !uiInfo.Get("Name", result))
30 return string.Empty;
31
32 if (result.Contains("#"))
33 return WidgetManager.Translate(result);
34
35 return result;
36 }
37
38 //------------------------------------------------------------------------------------------------
41 static BaseContainer GetUIInfo(notnull Resource resource)
42 {
43 if (!resource.IsValid())
44 return null;
45
46 return GetUIInfo(resource.GetResource().ToBaseContainer());
47 }
48
49 //------------------------------------------------------------------------------------------------
52 static BaseContainer GetUIInfo(notnull BaseContainer baseContainer)
53 {
54 IEntityComponentSource componentSource;
55
56 // character?
57 componentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, SCR_EditableCharacterComponent);
58 if (componentSource)
59 {
60 if (componentSource.GetObject("m_UIInfo"))
61 return componentSource.GetObject("m_UIInfo");
62 }
63
64 // group?
65 componentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, SCR_EditableGroupComponent);
66 if (componentSource)
67 {
68 if (componentSource.GetObject("m_UIInfo"))
69 return componentSource.GetObject("m_UIInfo");
70 }
71
72 // vehicle?
73 componentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, SCR_EditableVehicleComponent);
74 if (componentSource)
75 {
76 if (componentSource.GetObject("m_UIInfo"))
77 return componentSource.GetObject("m_UIInfo");
78 }
79
80 // turret?
81 componentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, WeaponSlotComponent);
82 if (componentSource)
83 {
85 if (componentSource.Get("WeaponTemplate", resourceName))
86 return GetUIInfo(Resource.Load(resourceName));
87 }
88
89 // inventory item?
90 componentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, InventoryItemComponent);
91 if (componentSource)
92 {
93 BaseContainer baseContainer2 = componentSource.GetObject("Attributes");
94 if (baseContainer2)
95 {
96 baseContainer2 = baseContainer2.GetObject("ItemDisplayName"); // var reuse
97 if (baseContainer2)
98 return baseContainer2;
99 }
100 }
101
102 // weapon?
103 componentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, WeaponComponent);
104 if (componentSource)
105 {
106 if (componentSource.GetObject("UIInfo"))
107 return componentSource.GetObject("UIInfo");
108 }
109
110 // something else?
111
112 return null;
113 }
114
115 //------------------------------------------------------------------------------------------------
118 static float GetMass(notnull BaseContainer baseContainer)
119 {
120 IEntityComponentSource entityComponentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, InventoryItemComponent);
121 if (entityComponentSource)
122 {
123 BaseContainer subContainer = entityComponentSource.GetObject("Attributes"); // variable reuse
124 if (subContainer)
125 {
126 subContainer = subContainer.GetObject("ItemPhysAttributes"); // variable reuse
127 if (subContainer)
128 {
129 float result;
130 if (subContainer.Get("Weight", result))
131 return result;
132 }
133 }
134 }
135
136 entityComponentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, EquipmentStorageComponent); // variable reuse
137 if (entityComponentSource)
138 {
139 BaseContainer subContainer = entityComponentSource.GetObject("Attributes"); // variable reuse
140 if (subContainer)
141 {
142 subContainer = subContainer.GetObject("ItemPhysAttributes"); // variable reuse
143 if (subContainer)
144 {
145 float result;
146 if (subContainer.Get("Weight", result))
147 return result;
148 }
149 }
150 }
151
152 entityComponentSource = SCR_BaseContainerTools.FindComponentSource(baseContainer, "RigidBody"); // variable reuse
153 if (entityComponentSource)
154 {
155 float result;
156 if (entityComponentSource.Get("Mass", result))
157 return result;
158 }
159
160 return 0;
161 }
162
163 //------------------------------------------------------------------------------------------------
166 static bool IsCharacter(notnull BaseContainer baseContainer)
167 {
168 return baseContainer.GetClassName().ToType()
169 && baseContainer.GetClassName().ToType().IsInherited(SCR_ChimeraCharacter);
170 }
171
172 //------------------------------------------------------------------------------------------------
175 static bool IsWeapon(notnull BaseContainer baseContainer)
176 {
177 return SCR_BaseContainerTools.FindComponentIndex(baseContainer, WeaponComponent) > -1;
178 }
179
180 //------------------------------------------------------------------------------------------------
183 static bool IsMagazine(notnull BaseContainer baseContainer)
184 {
185 return SCR_BaseContainerTools.FindComponentIndex(baseContainer, MagazineComponent) > -1;
186 }
187
188 //------------------------------------------------------------------------------------------------
191 static bool IsBullet(notnull BaseContainer baseContainer)
192 {
193 return baseContainer.GetClassName().ToType()
194 && baseContainer.GetClassName().ToType().IsInherited(Projectile)
195 && SCR_BaseContainerTools.FindComponentIndex(baseContainer, ShellMoveComponent) > -1;
196 }
197
198 //------------------------------------------------------------------------------------------------
201 static bool IsGroup(notnull BaseContainer baseContainer)
202 {
203 return baseContainer.GetClassName().ToType()
204 && baseContainer.GetClassName().ToType().IsInherited(SCR_AIGroup);
205 }
206
207 //------------------------------------------------------------------------------------------------
210 static bool IsWheeled(notnull BaseContainer baseContainer)
211 {
212 return baseContainer.GetClassName().ToType()
213 && baseContainer.GetClassName().ToType().IsInherited(Vehicle)
214 && SCR_BaseContainerTools.FindComponentIndex(baseContainer, VehicleWheeledSimulation) > -1;
215 }
216
217 //------------------------------------------------------------------------------------------------
220 static bool IsTracked(notnull BaseContainer baseContainer)
221 {
222 return baseContainer.GetClassName().ToType()
223 && baseContainer.GetClassName().ToType().IsInherited(Vehicle)
224 && SCR_BaseContainerTools.FindComponentIndex(baseContainer, VehicleTrackedSimulation) > -1;
225 }
226
227 //------------------------------------------------------------------------------------------------
230 static bool IsHelicopter(notnull BaseContainer baseContainer)
231 {
232 return baseContainer.GetClassName().ToType()
233 && baseContainer.GetClassName().ToType().IsInherited(Vehicle)
234 && SCR_BaseContainerTools.FindComponentIndex(baseContainer, VehicleHelicopterSimulation) > -1;
235 }
236
237 //------------------------------------------------------------------------------------------------
240 static bool IsStaticWeapon(notnull BaseContainer baseContainer)
241 {
242 return baseContainer.GetClassName().ToType()
243 && baseContainer.GetClassName().ToType().IsInherited(Turret)
244 && SCR_BaseContainerTools.FindComponentIndex(baseContainer, SCR_TurretControllerComponent) > -1;
245 }
246
247 //------------------------------------------------------------------------------------------------
250 static bool IsComposition(notnull BaseContainer baseContainer)
251 {
252 return SCR_BaseContainerTools.FindComponentIndex(baseContainer, SCR_SlotCompositionComponent) > -1;
253 }
254}
ResourceName resourceName
Definition SCR_AIGroup.c:66
void SCR_EditableGroupComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Entity composition which is supposed to fit into a slot.
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24