Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SwitchSeatUserAction.c
Go to the documentation of this file.
2 {
3  //------------------------------------------------------------------------------------------------
4  override bool CanBePerformedScript(IEntity user)
5  {
6  ChimeraCharacter character = ChimeraCharacter.Cast(user);
7  if (!character && !character.IsInVehicle())
8  return false;
9 
10  CharacterControllerComponent characterController = character.GetCharacterController();
11  if (!characterController)
12  return false;
13 
14  CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
15  if (!compartmentAccess)
16  return false;
17 
18  BaseCompartmentSlot characterCompartment = compartmentAccess.GetCompartment();
19  if (!characterCompartment)
20  return false;
21 
22  BaseCompartmentSlot compartment = GetCompartmentSlot();
23  if (!compartment)
24  return false;
25 
26  if (characterCompartment == compartment)
27  return false;
28 
29  // Restrict switching to this compartment in case the section does not match
30  if (characterCompartment.GetCompartmentSection() != compartment.GetCompartmentSection())
31  return false;
32 
33  auto commandHandler = character.GetAnimationComponent().GetCommandHandler();
34  if (commandHandler && commandHandler.IsVehicleSwitchingSeats())
35  return false;
36 
37  // Prevents switching seats within different vehicles,
38  if (characterCompartment.GetOwner().GetRootParent() != GetOwner().GetRootParent())
39  return false;
40 
41  // Check if the position isn't locked
42  if (m_pLockComp && m_pLockComp.IsLocked(user, compartment))
43  {
44  SetCannotPerformReason(m_pLockComp.GetCannotPerformReason(user));
45  return false;
46  }
47 
48  return true;
49  }
50 
51  //------------------------------------------------------------------------------------------------
52  override bool CanBeShownScript(IEntity user)
53  {
54  if (!user)
55  return false;
56 
57  BaseCompartmentSlot compartment = GetCompartmentSlot();
58  if (!compartment)
59  return false;
60 
61  if (compartment.GetOccupant())
62  return false;
63 
64  ChimeraCharacter character = ChimeraCharacter.Cast(user);
65  if (!character && !character.IsInVehicle())
66  return false;
67 
68  CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
69  if (!compartmentAccess)
70  return false;
71 
72  if (compartmentAccess.IsGettingIn() || compartmentAccess.IsGettingOut())
73  return false;
74 
75  BaseCompartmentSlot characterCompartment = compartmentAccess.GetCompartment();
76  if (!characterCompartment)
77  return false;
78 
79  if (characterCompartment == compartment)
80  return false;
81 
82  // Restrict switching to this compartment in case the section does not match
83  if (characterCompartment.GetCompartmentSection() != compartment.GetCompartmentSection())
84  return false;
85 
86  auto commandHandler = character.GetAnimationComponent().GetCommandHandler();
87  if (commandHandler && commandHandler.IsVehicleSwitchingSeats())
88  return false;
89 
90  // Prevents switching seats within different vehicles,
91  if (characterCompartment.GetOwner().GetRootParent() != GetOwner().GetRootParent())
92  return false;
93 
96  {
97  auto vehicleController = VehicleControllerComponent.Cast(characterCompartment.GetController());
98  if (vehicleController && !vehicleController.CanSwitchSeat())
99  return false;
100  }
101  else
102  {
103  auto vehicleController = VehicleControllerComponent_SA.Cast(characterCompartment.GetController());
104  if (vehicleController && !vehicleController.CanSwitchSeat())
105  return false;
106  }
107 
108  return true;
109  }
110 }
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetIsClientAuthority
override bool GetIsClientAuthority()
Definition: game.c:268
SCR_SwitchSeatAction
Definition: SCR_SwitchSeatUserAction.c:1
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_GetInUserAction
Definition: SCR_GetInUserAction.c:1