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_AmbientVehicleSpawnPointComponentSerializer.c
Go to the documentation of this file.
1
class
SCR_AmbientVehicleSpawnPointComponentSerializer
:
ScriptedComponentSerializer
2
{
3
//------------------------------------------------------------------------------------------------
4
override
static
typename
GetTargetType
()
5
{
6
return
SCR_AmbientVehicleSpawnPointComponent;
7
}
8
9
//------------------------------------------------------------------------------------------------
10
override
protected
ESerializeResult
Serialize
(notnull
IEntity
owner, notnull
GenericComponent
component, notnull
SaveContext
context)
11
{
12
auto
ambientVehicle = SCR_AmbientVehicleSpawnPointComponent.Cast(component);
13
auto
world =
ChimeraWorld
.CastFrom(owner.GetWorld());
14
const
WorldTimestamp
currentTime = world.GetServerTimestamp();
15
16
const
bool
depleted = ambientVehicle.GetIsDepleted();
17
const
UUID
vehicleId = GetSystem().GetId(ambientVehicle.GetSpawnedVehicle());
18
19
const
WorldTimestamp
despawnTimestamp = ambientVehicle.GetDespawnTimestamp();
20
float
despawnTime = 0;
21
if
(despawnTimestamp)
22
despawnTime = currentTime.DiffSeconds(despawnTimestamp);
23
24
const
WorldTimestamp
respawnTimestamp = ambientVehicle.GetRespawnTimestamp();
25
float
respawnTime = 0;
26
if
(respawnTimestamp)
27
respawnTime = currentTime.DiffSeconds(respawnTimestamp);
28
29
if
(!depleted &&
30
vehicleId.IsNull() &&
31
float
.AlmostEqual(despawnTime, 0.0) &&
32
float
.AlmostEqual(respawnTime, 0.0))
33
{
34
return
ESerializeResult
.DEFAULT;
35
}
36
37
context.WriteValue(
"version"
, 1);
38
context.WriteDefault(depleted,
false
);
39
context.WriteDefault(vehicleId,
UUID
.NULL_UUID);
40
context.WriteDefault(despawnTime, 0.0);
41
context.WriteDefault(respawnTime, 0.0);
42
return
ESerializeResult
.OK;
43
}
44
45
//------------------------------------------------------------------------------------------------
46
override
protected
bool
Deserialize
(notnull
IEntity
owner, notnull
GenericComponent
component, notnull
LoadContext
context)
47
{
48
auto
ambientVehicle = SCR_AmbientVehicleSpawnPointComponent.Cast(component);
49
auto
world =
ChimeraWorld
.CastFrom(owner.GetWorld());
50
const
WorldTimestamp
currentTime = world.GetServerTimestamp();
51
52
int
version;
53
context.Read(version);
54
55
bool
depleted;
56
if
(context.Read(depleted))
57
ambientVehicle.SetIsDepleted(depleted);
58
59
UUID
vehicleId;
60
if
(context.Read(vehicleId) && !vehicleId.IsNull())
61
{
62
Tuple1<SCR_AmbientVehicleSpawnPointComponent>
ctx(ambientVehicle);
63
PersistenceWhenAvailableTask
task
(
OnVehicleAvailable
, ctx);
64
GetSystem().WhenAvailable(vehicleId,
task
);
65
}
66
67
float
despawnTime;
68
if
(context.Read(despawnTime))
69
ambientVehicle.SetDespawnTimestamp(currentTime.PlusSeconds(despawnTime));
70
71
float
respawnTime;
72
if
(context.Read(respawnTime))
73
ambientVehicle.SetRespawnTimestamp(currentTime.PlusSeconds(respawnTime));
74
75
return
true
;
76
}
77
78
//------------------------------------------------------------------------------------------------
79
protected
static
void
OnVehicleAvailable
(Managed instance,
PersistenceDeferredDeserializeTask
task
,
bool
expired, Managed context)
80
{
81
auto
vehicle =
Vehicle
.Cast(instance);
82
if
(!vehicle)
83
return
;
84
85
auto
ctx =
Tuple1<SCR_AmbientVehicleSpawnPointComponent>
.Cast(context);
86
if
(ctx.param1)
87
ctx.param1.SetSpawnedVehicle(vehicle);
88
}
89
}
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_AmbientVehicleSpawnPointComponentSerializer
Definition
SCR_AmbientVehicleSpawnPointComponentSerializer.c:2
SCR_AmbientVehicleSpawnPointComponentSerializer::OnVehicleAvailable
static void OnVehicleAvailable(Managed instance, PersistenceDeferredDeserializeTask task, bool expired, Managed context)
Definition
SCR_AmbientVehicleSpawnPointComponentSerializer.c:79
SCR_AmbientVehicleSpawnPointComponentSerializer::Deserialize
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
Definition
SCR_AmbientVehicleSpawnPointComponentSerializer.c:46
SCR_AmbientVehicleSpawnPointComponentSerializer::Serialize
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
Definition
SCR_AmbientVehicleSpawnPointComponentSerializer.c:10
SaveContext
Definition
SaveContext.c:17
ScriptedComponentSerializer
Definition
ScriptedComponentSerializer.c:13
UUID
Definition
UUID.c:28
WorldTimestamp
Definition
WorldTimestamp.c:26
Vehicle
enum EPhysicsLayerPresets Vehicle
Definition
gameLib.c:24
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_AmbientVehicleSpawnPointComponentSerializer.c
Generated by
1.17.0