Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DoorUserAction.c
Go to the documentation of this file.
4 {
5  //------------------------------------------------------------------------------------------------
6  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
7  {
8  DoorComponent doorComponent = GetDoorComponent();
9  if (doorComponent)
10  {
11  vector doorOpeningVecWS = pOwnerEntity.VectorToParent(vector.Forward);
12  if (doorComponent.GetAngleRange() < 0.0)
13  doorOpeningVecWS = -1.0 * doorOpeningVecWS;
14 
15  vector userMat[4];
16  pUserEntity.GetWorldTransform(userMat);
17  float dotP = vector.Dot(doorOpeningVecWS, userMat[3] - doorComponent.GetDoorPivotPointWS());
18 
19  // Flip the control value if it is above a threshold
20  float controlValue = 1.0;
21  float currentState = doorComponent.GetDoorState();
22  if ((dotP < 0.0 && currentState <= 0.0) || (dotP > 0.0 && currentState < 0.0))
23  controlValue = -1.0;
24  if (Math.AbsFloat(doorComponent.GetControlValue()) > 0.5)
25  controlValue = 0.0;
26 
27  //Print(controlValue);
28  doorComponent.SetActionInstigator(pUserEntity);
29  doorComponent.SetControlValue(controlValue);
30  }
31 
32  super.PerformAction(pOwnerEntity, pUserEntity);
33  }
34 
35  //------------------------------------------------------------------------------------------------
36  override bool CanBePerformedScript(IEntity user)
37  {
38  DoorComponent doorComponent = GetDoorComponent();
39  if (doorComponent)
40  return true;
41 
42  return false;
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  override bool GetActionNameScript(out string outName)
47  {
48  auto doorComponent = GetDoorComponent();
49  // Logic here is flipped since method returns the opposite of what we expect
50  if (doorComponent && Math.AbsFloat(doorComponent.GetControlValue()) >= 0.5)
51  outName = "#AR-UserAction_Close";
52  else
53  outName = "#AR-UserAction_Open";
54 
55  return true;
56  }
57 
58 };
59 
61 {
62  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
63  {
64  super.PerformAction(pOwnerEntity, pUserEntity);
65  DoorComponent door = GetDoorComponent();
66  if (door)
67  {
68  LadderComponent ladder = LadderComponent.Cast(door.FindComponent(LadderComponent));
69  if (ladder)
70  {
71  if (door.GetControlValue() < 0.5)
72  {
73  ladder.SetEnabledEntry(false);
74  }
75  else
76  {
77  ladder.SetEnabledEntry(true);
78  }
79  }
80  }
81  }
82 };
SCR_DoorUserAction
Definition: SCR_DoorUserAction.c:3
DoorComponent
Definition: DoorComponent.c:12
DoorUserAction
Definition: DoorUserAction.c:12
SCR_LadderDoorUserAction
Definition: SCR_DoorUserAction.c:60