Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayerLoadoutData.c
Go to the documentation of this file.
2{
3 bool Active;
4 int SlotIdx;
5 ResourceName WeaponPrefab;
6 ref array<ResourceName> Attachments = {};
7}
8
9class SCR_ClothingLoadoutData
10{
13}
14
16{
17 ref array<ref SCR_ClothingLoadoutData> Clothings = {};
18 ref array<ref SCR_WeaponLoadoutData> Weapons = {};
19 float LoadoutCost;
20 float LoadoutPlayerSupplyAllocationCost;
21 int FactionIndex;
22
23 //------------------------------------------------------------------------------------------------
29 static bool Extract(SCR_PlayerLoadoutData instance, ScriptCtx ctx, SSnapSerializerBase snapshot)
30 {
31 int clothingCount = instance.Clothings.Count();
32 snapshot.SerializeInt(clothingCount);
33
34 ResourceName prefab;
35 for (int i = 0; i < clothingCount; ++i)
36 {
37 snapshot.SerializeInt(instance.Clothings[i].SlotIdx);
38 prefab = instance.Clothings[i].ClothingPrefab;
39 snapshot.SerializeString(prefab);
40 }
41
42 int weaponCount = instance.Weapons.Count();
43 snapshot.SerializeInt(weaponCount);
44 for (int i = 0; i < weaponCount; ++i)
45 {
46 snapshot.SerializeBool(instance.Weapons[i].Active);
47 snapshot.SerializeInt(instance.Weapons[i].SlotIdx);
48 prefab = instance.Weapons[i].WeaponPrefab;
49 snapshot.SerializeString(prefab);
50
51 int attachmentsCount = instance.Weapons[i].Attachments.Count();
52 snapshot.SerializeInt(attachmentsCount);
53 for (int nAttachment = 0; nAttachment < attachmentsCount; ++nAttachment)
54 {
55 prefab = instance.Weapons[i].Attachments[nAttachment];
56 snapshot.SerializeString(prefab);
57 }
58 }
59
60 snapshot.SerializeFloat(instance.LoadoutCost);
61 snapshot.SerializeFloat(instance.LoadoutPlayerSupplyAllocationCost);
62 snapshot.SerializeInt(instance.FactionIndex);
63 return true;
64 }
65
66 //------------------------------------------------------------------------------------------------
72 static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, SCR_PlayerLoadoutData instance)
73 {
74 // Fill an instance with values from snapshot.
75 int clothingCount;
76 snapshot.SerializeInt(clothingCount);
77 instance.Clothings.Clear();
78
79 SCR_ClothingLoadoutData clothingData;
80 for (int i = 0; i < clothingCount; ++i)
81 {
82 clothingData = new SCR_ClothingLoadoutData();
83
84 snapshot.SerializeInt(clothingData.SlotIdx);
85
86 ResourceName prefab;
87 snapshot.SerializeString(prefab);
88 clothingData.ClothingPrefab = prefab;
89
90 instance.Clothings.Insert(clothingData);
91 }
92
93 int weaponCount;
94 snapshot.SerializeInt(weaponCount);
95 instance.Weapons.Clear();
96
97 SCR_WeaponLoadoutData weaponData;
98 for (int i = 0; i < weaponCount; ++i)
99 {
100 weaponData = new SCR_WeaponLoadoutData();
101
102 snapshot.SerializeBool(weaponData.Active);
103 snapshot.SerializeInt(weaponData.SlotIdx);
104
105 ResourceName prefab;
106 snapshot.SerializeString(prefab);
107 weaponData.WeaponPrefab = prefab;
108
109 int attachmentsCount;
110 snapshot.SerializeInt(attachmentsCount);
111 weaponData.Attachments.Reserve(attachmentsCount);
112 for (int nAttachment = 0; nAttachment < attachmentsCount; ++nAttachment)
113 {
114 snapshot.SerializeString(prefab);
115 weaponData.Attachments.Insert(prefab);
116 }
117
118 instance.Weapons.Insert(weaponData);
119 }
120
121 snapshot.SerializeFloat(instance.LoadoutCost);
122 snapshot.SerializeFloat(instance.LoadoutPlayerSupplyAllocationCost);
123 snapshot.SerializeInt(instance.FactionIndex);
124 return true;
125 }
126
127 //------------------------------------------------------------------------------------------------
133 static void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
134 {
135 int clothingCount;
136 snapshot.SerializeBytes(clothingCount, 4);
137 packet.Serialize(clothingCount, 32);
138
139 ResourceName prefab;
140 for (int i = 0; i < clothingCount; ++i)
141 {
142 // clothingData.SlotIdx
143 snapshot.EncodeInt(packet);
144
145 // clothingData.ClothingPrefab
146 snapshot.SerializeString(prefab);
147 packet.SerializeResourceName(prefab);
148 }
149
150 int weaponCount;
151 snapshot.SerializeBytes(weaponCount, 4);
152 packet.Serialize(weaponCount, 32);
153
154 for (int i = 0; i < weaponCount; ++i)
155 {
156 // weaponData.Active
157 snapshot.EncodeBool(packet);
158
159 // weaponData.SlotIdx
160 snapshot.EncodeInt(packet);
161
162 // weaponData.WeaponPrefab
163 snapshot.SerializeString(prefab);
164 packet.SerializeResourceName(prefab);
165
166 // weaponData.Attachments
167 int attachmentsCount;
168 snapshot.SerializeBytes(attachmentsCount, 4);
169 packet.Serialize(attachmentsCount, 32);
170 for (int nAttachment = 0; nAttachment < attachmentsCount; ++nAttachment)
171 {
172 snapshot.SerializeString(prefab);
173 packet.SerializeResourceName(prefab);
174 }
175 }
176
177 snapshot.EncodeFloat(packet);
178 snapshot.EncodeFloat(packet);
179 snapshot.EncodeInt(packet);
180 }
181
182 //------------------------------------------------------------------------------------------------
188 static bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
189 {
190 int clothingCount;
191 packet.Serialize(clothingCount, 32);
192 snapshot.SerializeBytes(clothingCount, 4);
193
194 ResourceName prefab;
195 for (int i = 0; i < clothingCount; ++i)
196 {
197 // clothingData.SlotIdx
198 snapshot.DecodeInt(packet);
199
200 // clothingData.ClothingPrefab
201 packet.SerializeResourceName(prefab);
202 snapshot.SerializeString(prefab);
203 }
204
205 int weaponCount;
206 packet.Serialize(weaponCount, 32);
207 snapshot.SerializeBytes(weaponCount, 4);
208
209 for (int i = 0; i < weaponCount; ++i)
210 {
211 // weaponData.Active
212 snapshot.DecodeBool(packet);
213
214 // weaponData.SlotIdx
215 snapshot.DecodeInt(packet);
216
217 // weaponData.WeaponPrefab
218 packet.SerializeResourceName(prefab);
219 snapshot.SerializeString(prefab);
220
221 // weaponData.Attachments
222 int attachmentsCount;
223 packet.Serialize(attachmentsCount, 32);
224 snapshot.SerializeBytes(attachmentsCount, 4);
225 for (int nAttachment = 0; nAttachment < attachmentsCount; ++nAttachment)
226 {
227 packet.SerializeResourceName(prefab);
228 snapshot.SerializeString(prefab);
229 }
230 }
231
232 snapshot.DecodeFloat(packet);
233 snapshot.DecodeFloat(packet);
234 snapshot.DecodeInt(packet);
235
236 return true;
237 }
238
239 //------------------------------------------------------------------------------------------------
245 static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx)
246 {
247 Print("Cannot use SCR_PlayerLoadoutData as a property", LogLevel.ERROR);
248 return true;
249 }
250
251 //------------------------------------------------------------------------------------------------
257 static bool PropCompare(SCR_PlayerLoadoutData instance, SSnapSerializerBase snapshot, ScriptCtx ctx)
258 {
259 Print("Cannot use SCR_PlayerLoadoutData as a property", LogLevel.ERROR);
260 return true;
261 }
262}
class SCR_WeaponLoadoutData SlotIdx
ResourceName ClothingPrefab
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