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_PlayerControllerSerializer.c
Go to the documentation of this file.
1
class
SCR_PlayerControllerSerializer
:
ScriptedEntitySerializer
2
{
3
[
Attribute
(
"1"
,
desc
:
"Enable if the gamemode allows for posessing another character besides the main player entity."
)]
4
protected
bool
m_bPosessionPossible
;
5
6
//------------------------------------------------------------------------------------------------
7
override
static
typename
GetTargetType
()
8
{
9
return
SCR_PlayerController
;
10
}
11
12
//------------------------------------------------------------------------------------------------
13
override
protected
ESerializeResult
Serialize
(notnull
IEntity
entity, notnull
SaveContext
context)
14
{
15
const
SCR_PlayerController
playerController =
SCR_PlayerController
.Cast(entity);
16
const
UUID
playerEntity = GetSystem().GetId(playerController.
GetMainEntity
());
17
UUID
currentEntity = GetSystem().GetId(playerController.GetControlledEntity());
18
if
(currentEntity.IsNull())
19
currentEntity = playerEntity;
// In case the currently controlled entity is not persistent
20
21
if
(playerEntity.IsNull() && (!
m_bPosessionPossible
|| currentEntity == playerEntity))
22
return
ESerializeResult
.DEFAULT;
23
24
context.WriteValue(
"version"
, 1);
25
context.WriteDefault(playerEntity,
UUID
.NULL_UUID);
26
27
if
(
m_bPosessionPossible
)
28
context.WriteDefault(currentEntity, playerEntity);
29
30
return
ESerializeResult
.OK;
31
}
32
33
//------------------------------------------------------------------------------------------------
34
override
protected
bool
Deserialize
(notnull
IEntity
entity, notnull
LoadContext
context)
35
{
36
auto
playerController =
SCR_PlayerController
.Cast(entity);
37
38
int
version;
39
context.ReadValue(
"version"
, version);
40
41
UUID
playerEntity;
42
context.ReadDefault(playerEntity,
UUID
.NULL_UUID);
43
44
UUID
currentEntity;
45
if
(
m_bPosessionPossible
)
46
{
47
context.ReadDefault(currentEntity, playerEntity);
48
}
49
else
50
{
51
currentEntity =
UUID
.NULL_UUID;
52
}
53
54
// For vanilla we go through the respawn system to assign main and currently controlled entity to not break existing logic that relies on it.
55
auto
respawnSystem = SCR_RespawnSystemComponent.GetInstance();
56
if
(respawnSystem)
57
{
58
respawnSystem.GetSpawnLogic().StoreControlledEntityIds(playerController, playerEntity, currentEntity);
59
return
true
;
60
}
61
62
// TODO(@langepau): Support for direct loading of player and controlled entity with spawn request on both and WhenAvailable if a mod wants to not have a respawn system.
63
return
false
;
64
}
65
}
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
IEntity
Definition
IEntity.c:13
LoadContext
Definition
LoadContext.c:17
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetMainEntity
IEntity GetMainEntity()
Definition
SCR_PlayerController.c:446
SCR_PlayerControllerSerializer
Definition
SCR_PlayerControllerSerializer.c:2
SCR_PlayerControllerSerializer::Serialize
ESerializeResult Serialize(notnull IEntity entity, notnull SaveContext context)
Definition
SCR_PlayerControllerSerializer.c:13
SCR_PlayerControllerSerializer::Deserialize
bool Deserialize(notnull IEntity entity, notnull LoadContext context)
Definition
SCR_PlayerControllerSerializer.c:34
SCR_PlayerControllerSerializer::GetTargetType
static override GetTargetType()
Definition
SCR_PlayerControllerSerializer.c:7
SCR_PlayerControllerSerializer::m_bPosessionPossible
bool m_bPosessionPossible
Definition
SCR_PlayerControllerSerializer.c:4
SaveContext
Definition
SaveContext.c:17
ScriptedEntitySerializer
Definition
ScriptedEntitySerializer.c:13
UUID
Definition
UUID.c:28
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ESerializeResult
ESerializeResult
Definition
ESerializeResult.c:13
scripts
Game
Plugins
Persistence
System
Serializers
Entities
SCR_PlayerControllerSerializer.c
Generated by
1.17.0