Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_VehicleFactionAffiliationComponent.c
Go to the documentation of this file.
1
class
SCR_VehicleFactionAffiliationComponentClass
:
SCR_FactionAffiliationComponentClass
2
{
3
4
};
5
6
class
SCR_VehicleFactionAffiliationComponent
:
SCR_FactionAffiliationComponent
7
{
8
protected
int
m_iOccupantCount
;
9
protected
int
m_iAliveOccupantCount
;
10
11
//--------------------------------------------------------------------------------------------------------------------------
12
override
event
void
OnPostInit
(
IEntity
owner)
13
{
14
ClearAffiliatedFaction
();
15
}
16
17
//--------------------------------------------------------------------------------------------------------------------------
19
bool
IsVehicleOccupied
()
20
{
21
return
m_iOccupantCount
> 0;
22
}
23
24
//--------------------------------------------------------------------------------------------------------------------------
26
bool
IsVehicleActive
()
27
{
28
return
m_iAliveOccupantCount
> 0;
29
}
30
31
//--------------------------------------------------------------------------------------------------------------------------
32
override
protected
void
OnCompartmentEntered
(
IEntity
vehicle,
IEntity
occupant,
BaseCompartmentSlot
compartment,
bool
move)
33
{
34
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(occupant);
35
if
(!character)
36
return
;
37
38
// Test if the faction of the vehicle and the newly mounted passenger match.
39
// If not, we'll eject the new passenger
40
Faction
characterFaction = character.GetFaction();
41
Faction
vehicleFaction =
GetAffiliatedFaction
();
42
43
if
(characterFaction && !vehicleFaction)
44
{
45
// No faction on the vehicle, just set the occupant's faction
46
SetAffiliatedFaction
(characterFaction);
47
}
48
else
if
(characterFaction && !characterFaction.IsFactionFriendly(
GetAffiliatedFaction
()))
49
{
50
// There is vehicleFaction set. Only overwrite it when there are no further occupants
51
if
(!
IsVehicleOccupied
())
52
{
53
SetAffiliatedFaction
(characterFaction);
54
}
55
};
56
57
if
(vehicleFaction && characterFaction && characterFaction.IsFactionEnemy(vehicleFaction) && !characterFaction.IsFactionEnemy(characterFaction))
58
{
59
CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
60
compartmentAccess.GetOutVehicle(
EGetOutType
.TELEPORT, -1,
ECloseDoorAfterActions
.INVALID,
false
);
61
// Drop through, we need to account for this new occupant still
62
};
63
64
// Make us count.
65
m_iOccupantCount
++;
66
UpdateOccupantsCount
();
67
}
68
69
70
//--------------------------------------------------------------------------------------------------------------------------
71
override
protected
void
OnCompartmentLeft
(
IEntity
vehicle,
IEntity
occupant,
BaseCompartmentSlot
compartment,
bool
move)
72
{
73
if
(move)
// moving only between compartments
74
return
;
75
76
m_iOccupantCount
--;
77
UpdateOccupantsCount
(occupant);
78
}
79
80
//--------------------------------------------------------------------------------------------------------------------------
81
void
UpdateOccupantsCount
(
IEntity
ignoreOccupant = null)
82
{
83
SCR_BaseCompartmentManagerComponent baseCompMan = SCR_BaseCompartmentManagerComponent.Cast(
GetOwner
().FindComponent(SCR_BaseCompartmentManagerComponent));
84
if
(!baseCompMan)
85
return
;
86
87
array<IEntity> occupants = {};
88
baseCompMan.GetOccupants(occupants);
89
int
aliveOccupants;
90
int
allOccupants;
91
ECharacterLifeState
state;
92
foreach
(
IEntity
occupant : occupants)
93
{
94
if
((ignoreOccupant == occupant))
95
continue
;
96
97
ChimeraCharacter
character =
ChimeraCharacter
.Cast(occupant);
98
if
(!character)
99
continue
;
100
101
CharacterControllerComponent contr = character.GetCharacterController();
102
if
(!contr)
103
continue
;
104
105
state = contr.GetLifeState();
106
if
(state ==
ECharacterLifeState
.ALIVE)
107
aliveOccupants++;
108
109
if
(state !=
ECharacterLifeState
.DEAD)
110
allOccupants++;
111
}
112
113
m_iAliveOccupantCount
= aliveOccupants;
114
m_iOccupantCount
= allOccupants;
115
116
if
(
m_iOccupantCount
< 1)
117
ClearAffiliatedFaction
();
118
}
119
120
//--------------------------------------------------------------------------------------------------------------------------
121
void
OnOccupantLifeStateChanged
(
ECharacterLifeState
previousLifeState,
ECharacterLifeState
newLifeState)
122
{
123
UpdateOccupantsCount
();
124
}
125
};
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
ChimeraCharacter
Definition
ChimeraCharacter.c:13
Faction
Definition
Faction.c:13
IEntity
Definition
IEntity.c:13
SCR_FactionAffiliationComponentClass
Definition
SCR_FactionAffiliationComponent.c:2
SCR_FactionAffiliationComponent
Definition
SCR_FactionAffiliationComponent.c:11
SCR_FactionAffiliationComponent::ClearAffiliatedFaction
void ClearAffiliatedFaction()
Definition
SCR_FactionAffiliationComponent.c:29
SCR_VehicleFactionAffiliationComponentClass
Definition
SCR_VehicleFactionAffiliationComponent.c:2
SCR_VehicleFactionAffiliationComponent
Definition
SCR_VehicleFactionAffiliationComponent.c:7
SCR_VehicleFactionAffiliationComponent::OnOccupantLifeStateChanged
void OnOccupantLifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
Definition
SCR_VehicleFactionAffiliationComponent.c:121
SCR_VehicleFactionAffiliationComponent::UpdateOccupantsCount
void UpdateOccupantsCount(IEntity ignoreOccupant=null)
Definition
SCR_VehicleFactionAffiliationComponent.c:81
SCR_VehicleFactionAffiliationComponent::OnPostInit
override event void OnPostInit(IEntity owner)
Definition
SCR_VehicleFactionAffiliationComponent.c:12
SCR_VehicleFactionAffiliationComponent::OnCompartmentEntered
void OnCompartmentEntered(IEntity vehicle, IEntity occupant, BaseCompartmentSlot compartment, bool move)
Definition
SCR_VehicleFactionAffiliationComponent.c:32
SCR_VehicleFactionAffiliationComponent::m_iOccupantCount
int m_iOccupantCount
Definition
SCR_VehicleFactionAffiliationComponent.c:8
SCR_VehicleFactionAffiliationComponent::OnCompartmentLeft
void OnCompartmentLeft(IEntity vehicle, IEntity occupant, BaseCompartmentSlot compartment, bool move)
Definition
SCR_VehicleFactionAffiliationComponent.c:71
SCR_VehicleFactionAffiliationComponent::IsVehicleOccupied
bool IsVehicleOccupied()
Check if there are any occupants regardless of life state.
Definition
SCR_VehicleFactionAffiliationComponent.c:19
SCR_VehicleFactionAffiliationComponent::m_iAliveOccupantCount
int m_iAliveOccupantCount
Definition
SCR_VehicleFactionAffiliationComponent.c:9
SCR_VehicleFactionAffiliationComponent::IsVehicleActive
bool IsVehicleActive()
Check if there are any conscious and alive occupants among the occupants.
Definition
SCR_VehicleFactionAffiliationComponent.c:26
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition
SCR_FuelNode.c:128
ECharacterLifeState
ECharacterLifeState
Definition
ECharacterLifeState.c:13
SetAffiliatedFaction
proto external void SetAffiliatedFaction(Faction faction)
GetAffiliatedFaction
SCR_CampaignFaction GetAffiliatedFaction()
Returns the affiliated faction or null if none.
Definition
SCR_CampaignMobileAssemblyComponent.c:78
ECloseDoorAfterActions
ECloseDoorAfterActions
Definition
ECloseDoorAfterActions.c:13
EGetOutType
EGetOutType
Definition
EGetOutType.c:13
scripts
Game
Vehicle
SCR_VehicleFactionAffiliationComponent.c
Generated by
1.17.0