Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RestrictedDeployableSpawnPointComponentSerializer.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 {
13 const BaseContainer source = component.GetComponentSource(owner);
14
15 const bool deployed = spawnPoint.IsDeployed();
16
17 const SCR_ESpawnPointBudgetType budgetType = spawnPoint.GetBudgetType();
18 SCR_ESpawnPointBudgetType budgetTypeDefault = SCR_ESpawnPointBudgetType.SUPPLIES;
19 if (source)
20 source.Get("m_eRespawnBudgetType", budgetTypeDefault);
21
22 const float supplies = spawnPoint.GetSuppliesValue();
23 float suppliesDefault = 100;
24 if (source)
25 source.Get("m_fSuppliesValue", suppliesDefault);
26
27 const int respawnCount = spawnPoint.GetRespawnCount();
28 const int respawnCountDefault = 0;
29
30 const int spawnTicketsMax = spawnPoint.GetMaxRespawns();
31 float spawnTicketsMaxDefault = 5;
32 if (source)
33 source.Get("m_iMaxRespawns", spawnTicketsMaxDefault);
34
35 const int allowCustomLoadout = spawnPoint.IsCustomLoadoutsAllowed();
36 bool allowCustomLoadoutDefault = false;
37 if (source)
38 source.Get("m_bAllowCustomLoadouts", allowCustomLoadoutDefault);
39
40 if (deployed == false &&
41 budgetType == budgetTypeDefault &&
42 supplies == suppliesDefault &&
43 respawnCount == respawnCountDefault &&
44 spawnTicketsMax == spawnTicketsMaxDefault &&
45 allowCustomLoadout == allowCustomLoadoutDefault)
46 {
47 return ESerializeResult.DEFAULT;
48 }
49
50 UUID groupId = UUID.NULL_UUID;
51 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
52 if (groupsManager)
53 groupId = GetSystem().GetId(groupsManager.FindGroup(spawnPoint.GetGroupID()));
54
55 const UUID ownerId = GetSystem().GetId(GetGame().GetPlayerManager().GetPlayerController(spawnPoint.GetItemOwnerID()));
56
57 context.WriteValue("version", 1);
58 context.WriteDefault(deployed, false);
59 context.WriteDefault(supplies, suppliesDefault);
60 context.WriteDefault(respawnCount, respawnCountDefault);
61 context.WriteDefault(spawnTicketsMax, spawnTicketsMax);
62 context.WriteDefault(allowCustomLoadout, allowCustomLoadoutDefault);
63 context.WriteDefault(groupId, UUID.NULL_UUID);
64 context.WriteDefault(ownerId, UUID.NULL_UUID);
65 return ESerializeResult.OK;
66 }
67
68 //------------------------------------------------------------------------------------------------
69 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
70 {
72
73 int version;
74 context.Read(version);
75
76 bool deployed;
77 context.ReadDefault(deployed, false);
78
79 float supplies;
80 if (context.Read(supplies))
81 spawnPoint.SetSuppliesValue(supplies, false);
82
83 int respawnCount;
84 if (context.Read(respawnCount))
85 spawnPoint.SetRespawnCount(respawnCount);
86
87 int spawnTicketsMax;
88 if (context.Read(spawnTicketsMax))
89 spawnPoint.SetRespawnCount(spawnTicketsMax);
90
91 bool allowCustomLoadout;
92 if (context.Read(allowCustomLoadout))
93 spawnPoint.SetSpawningWithLoadout(allowCustomLoadout);
94
95 UUID groupId;
96 context.ReadDefault(groupId, UUID.NULL_UUID);
97
98 UUID ownerId;
99 if (context.Read(ownerId))
100 {
103 GetSystem().WhenAvailable(ownerId, task);
104 }
105
106 if (deployed && !groupId.IsNull())
107 {
110 GetSystem().WhenAvailable(groupId, task);
111 }
112
113 return true;
114 }
115
116 //------------------------------------------------------------------------------------------------
117 protected static void OnGroupAvailable(Managed instance, PersistenceDeferredDeserializeTask task, bool expired, Managed context)
118 {
119 auto group = SCR_AIGroup.Cast(instance);
120 if (!group)
121 return;
122
124 if (ctx.param1)
125 ctx.param1.DeployByGroup(group, reload: true);
126 }
127
128 //------------------------------------------------------------------------------------------------
129 protected static void OnOwnerAvailable(Managed instance, PersistenceDeferredDeserializeTask task, bool expired, Managed context)
130 {
131 auto owner = PlayerController.Cast(instance);
132 if (!owner)
133 return;
134
136 if (ctx.param1)
137 ctx.param1.SetItemOwner(owner.GetPlayerId());
138 }
139}
class SCR_PersistentThreatSector GetTargetType()
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Deployable spawn point with configurable conditions.
void SetSuppliesValue(float value, bool refreshDeployedContainer=true)
static void OnOwnerAvailable(Managed instance, PersistenceDeferredDeserializeTask task, bool expired, Managed context)
static void OnGroupAvailable(Managed instance, PersistenceDeferredDeserializeTask task, bool expired, Managed context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
Definition UUID.c:28
proto external PlayerController GetPlayerController()
ESerializeResult
void Tuple1(T1 p1)
Definition tuple.c:37