Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CharacterFactionAffiliationComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
6 return FactionAffiliationComponent;
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 const FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(component);
13
14 const FactionKey factionKey = factionAffiliation.GetAffiliatedFactionKey();
15 const FactionKey defaultFactionKey = factionAffiliation.GetDefaultFactionKey();
16
17 if (factionKey == defaultFactionKey)
18 return ESerializeResult.DEFAULT;
19
20 context.WriteValue("version", 1);
21 context.Write(factionKey);
22 return ESerializeResult.OK;
23 }
24
25 //------------------------------------------------------------------------------------------------
26 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
27 {
28 auto factionAffiliation = FactionAffiliationComponent.Cast(component);
29
30 int version;
31 context.Read(version);
32
33 FactionKey factionKey;
34 context.Read(factionKey);
35
36 const FactionKey currentFactionKey = factionAffiliation.GetAffiliatedFactionKey();
37 if (factionKey != currentFactionKey)
38 {
39 FactionManager factionManager = GetGame().GetFactionManager();
40 if (factionManager)
41 {
42 const Faction faction = factionManager.GetFactionByKey(factionKey);
43 factionAffiliation.SetAffiliatedFaction(faction);
44 }
45 }
46
47 return true;
48 }
49}
class SCR_PersistentThreatSector GetTargetType()
ArmaReforgerScripted GetGame()
Definition game.c:1398
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult