Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIWaypointArtillerySupportSerializer.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 entity, notnull SaveContext context)
11 {
12 const SCR_AIWaypointArtillerySupport artillerySupport = SCR_AIWaypointArtillerySupport.Cast(entity);
13 BaseContainer source;
14 if (artillerySupport.GetPrefabData())
15 source = artillerySupport.GetPrefabData().GetPrefab();
16
17 const bool active = artillerySupport.IsActive();
18 bool activeDefault = true;
19 if (source)
20 source.Get("m_bActive", activeDefault);
21
22 const int targetShotCount = artillerySupport.GetTargetShotCount();
23 int targetShotCountDefault = true;
24 if (source)
25 source.Get("m_iTargetShotCount", targetShotCountDefault);
26
27 const SCR_EAIArtilleryAmmoType ammoType = artillerySupport.GetAmmoType();
28 SCR_EAIArtilleryAmmoType ammoTypeDefault = SCR_EAIArtilleryAmmoType.HIGH_EXPLOSIVE;
29 if (source)
30 source.Get("m_eAmmoType", ammoTypeDefault);
31
32 context.StartObject("base");
33 const ESerializeResult baseResult = super.Serialize(entity, context);
34 context.EndObject();
35 if (baseResult == ESerializeResult.ERROR)
36 return baseResult;
37
38 if (baseResult == ESerializeResult.DEFAULT &&
39 active == activeDefault &&
40 targetShotCount == targetShotCountDefault &&
41 ammoType == ammoTypeDefault)
42 {
43 return baseResult;
44 }
45
46 context.WriteValue("version", 1);
47 context.WriteDefault(active, activeDefault);
48 context.WriteDefault(targetShotCount, targetShotCountDefault);
49 context.WriteDefault(ammoType, ammoTypeDefault);
50 return ESerializeResult.OK;
51 }
52
53 //------------------------------------------------------------------------------------------------
54 override protected bool Deserialize(notnull IEntity entity, notnull LoadContext context)
55 {
56 auto artillerySupport = SCR_AIWaypointArtillerySupport.Cast(entity);
57
58 if (context.DoesObjectExist("base"))
59 {
60 if (!context.StartObject("base") ||
61 !super.Deserialize(entity, context) ||
62 !context.EndObject())
63 {
64 return false;
65 }
66 }
67
68 int version;
69 context.Read(version);
70
71 bool active;
72 if (context.Read(active))
73 artillerySupport.SetActive(active);
74
75 int targetShotCount;
76 if (context.Read(targetShotCount))
77 artillerySupport.SetTargetShotCount(targetShotCount);
78
80 if (context.Read(ammoType))
81 artillerySupport.SetAmmoType(ammoType);
82
83 return true;
84 }
85}
class SCR_PersistentThreatSector GetTargetType()
void SetActive(bool value, bool invokeEvent=true)
ESerializeResult Serialize(notnull IEntity entity, notnull SaveContext context)
bool Deserialize(notnull IEntity entity, notnull LoadContext context)
ESerializeResult