Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGroupVehicleManager.c
Go to the documentation of this file.
2{
3 protected ref array<ref SCR_AIGroupVehicle> m_aGroupVehicles = {};
4
5 //---------------------------------------------------------------------------------------------------
7 {
8 foreach (SCR_AIGroupVehicle groupVehicle : m_aGroupVehicles)
9 {
10 if (groupVehicle.GetEntity() == vehicleEntity)
11 return groupVehicle;
12 }
13 return null;
14 }
15
16 //---------------------------------------------------------------------------------------------------
18 {
19 foreach (SCR_AIGroupVehicle groupVehicle : m_aGroupVehicles)
20 {
21 if (groupVehicle.GetVehicleUsageComponent() == vehicleUsageComp)
22 return groupVehicle;
23 }
24 return null;
25 }
26
27 //---------------------------------------------------------------------------------------------------
29 {
30 foreach (SCR_AIGroupVehicle groupVehicle : m_aGroupVehicles)
31 {
32 if (groupVehicle.GetSubgroupHandleId() == vehicleHandlerId)
33 return groupVehicle;
34 }
35 return null;
36 }
37
38 //---------------------------------------------------------------------------------------------------
39 void GetAllVehicles(array<ref SCR_AIGroupVehicle> outAllVehicles)
40 {
41 outAllVehicles.Clear();
42 foreach(auto groupVehicle : m_aGroupVehicles)
43 outAllVehicles.Insert(groupVehicle);
44 }
45
46 //---------------------------------------------------------------------------------------------------
47 void GetAllVehicleEntities(array<IEntity> outAllVehicles)
48 {
49 outAllVehicles.Clear();
50 foreach(SCR_AIGroupVehicle groupVehicle : m_aGroupVehicles)
51 outAllVehicles.Insert(groupVehicle.GetEntity());
52 }
53
54 //---------------------------------------------------------------------------------------------------
56 {
57 return m_aGroupVehicles.Count();
58 }
59
60 //---------------------------------------------------------------------------------------------------
62 {
63 SCR_AIGroupVehicle groupVehicle = FindVehicle(vehicleUsageComp);
64 if (groupVehicle)
65 return groupVehicle;
66
67 SCR_AIGroupVehicle newGroupVehicle = new SCR_AIGroupVehicle(vehicleUsageComp);
68 m_aGroupVehicles.Insert(newGroupVehicle);
69
70 return newGroupVehicle;
71 }
72
73 //---------------------------------------------------------------------------------------------------
74 bool RemoveVehicle(notnull SCR_AIVehicleUsageComponent vehicleUsageComp)
75 {
76 foreach (int index, SCR_AIGroupVehicle groupVehicle : m_aGroupVehicles)
77 {
78 if (groupVehicle.GetVehicleUsageComponent() == vehicleUsageComp)
79 {
80 m_aGroupVehicles.Remove(index);
81 return true;
82 }
83 }
84 return false;
85 }
86
87 //---------------------------------------------------------------------------------------------------
92 void OnAgentRemoved(notnull AIAgent removedAgent, notnull SCR_AIGroup agentFormerGroup)
93 {
94 // Note: removedAgent is not the group member anymore
95 ChimeraCharacter agentEntity = ChimeraCharacter.Cast(removedAgent.GetControlledEntity());
96 if (!agentEntity || !agentEntity.IsInVehicle())
97 return;
98
99 CompartmentAccessComponent compAcc = agentEntity.GetCompartmentAccessComponent();
100 if (!compAcc)
101 return;
102
103 IEntity vehicleOfAgent = compAcc.GetVehicleIn(agentEntity);
104 if (!vehicleOfAgent)
105 return;
106
108 if (!usage)
109 return;
110
111 if (!usage.IsOccupiedByGroup(agentFormerGroup))
112 RemoveVehicle(usage);
113 }
114};
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
proto external Managed FindComponent(typename typeName)
This class is used for keeping track of vehicles assigned to group.
SCR_AIGroupVehicle FindVehicle(IEntity vehicleEntity)
SCR_AIGroupVehicle TryAddVehicle(notnull SCR_AIVehicleUsageComponent vehicleUsageComp)
ref array< ref SCR_AIGroupVehicle > m_aGroupVehicles
void GetAllVehicles(array< ref SCR_AIGroupVehicle > outAllVehicles)
void OnAgentRemoved(notnull AIAgent removedAgent, notnull SCR_AIGroup agentFormerGroup)
bool RemoveVehicle(notnull SCR_AIVehicleUsageComponent vehicleUsageComp)
SCR_AIGroupVehicle FindVehicleBySubgroupId(int vehicleHandlerId)
void GetAllVehicleEntities(array< IEntity > outAllVehicles)
SCR_AIGroupVehicle FindVehicle(SCR_AIVehicleUsageComponent vehicleUsageComp)
bool IsOccupiedByGroup(notnull SCR_AIGroup aiGroup)