Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CallsignBaseComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 const SCR_CallsignBaseComponent callsign = SCR_CallsignBaseComponent.Cast(component);
13
14 auto group = SCR_AIGroup.Cast(owner);
15
16 int companyIndex, platoonIndex, squadIndex, characterNumber;
17 ERoleCallsign characterRole;
18
19 if ((group && group.GetAgentsCount() == 0) || !callsign.GetCallsignIndexes(companyIndex, platoonIndex, squadIndex, characterNumber, characterRole))
20 return ESerializeResult.DEFAULT;
21
22 context.WriteValue("version", 1);
23 context.WriteDefault(companyIndex, -1);
24 context.WriteDefault(platoonIndex, -1);
25 context.WriteDefault(squadIndex, -1);
26
27 /*
28 if (!group)
29 {
30 context.WriteDefault(characterNumber, -1);
31 context.WriteDefault(characterRole, ERoleCallsign.NONE);
32 }
33 */
34
35 return ESerializeResult.OK;
36 }
37
38 //------------------------------------------------------------------------------------------------
39 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
40 {
42
43 int version;
44 context.ReadValue("version", version);
45
46 int companyIndex, platoonIndex, squadIndex;
47 context.ReadDefault(companyIndex, -1);
48 context.ReadDefault(platoonIndex, -1);
49 context.ReadDefault(squadIndex, -1);
50
51 auto group = SCR_AIGroup.Cast(owner);
52 if (group)
53 {
54 auto callsignManager = SCR_CallsignManagerComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_CallsignManagerComponent));
55 callsignManager.RemoveAvailableGroupCallsign(group.GetFaction(), companyIndex, platoonIndex, squadIndex);
56
57 auto groupCallsign = SCR_CallsignGroupComponent.Cast(callsign);
58 if (!groupCallsign)
59 return false;
60
61 groupCallsign.DoAssignCallsign(companyIndex, platoonIndex, squadIndex);
62 }
63
64 // TODO(@langepau): If desired to remember individual callsigns we need to make sure default group inits etc do not run after and reset it again :)
65 // Also we might want to store member callsigns on the group data still as callsigns make no sense on individual chars without groups?
66 /*
67 else
68 {
69 int characterNumber;
70 context.ReadDefault(characterNumber, -1);
71
72 ERoleCallsign characterRole;
73 context.ReadDefault(characterRole, ERoleCallsign.NONE);
74
75 auto factionAffiliation = FactionAffiliationComponent.Cast(owner.FindComponent(FactionAffiliationComponent));
76 if (!factionAffiliation)
77 return false;
78
79 auto charCallsign = SCR_CallsignCharacterComponent.Cast(callsign);
80 if (!charCallsign)
81 return false;
82
83 charCallsign.AssignCharacterCallsign(factionAffiliation.GetAffiliatedFaction(), companyIndex, platoonIndex, squadIndex, characterNumber, characterRole, charCallsign.GetIsCharacterAloneInGroup());
84 }
85 */
86
87 return true;
88 }
89}
class SCR_PersistentThreatSector GetTargetType()
ERoleCallsign
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
Component of assigning and storing squad names.
bool GetCallsignIndexes(out int companyIndex, out int platoonIndex, out int squadIndex, out int characterNumber=-1, out ERoleCallsign characterRole=ERoleCallsign.NONE)
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
void RemoveAvailableGroupCallsign(Faction faction, int companyIndex, int platoonIndex, int squadIndex)
ESerializeResult