Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AICombatComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
6 return SCR_AICombatComponent;
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 const SCR_AICombatComponent aiCombat = SCR_AICombatComponent.Cast(component);
13
14 const EAISkill skill = aiCombat.GetAISkill();
15 const EAISkill skillDefault = aiCombat.GetAISkillDefault();
16 const float perceptionFactor = aiCombat.GetPerceptionFactor();
17
18 if (skill == skillDefault && float.AlmostEqual(perceptionFactor, 1.0))
19 return ESerializeResult.DEFAULT;
20
21 context.WriteValue("version", 1);
22 context.WriteDefault(skill, skillDefault);
23 context.WriteDefault(perceptionFactor, 1.0);
24 return ESerializeResult.OK;
25 }
26
27 //------------------------------------------------------------------------------------------------
28 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
29 {
30 auto aiCombat = SCR_AICombatComponent.Cast(component);
31
32 int version;
33 context.Read(version);
34
35 const EAISkill skillDefault = aiCombat.GetAISkillDefault();
36 EAISkill skill;
37 context.ReadDefault(skill, skillDefault);
38
39 float perceptionFactor;
40 context.ReadDefault(perceptionFactor, 1.0);
41
42 if (skill != skillDefault)
43 aiCombat.SetAISkill(skill);
44
45 if (!float.AlmostEqual(perceptionFactor, 1.0))
46 aiCombat.SetPerceptionFactor(perceptionFactor);
47
48 return true;
49 }
50}
class SCR_PersistentThreatSector GetTargetType()
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult