3 protected const LocalizedString OCCUPIED_BY_SUPPLIES =
"#AR-UserAction_SeatOccupied";
5 protected SCR_BaseLockComponent m_pLockComp;
7 protected SCR_ResourceComponent m_ResourceComp;
8 protected SCR_BaseCompartmentManagerComponent m_CompartmentManager;
11 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
17 m_pLockComp = SCR_BaseLockComponent.Cast(pOwnerEntity.FindComponent(SCR_BaseLockComponent));
21 m_CompartmentManager = SCR_BaseCompartmentManagerComponent.Cast(pOwnerEntity.FindComponent(SCR_BaseCompartmentManagerComponent));
23 m_ResourceComp = SCR_ResourceComponent.FindResourceComponent(pOwnerEntity,
true);
27 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
29 if (!pOwnerEntity || !pUserEntity)
32 ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
36 BaseCompartmentSlot targetCompartment = GetCompartmentSlot();
37 if (!targetCompartment)
40 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
41 if (!compartmentAccess)
44 if (!compartmentAccess.GetInVehicle(pOwnerEntity, targetCompartment, GetRelevantDoorIndex(pUserEntity)))
47 super.PerformAction(pOwnerEntity, pUserEntity);
51 override bool CanBePerformedScript(IEntity user)
56 BaseCompartmentSlot compartment = GetCompartmentSlot();
60 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
64 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
65 if (!compartmentAccess)
69 float storedResources;
74 SetCannotPerformReason(OCCUPIED_BY_SUPPLIES);
79 IEntity owner = compartment.GetOwner();
83 Faction characterFaction = character.GetFaction();
84 Faction vehicleFaction = vehicle.GetFaction();
85 if (characterFaction && vehicleFaction && characterFaction.IsFactionEnemy(vehicleFaction))
87 SetCannotPerformReason(
"#AR-UserAction_SeatHostile");
92 if (compartment.GetOccupant())
94 SetCannotPerformReason(
"#AR-UserAction_SeatOccupied");
99 if (m_pLockComp && m_pLockComp.IsLocked(user, compartment))
101 SetCannotPerformReason(m_pLockComp.GetCannotPerformReason(user));
106 if (!compartmentAccess.CanGetInVehicleViaDoor(owner, compartment, GetRelevantDoorIndex(user)))
108 SetCannotPerformReason(
"#AR-UserAction_SeatObstructed");
116 override bool CanBeShownScript(IEntity user)
121 BaseCompartmentSlot compartment = GetCompartmentSlot();
125 ChimeraCharacter character = ChimeraCharacter.Cast(user);
126 if (character && character.IsInVehicle())
129 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
130 if (!compartmentAccess)
133 if (compartmentAccess.IsGettingIn() || compartmentAccess.IsGettingOut())