Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayerControllerSerializer.c
Go to the documentation of this file.
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 {
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
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;
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}
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ESerializeResult Serialize(notnull IEntity entity, notnull SaveContext context)
bool Deserialize(notnull IEntity entity, notnull LoadContext context)
Definition UUID.c:28
SCR_FieldOfViewSettings Attribute
ESerializeResult