Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGroupUtilityComponentSerializer.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_AIGroupUtilityComponent aiGroupUtility = SCR_AIGroupUtilityComponent.Cast(component);
13
14 const float autonomousDistance = aiGroupUtility.GetMaxAutonomousDistance();
15 const EAIGroupCombatMode combatMode = aiGroupUtility.GetCombatModeExternal();
16
17 if (autonomousDistance == SCR_AIGroupUtilityComponent.AUTONOMOUS_DISTANCE_MAX_DEFAULT &&
18 combatMode == EAIGroupCombatMode.FIRE_AT_WILL)
19 {
20 return ESerializeResult.DEFAULT;
21 }
22
23 context.WriteValue("version", 1);
24 context.WriteDefault(autonomousDistance, SCR_AIGroupUtilityComponent.AUTONOMOUS_DISTANCE_MAX_DEFAULT);
25 context.WriteDefault(combatMode, EAIGroupCombatMode.FIRE_AT_WILL);
26 return ESerializeResult.OK;
27 }
28
29 //------------------------------------------------------------------------------------------------
30 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
31 {
32 auto aiGroupUtility = SCR_AIGroupUtilityComponent.Cast(component);
33
34 int version;
35 context.Read(version);
36
37 float autonomousDistance;
38 context.ReadDefault(autonomousDistance, SCR_AIGroupUtilityComponent.AUTONOMOUS_DISTANCE_MAX_DEFAULT);
39
40 EAIGroupCombatMode combatMode;
41 context.ReadDefault(combatMode, EAIGroupCombatMode.FIRE_AT_WILL);
42
43 if (autonomousDistance != SCR_AIGroupUtilityComponent.AUTONOMOUS_DISTANCE_MAX_DEFAULT)
44 aiGroupUtility.SetMaxAutonomousDistance(autonomousDistance);
45
46 if (combatMode != EAIGroupCombatMode.FIRE_AT_WILL)
47 aiGroupUtility.SetCombatMode(combatMode);
48
49 return true;
50 }
51}
class SCR_PersistentThreatSector GetTargetType()
EAIGroupCombatMode GetCombatModeExternal()
See SetCombatMode.
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult