Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_PlayerLoadoutData.c
Go to the documentation of this file.
2 {
3  int SlotIdx;
4  ResourceName WeaponPrefab;
5 }
6 
7 class SCR_ClothingLoadoutData
8 {
9  int SlotIdx;
10  ResourceName ClothingPrefab;
11 }
12 
14 {
15  ref array<ref SCR_ClothingLoadoutData> Clothings = {};
16  ref array<ref SCR_WeaponLoadoutData> Weapons = {};
17  float LoadoutCost;
18 
19  //------------------------------------------------------------------------------------------------
25  static bool Extract(SCR_PlayerLoadoutData instance, ScriptCtx ctx, SSnapSerializerBase snapshot)
26  {
27  // Fill a snapshot with values from an instance.
28 
29  int clothingCount = instance.Clothings.Count();
30  snapshot.SerializeInt(clothingCount);
31 
32  for (int i = 0; i < clothingCount; ++i)
33  {
34  snapshot.SerializeInt(instance.Clothings[i].SlotIdx);
35 
36  string resourceName = instance.Clothings[i].ClothingPrefab;
37  snapshot.SerializeString(resourceName);
38  }
39 
40  int weaponCount = instance.Weapons.Count();
41  snapshot.SerializeInt(weaponCount);
42 
43  for (int i = 0; i < weaponCount; ++i)
44  {
45  snapshot.SerializeInt(instance.Weapons[i].SlotIdx);
46 
47  string resourceName = instance.Weapons[i].WeaponPrefab;
48  snapshot.SerializeString(resourceName);
49  }
50 
51  snapshot.SerializeFloat(instance.LoadoutCost);
52 
53  return true;
54  }
55 
56  //------------------------------------------------------------------------------------------------
62  static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, SCR_PlayerLoadoutData instance)
63  {
64  // Fill an instance with values from snapshot.
65  int clothingCount;
66  snapshot.SerializeInt(clothingCount);
67  instance.Clothings.Clear();
68 
69  for (int i = 0; i < clothingCount; ++i)
70  {
71  SCR_ClothingLoadoutData clothingData();
72 
73  snapshot.SerializeInt(clothingData.SlotIdx);
74 
75  string resourceName;
76  snapshot.SerializeString(resourceName);
77  clothingData.ClothingPrefab = resourceName;
78 
79  instance.Clothings.Insert(clothingData);
80  }
81 
82  int weaponCount;
83  snapshot.SerializeInt(weaponCount);
84  instance.Weapons.Clear();
85 
86  for (int i = 0; i < weaponCount; ++i)
87  {
88  SCR_WeaponLoadoutData weaponData();
89 
90  snapshot.SerializeInt(weaponData.SlotIdx);
91 
92  string resourceName;
93  snapshot.SerializeString(resourceName);
94  weaponData.WeaponPrefab = resourceName;
95 
96  instance.Weapons.Insert(weaponData);
97  }
98 
99  snapshot.SerializeFloat(instance.LoadoutCost);
100 
101  return true;
102  }
103 
104  //------------------------------------------------------------------------------------------------
110  static void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
111  {
112  int clothingCount;
113  snapshot.SerializeBytes(clothingCount, 4);
114  packet.Serialize(clothingCount, 32);
115 
116  for (int i = 0; i < clothingCount; ++i)
117  {
118  snapshot.EncodeInt(packet);
119  snapshot.EncodeString(packet);
120  }
121 
122  int weaponCount;
123  snapshot.SerializeBytes(weaponCount, 4);
124  packet.Serialize(weaponCount, 32);
125 
126  for (int i = 0; i < weaponCount; ++i)
127  {
128  snapshot.EncodeInt(packet);
129  snapshot.EncodeString(packet);
130  }
131 
132  snapshot.EncodeFloat(packet);
133  }
134 
135  //------------------------------------------------------------------------------------------------
141  static bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
142  {
143  int clothingCount;
144  packet.Serialize(clothingCount, 32);
145  snapshot.SerializeBytes(clothingCount, 4);
146 
147  for (int i = 0; i < clothingCount; ++i)
148  {
149  snapshot.DecodeInt(packet);
150  snapshot.DecodeString(packet);
151  }
152 
153  int weaponCount;
154  packet.Serialize(weaponCount, 32);
155  snapshot.SerializeBytes(weaponCount, 4);
156 
157  for (int i = 0; i < weaponCount; ++i)
158  {
159  snapshot.DecodeInt(packet);
160  snapshot.DecodeString(packet);
161  }
162 
163  snapshot.DecodeFloat(packet);
164 
165  return true;
166  }
167 
168  //------------------------------------------------------------------------------------------------
174  static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx)
175  {
176  Print("Cannot use SCR_PlayerLoadoutData as a property", LogLevel.ERROR);
177  return true;
178  }
179 
180  //------------------------------------------------------------------------------------------------
186  static bool PropCompare(SCR_PlayerLoadoutData instance, SSnapSerializerBase snapshot, ScriptCtx ctx)
187  {
188  Print("Cannot use SCR_PlayerLoadoutData as a property", LogLevel.ERROR);
189  return true;
190  }
191 }
SCR_PlayerLoadoutData
Definition: SCR_PlayerLoadoutData.c:13
SlotIdx
class SCR_WeaponLoadoutData SlotIdx
SCR_WeaponLoadoutData
Definition: SCR_PlayerLoadoutData.c:1
ClothingPrefab
ResourceName ClothingPrefab
Definition: SCR_PlayerLoadoutData.c:10