Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_AmbientPatrolSpawnPointComponentSerializer.c
Go to the documentation of this file.
1
class
SCR_AmbientPatrolSpawnPointComponentSerializer
:
ScriptedComponentSerializer
2
{
3
//------------------------------------------------------------------------------------------------
4
override
static
typename
GetTargetType
()
5
{
6
return
SCR_AmbientPatrolSpawnPointComponent;
7
}
8
9
//------------------------------------------------------------------------------------------------
10
override
protected
ESerializeResult
Serialize
(notnull
IEntity
owner, notnull
GenericComponent
component, notnull
SaveContext
context)
11
{
12
auto
ambientPatrol = SCR_AmbientPatrolSpawnPointComponent.Cast(component);
13
auto
world =
ChimeraWorld
.CastFrom(owner.GetWorld());
14
const
WorldTimestamp
currentTime = world.GetServerTimestamp();
15
16
const
bool
spawned = ambientPatrol.GetIsSpawned();
17
const
bool
paused = ambientPatrol.GetIsPaused();
18
const
int
membersAlive = ambientPatrol.GetMembersAlive();
19
20
if
(!spawned && !paused && (membersAlive == -1))
21
return
ESerializeResult
.DEFAULT;
22
23
const
UUID
groupId = GetSystem().GetId(ambientPatrol.GetSpawnedGroup());
24
const
bool
groupActive = ambientPatrol.IsGroupActive();
25
const
UUID
waypointId = GetSystem().GetId(ambientPatrol.GetWaypoint());
26
27
const
WorldTimestamp
despawnTimestamp = ambientPatrol.GetDespawnTimestamp();
28
float
despawnTime = 0;
29
if
(despawnTimestamp)
30
despawnTime = currentTime.DiffSeconds(despawnTimestamp);
31
32
const
WorldTimestamp
respawnTimestamp = ambientPatrol.GetRespawnTimestamp();
33
float
respawnTime = 0;
34
if
(respawnTimestamp)
35
respawnTime = currentTime.DiffSeconds(respawnTimestamp);
36
37
context.WriteValue(
"version"
, 1);
38
context.WriteDefault(spawned,
false
);
39
context.WriteDefault(paused,
false
);
40
context.WriteDefault(groupId,
UUID
.NULL_UUID);
41
context.WriteDefault(groupActive,
false
);
42
context.WriteDefault(membersAlive, -1);
43
context.WriteDefault(waypointId,
UUID
.NULL_UUID);
44
context.WriteDefault(despawnTime, 0.0);
45
context.WriteDefault(respawnTime, 0.0);
46
return
ESerializeResult
.OK;
47
}
48
49
//------------------------------------------------------------------------------------------------
50
override
protected
bool
Deserialize
(notnull
IEntity
owner, notnull
GenericComponent
component, notnull
LoadContext
context)
51
{
52
auto
ambientPatrol = SCR_AmbientPatrolSpawnPointComponent.Cast(component);
53
auto
world =
ChimeraWorld
.CastFrom(owner.GetWorld());
54
const
WorldTimestamp
currentTime = world.GetServerTimestamp();
55
56
int
version;
57
context.Read(version);
58
59
bool
spawned;
60
if
(context.Read(spawned))
61
ambientPatrol.SetIsSpawned(spawned);
62
63
bool
paused;
64
if
(context.Read(paused))
65
ambientPatrol.SetIsPaused(paused);
66
67
UUID
groupId;
68
if
(context.Read(groupId) && !groupId.IsNull())
69
{
70
Tuple1<SCR_AmbientPatrolSpawnPointComponent>
ctx(ambientPatrol);
71
PersistenceWhenAvailableTask
task
(
OnGroupAvailable
, ctx);
72
GetSystem().WhenAvailable(groupId,
task
);
73
}
74
75
bool
groupActive;
76
if
(context.Read(groupActive))
77
{
78
if
(groupActive)
79
{
80
ambientPatrol.ActivateGroup();
81
}
82
else
83
{
84
ambientPatrol.DeactivateGroup();
85
}
86
}
87
88
int
membersAlive;
89
if
(context.Read(membersAlive))
90
ambientPatrol.SetMembersAlive(membersAlive);
91
92
UUID
waypointId;
93
if
(context.Read(waypointId) && !waypointId.IsNull())
94
{
95
Tuple1<SCR_AmbientPatrolSpawnPointComponent>
ctx(ambientPatrol);
96
PersistenceWhenAvailableTask
task
(
OnWaypointAvailable
, ctx);
97
GetSystem().WhenAvailable(waypointId,
task
);
98
}
99
100
float
despawnTime;
101
if
(context.Read(despawnTime))
102
ambientPatrol.SetDespawnTimestamp(currentTime.PlusSeconds(despawnTime));
103
104
float
respawnTime;
105
if
(context.Read(respawnTime))
106
ambientPatrol.SetRespawnTimestamp(currentTime.PlusSeconds(respawnTime));
107
108
return
true
;
109
}
110
111
//------------------------------------------------------------------------------------------------
112
protected
static
void
OnGroupAvailable
(Managed instance,
PersistenceDeferredDeserializeTask
task
,
bool
expired, Managed context)
113
{
114
auto
group =
SCR_AIGroup
.Cast(instance);
115
if
(!group)
116
return
;
117
118
auto
ctx =
Tuple1<SCR_AmbientPatrolSpawnPointComponent>
.Cast(context);
119
if
(ctx.param1)
120
ctx.param1.SetspawnedGroup(group);
121
}
122
123
//------------------------------------------------------------------------------------------------
124
protected
static
void
OnWaypointAvailable
(Managed instance,
PersistenceDeferredDeserializeTask
task
,
bool
expired, Managed context)
125
{
126
auto
wp =
SCR_AIWaypoint
.Cast(instance);
127
if
(!wp)
128
return
;
129
130
auto
ctx =
Tuple1<SCR_AmbientPatrolSpawnPointComponent>
.Cast(context);
131
if
(ctx.param1)
132
ctx.param1.SetWaypoint(wp);
133
}
134
}
GetTargetType
class SCR_PersistentThreatSector GetTargetType()
Definition
AIControlComponentSerializer.c:12
task
from task
Definition
SCR_TaskNotificationConfigs.c:12
ChimeraWorld
Definition
ChimeraWorld.c:13
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
LoadContext
Definition
LoadContext.c:17
PersistenceDeferredDeserializeTask
Definition
PersistenceDeferredDeserializeTask.c:13
PersistenceWhenAvailableTask
Definition
PersistenceWhenAvailableTask.c:14
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIWaypoint
Definition
SCR_AIWaypoint.c:6
SCR_AmbientPatrolSpawnPointComponentSerializer
Definition
SCR_AmbientPatrolSpawnPointComponentSerializer.c:2
SCR_AmbientPatrolSpawnPointComponentSerializer::Serialize
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
Definition
SCR_AmbientPatrolSpawnPointComponentSerializer.c:10
SCR_AmbientPatrolSpawnPointComponentSerializer::OnGroupAvailable
static void OnGroupAvailable(Managed instance, PersistenceDeferredDeserializeTask task, bool expired, Managed context)
Definition
SCR_AmbientPatrolSpawnPointComponentSerializer.c:112
SCR_AmbientPatrolSpawnPointComponentSerializer::OnWaypointAvailable
static void OnWaypointAvailable(Managed instance, PersistenceDeferredDeserializeTask task, bool expired, Managed context)
Definition
SCR_AmbientPatrolSpawnPointComponentSerializer.c:124
SCR_AmbientPatrolSpawnPointComponentSerializer::Deserialize
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
Definition
SCR_AmbientPatrolSpawnPointComponentSerializer.c:50
SaveContext
Definition
SaveContext.c:17
ScriptedComponentSerializer
Definition
ScriptedComponentSerializer.c:13
UUID
Definition
UUID.c:28
WorldTimestamp
Definition
WorldTimestamp.c:26
ESerializeResult
ESerializeResult
Definition
ESerializeResult.c:13
Tuple1
void Tuple1(T1 p1)
Definition
tuple.c:37
scripts
Game
Plugins
Persistence
System
Serializers
Components
GameMode
Conflict
SCR_AmbientPatrolSpawnPointComponentSerializer.c
Generated by
1.17.0