8 protected int m_iOccupantCount;
9 protected int m_iAliveOccupantCount;
12 override event void OnPostInit(IEntity owner)
14 ClearAffiliatedFaction();
19 bool IsVehicleOccupied()
21 return m_iOccupantCount > 0;
26 bool IsVehicleActive()
28 return m_iAliveOccupantCount > 0;
32 override protected void OnCompartmentEntered(IEntity vehicle, IEntity occupant, BaseCompartmentSlot compartment,
bool move)
34 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(occupant);
40 Faction characterFaction = character.GetFaction();
43 if (characterFaction && !vehicleFaction)
51 if (!IsVehicleOccupied())
57 if (vehicleFaction && characterFaction && characterFaction.IsFactionEnemy(vehicleFaction) && !characterFaction.IsFactionEnemy(characterFaction))
59 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
60 compartmentAccess.EjectOutOfVehicle();
66 UpdateOccupantsCount();
71 override protected void OnCompartmentLeft(IEntity vehicle, IEntity occupant, BaseCompartmentSlot compartment,
bool move)
77 UpdateOccupantsCount(occupant);
81 void UpdateOccupantsCount(IEntity ignoreOccupant =
null)
83 SCR_BaseCompartmentManagerComponent baseCompMan = SCR_BaseCompartmentManagerComponent.Cast(
GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
87 array<IEntity> occupants = {};
88 baseCompMan.GetOccupants(occupants);
92 foreach(IEntity occupant : occupants)
94 if ((ignoreOccupant == occupant))
97 ChimeraCharacter character = ChimeraCharacter.Cast(occupant);
101 CharacterControllerComponent contr = character.GetCharacterController();
105 state = contr.GetLifeState();
113 m_iAliveOccupantCount = aliveOccupants;
114 m_iOccupantCount = allOccupants;
116 if (m_iOccupantCount < 1)
117 ClearAffiliatedFaction();
123 UpdateOccupantsCount();