Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CharacterCommandLoiter.c
Go to the documentation of this file.
1 enum ELoiterCommandState // TODO: SCR_
2 {
3  LOITERING = 0,
4  EXITING = 1,
5  DONE = 2
6 }
7 
9 {
10  //------------------------------------------------------------------------------------------------
11  // constructor
12  void SCR_CharacterCommandLoiter(BaseAnimPhysComponent pAnimPhysComponent, ChimeraCharacter pCharacter, CharacterInputContext pBaseInputCtx, SCR_ScriptedCharacterInputContext pScrInputCtx, SCR_ScriptedCommandsStaticTable pStaticTable, SCR_CharacterCommandHandlerComponent pScrCommandHandler)
13  {
14  m_pCharAnimComponent = CharacterAnimationComponent.Cast(pAnimPhysComponent);
15  m_pCharacter = pCharacter;
16  m_pBaseInputCtx = pBaseInputCtx;
17  m_pScrInputCtx = pScrInputCtx;
18  m_pStaticTable = pStaticTable;
19  m_pCommandHandler = pScrCommandHandler;
20  }
21 
22  //------------------------------------------------------------------------------------------------
23  override void OnActivate()
24  {
25  m_bWasTag = false;
26 
27  if (m_pScrInputCtx.m_iLoiteringType < 0)
28  {
29  SetFlagFinished(true);
30  return;
31  }
32 
34  }
35 
36  //------------------------------------------------------------------------------------------------
37  override void OnDeactivate()
38  {
39  m_pScrInputCtx.m_iLoiteringType = -1;
40  }
41 
42  //------------------------------------------------------------------------------------------------
43  override void OnPossess()
44  {
45  StopLoitering(true);
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  override bool IsRootMotionControlled()
50  {
51  return m_pScrInputCtx.m_bLoiteringRootMotion;
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  override void PrePhysUpdate(float pDt)
56  {
57  switch (m_eState)
58  {
59  case ELoiterCommandState.LOITERING:
60  {
61  bool isTag = m_pCharAnimComponent.IsPrimaryTag(m_pStaticTable.m_IsLoiteringTag);
62  m_bWasTag = isTag || m_bWasTag;
63 
64  bool cancelLoiterInputs = false;
65 
66  PlayerController playerController = GetGame().GetPlayerController();
67  if (playerController && playerController.GetControlledEntity() == m_pCharacter)
68  {
69  InputManager iManager = GetGame().GetInputManager();
70  cancelLoiterInputs = iManager.GetActionValue("CharacterFire") || iManager.GetActionValue("CharacterSprint") || iManager.GetActionValue("CharacterRaiseWeapon") || iManager.GetActionValue("CharacterWeaponADS") || iManager.GetActionValue("CharacterReload");
71  }
72 
73  if ((m_bWasTag && !isTag) || cancelLoiterInputs)
74  {
75  m_pCommandHandler.StopLoitering(false);
76  }
77  }
78  break;
79  case ELoiterCommandState.EXITING:
80  {
81  m_pCharAnimComponent.CallCommand(m_pStaticTable.m_CommandGesture, -1, 0.0); // -1 is soft exit.
82  // @TODO(ivanickyjak) We cannot use tags on server.
83  bool isTag = m_pCharAnimComponent.IsPrimaryTag(m_pStaticTable.m_IsLoiteringTag) || m_pCharAnimComponent.IsSecondaryTag(m_pStaticTable.m_IsLoiteringTag);
84  if (!isTag)
85  {
86  FinishLoiter();
87  }
88  }
89  break;
90  }
91  }
92 
93  //------------------------------------------------------------------------------------------------
97  {
98  switch (newState)
99  {
100  case ELoiterCommandState.LOITERING:
101  {
102  m_bWasTag = false;
103  m_pCharAnimComponent.CallCommand4I(m_pStaticTable.m_CommandGesture, 0, m_pScrInputCtx.m_iLoiteringType, 0, 0, 0.0);
104  }
105  break;
106  case ELoiterCommandState.EXITING:
107  {
108  m_pCharAnimComponent.CallCommand(m_pStaticTable.m_CommandGesture, -1, 0.0); // -1 is soft exit.
109  }
110  break;
111  }
112 
113  m_eState = newState;
114  }
115 
116  //------------------------------------------------------------------------------------------------
118  void StopLoitering(bool terminateFast)
119  {
121  }
122 
123  //------------------------------------------------------------------------------------------------
124  protected void FinishLoiter()
125  {
126  SetFlagFinished(true);
127  m_pScrInputCtx.m_iLoiteringType = -1;
128  }
129 
130  protected CharacterAnimationComponent m_pCharAnimComponent;
131  protected ChimeraCharacter m_pCharacter;
135  protected SCR_CharacterCommandHandlerComponent m_pCommandHandler;
136 
138  protected bool m_bWasTag;
139 }
SCR_ScriptedCharacterInputContext
Definition: SCR_ScriptedCharacterInputContext.c:1
SCR_ScriptedCommandsStaticTable
Definition: SCR_ScriptedCommandsStaticTable.c:1
CharacterInputContext
Definition: CharacterInputContext.c:12
SCR_CharacterCommandLoiter
enum ELoiterCommandState SCR_CharacterCommandLoiter(BaseAnimPhysComponent pAnimPhysComponent, ChimeraCharacter pCharacter, CharacterInputContext pBaseInputCtx, SCR_ScriptedCharacterInputContext pScrInputCtx, SCR_ScriptedCommandsStaticTable pStaticTable, SCR_CharacterCommandHandlerComponent pScrCommandHandler)
Definition: SCR_CharacterCommandLoiter.c:12
EXITING
EXITING
Definition: SCR_CharacterCommandLoiter.c:3
FinishLoiter
protected void FinishLoiter()
Definition: SCR_CharacterCommandLoiter.c:124
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
StopLoitering
void StopLoitering(bool terminateFast)
Definition: SCR_CharacterCommandLoiter.c:118
m_pCharAnimComponent
protected CharacterAnimationComponent m_pCharAnimComponent
Definition: SCR_CharacterCommandLoiter.c:130
LOITERING
LOITERING
Definition: SCR_CharacterCommandLoiter.c:2
PrePhysUpdate
override void PrePhysUpdate(float pDt)
Definition: SCR_CharacterCommandLoiter.c:55
OnDeactivate
override void OnDeactivate()
Definition: SCR_CharacterCommandLoiter.c:37
OnActivate
override void OnActivate()
Definition: SCR_CharacterCommandLoiter.c:23
m_pBaseInputCtx
protected CharacterInputContext m_pBaseInputCtx
Definition: SCR_CharacterCommandLoiter.c:132
IsRootMotionControlled
override bool IsRootMotionControlled()
Definition: SCR_CharacterCommandLoiter.c:49
m_pCommandHandler
protected SCR_CharacterCommandHandlerComponent m_pCommandHandler
Definition: SCR_CharacterCommandLoiter.c:135
ELoiterCommandState
ELoiterCommandState
Definition: SCR_CharacterCommandLoiter.c:1
m_eState
protected ELoiterCommandState m_eState
Definition: SCR_CharacterCommandLoiter.c:137
CharacterCommandScripted
Definition: CharacterCommandScripted.c:12
m_pCharacter
protected ChimeraCharacter m_pCharacter
Definition: SCR_CharacterCommandLoiter.c:131
m_pStaticTable
protected SCR_ScriptedCommandsStaticTable m_pStaticTable
Definition: SCR_CharacterCommandLoiter.c:134
m_bWasTag
protected bool m_bWasTag
Definition: SCR_CharacterCommandLoiter.c:138
OnPossess
override void OnPossess()
Definition: SCR_CharacterCommandLoiter.c:43
DONE
DONE
Definition: SCR_CharacterCommandLoiter.c:4
m_pScrInputCtx
protected SCR_ScriptedCharacterInputContext m_pScrInputCtx
Definition: SCR_CharacterCommandLoiter.c:133
SwitchState
void SwitchState(ELoiterCommandState newState)
Definition: SCR_CharacterCommandLoiter.c:96