Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CloseVehicleDoorUserAction.c
Go to the documentation of this file.
2{
3 [Attribute("1", desc: "Should the door open on their own, or should they be opened by the character?")]
4 protected bool m_bAnimateCharacter;
5
6 //------------------------------------------------------------------------------------------------
7 override bool GetActionNameScript(out string outName)
8 {
9 UIInfo uiInfo = GetUIInfo();
10 if (!uiInfo)
11 {
12 outName = "Missing UIInfo";
13 return true;
14 }
15
16 outName = uiInfo.GetName();
17 return true;
18 }
19
20 //------------------------------------------------------------------------------------------------
22 {
23 return true;
24 }
25
26 //------------------------------------------------------------------------------------------------
27 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
28 {
29 if (!pOwnerEntity || !pUserEntity)
30 return;
31
32 ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
33 if (!character)
34 return;
35
36 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
37 if (controller && controller.IsLoitering())
38 return;
39
40 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
41 if (!compartmentAccess)
42 return;
43
45 if (compartmentAccess.IsInCompartment())
46 {
47 BaseCompartmentSlot compartment = compartmentAccess.GetCompartment();
48 array<int> compartmentDoors = {};
49 if (compartment)
50 compartment.GetAvailableDoorIndices(compartmentDoors);
51
52 if (compartmentDoors.Contains(GetDoorIndex()))
53 animType = ECharacterDoorAnimType.FROM_INSIDE;
54 else
55 animType = ECharacterDoorAnimType.NO_CHARACTER_ANIM;
56 }
57 else
58 {
59 animType = ECharacterDoorAnimType.FROM_OUTSIDE;
60 }
61
62 if (!compartmentAccess.CloseDoor(pOwnerEntity, animType, GetDoorIndex()))
63 return;
64
65 super.PerformAction(pOwnerEntity, pUserEntity);
66 }
67
68 //------------------------------------------------------------------------------------------------
69 override bool CanBePerformedScript(IEntity user)
70 {
71 IEntity owner = GetOwner();//no null check here as it was already done in CanBeShownScript
72 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
73 if (!character)
74 return false;
75
76 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
77 if (controller && controller.IsLoitering())
78 return false;
79
80 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
81 if (!compartmentAccess)
82 return false;
83
84 Vehicle vehicle = Vehicle.Cast(SCR_EntityHelper.GetMainParent(owner, true));
85 if (vehicle)
86 {
87 Faction characterFaction = character.GetFaction();
88 Faction vehicleFaction = vehicle.GetFaction();
89 if (characterFaction && vehicleFaction && characterFaction.IsFactionEnemy(vehicleFaction) && vehicleFaction != characterFaction)
90 {
91 SetCannotPerformReason("#AR-UserAction_SeatHostile");
92 return false;
93 }
94 }
95
97 if (!compartmentManager)
98 return false;
99
100 IEntity currentDoorUser = compartmentManager.GetDoorUser(GetDoorIndex());
101 if (currentDoorUser && currentDoorUser != user)
102 {
103 SetCannotPerformReason("#AR-UserAction_SeatOccupied");
104 return false;
105 }
106
107 if (!compartmentAccess.CanAccessDoor(vehicle, compartmentManager, GetDoorIndex()))
108 {
109 SetCannotPerformReason("#AR-UserAction_SeatObstructed");
110 return false;
111 }
112
113 return true;
114 }
115
116 //------------------------------------------------------------------------------------------------
117 override bool CanBeShownScript(IEntity user)
118 {
119 IEntity owner = GetOwner();
120 if (!owner)
121 return false;
122
123 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
124 if (!character)
125 return false;
126
127 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
128 if (!compartmentAccess)
129 return false;
130
131 if (compartmentAccess.IsGettingIn() || compartmentAccess.IsGettingOut())
132 return false;
133
134 if (compartmentAccess.IsDoorFromAnotherVehicle(owner, GetDoorIndex()))
135 return false;
136
138 if (!compartmentManager)
139 return false;
140
141 return compartmentManager.IsDoorOpen(GetDoorIndex());
142 }
143};
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SetCannotPerformReason(string reason)
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
proto external Managed FindComponent(typename typeName)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
override bool CanBePerformedScript(IEntity user)
override bool GetActionNameScript(out string outName)
static IEntity GetMainParent(IEntity entity, bool self=false)
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_FieldOfViewSettings Attribute
ECharacterDoorAnimType