Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ArsenalComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 const SCR_ArsenalComponent arsenal = SCR_ArsenalComponent.Cast(component);
13 const BaseContainer source = arsenal.GetComponentSource(owner);
14
15 const bool enabled = arsenal.IsArsenalEnabled();
16 bool enabledDefault = true;
17 if (source)
18 source.Get("m_bArsenalEnabled", enabledDefault);
19
20 const SCR_EArsenalSaveType saveType = arsenal.GetArsenalSaveType();
21 SCR_EArsenalSaveType saveTypeDefault = 0;
22 if (source)
23 source.Get("m_eArsenalSaveType", saveTypeDefault);
24
25 const SCR_EArsenalItemType supportedItemTypes = arsenal.GetSupportedArsenalItemTypes();
26 SCR_EArsenalItemType supportedItemTypesDefault = 0;
27 if (source)
28 source.Get("m_eSupportedArsenalItemTypes", supportedItemTypesDefault);
29
30 const SCR_EArsenalItemMode supportedItemModes = arsenal.GetSupportedArsenalItemModes();
31 SCR_EArsenalItemMode supportedItemModesDefault = 0;
32 if (source)
33 source.Get("m_eSupportedArsenalItemModes", supportedItemModesDefault);
34
35 if (enabled == enabledDefault &&
36 saveType == saveTypeDefault &&
37 supportedItemTypes == supportedItemTypesDefault &&
38 supportedItemModes == supportedItemModesDefault)
39 return ESerializeResult.DEFAULT;
40
41 context.WriteValue("version", 1);
42 context.WriteDefault(enabled, enabledDefault);
43 context.WriteDefault(saveType, saveTypeDefault);
44 context.WriteDefault(supportedItemTypes, supportedItemTypesDefault);
45 context.WriteDefault(supportedItemModes, supportedItemModesDefault);
46 return ESerializeResult.OK;
47 }
48
49 //------------------------------------------------------------------------------------------------
50 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
51 {
52 auto arsenal = SCR_ArsenalComponent.Cast(component);
53
54 int version;
55 context.Read(version);
56
57 bool enabled;
58 if (context.Read(enabled))
59 arsenal.SetArsenalEnabled(enabled);
60
61 SCR_EArsenalSaveType saveType;
62 if (context.Read(saveType))
63 arsenal.SetArsenalSaveType(saveType);
64
65 SCR_EArsenalItemType supportedItemTypes;
66 if (context.Read(supportedItemTypes))
67 arsenal.SetSupportedArsenalItemTypes(supportedItemTypes);
68
69 SCR_EArsenalItemMode supportedItemModes;
70 if (context.Read(supportedItemModes))
71 arsenal.SetSupportedArsenalItemModes(supportedItemModes);
72
73 return true;
74 }
75}
class SCR_PersistentThreatSector GetTargetType()
SCR_EArsenalItemMode
SCR_EArsenalItemType
void SetArsenalEnabled(bool enable, bool isOverwrite=true)
SCR_EArsenalSaveType GetArsenalSaveType()
SCR_EArsenalItemMode GetSupportedArsenalItemModes()
SCR_EArsenalItemType GetSupportedArsenalItemTypes()
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult