Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LadderUserAction.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  static const float MAX_LADDER_TEST_DISTANCE = 5.0;
5  static const float MAX_LADDER_ENTRY_ANGLE = 75.0;
6  protected IEntity m_pLadderOwner;
7 
8  [Attribute("0", UIWidgets.EditBox, "Which ladder component to use", "0 inf")]
9  protected int m_iLadderComponentIndex;
10 
11  protected override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
12  {
13  array<Managed> ladderComponents = {};
14  pOwnerEntity.FindComponents(LadderComponent, ladderComponents);
15  if (!ladderComponents.IsIndexValid(m_iLadderComponentIndex))
16  {
17  Print("m_iLadderComponentIndex : " + m_iLadderComponentIndex + " is not an index valid", LogLevel.ERROR);
18  return;
19  }
20 
21  m_pLadderOwner = pOwnerEntity;
22  }
23 
24  protected SCR_CharacterCommandHandlerComponent FindCommandHandler(IEntity pUser)
25  {
26  ChimeraCharacter character = ChimeraCharacter.Cast(pUser);
27  if (!character)
28  return null;
29 
30  CharacterAnimationComponent animationComponent = character.GetCharacterController().GetAnimationComponent();
31  if (!animationComponent)
32  return null;
33 
34  return SCR_CharacterCommandHandlerComponent.Cast(animationComponent.FindComponent(SCR_CharacterCommandHandlerComponent));
35  }
36 
37  protected override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
38  {
39  ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
40  CharacterControllerComponent controller = character.GetCharacterController();
41  controller.TryUseLadder(m_pLadderOwner, m_iLadderComponentIndex, MAX_LADDER_TEST_DISTANCE, MAX_LADDER_ENTRY_ANGLE);
42  }
43 
44  protected override bool CanBePerformedScript(IEntity user)
45  {
46  ChimeraCharacter character = ChimeraCharacter.Cast(user);
47  if (!character)
48  return false;
49 
50  CharacterControllerComponent controller = character.GetCharacterController();
51  return controller && controller.CanUseLadder(m_pLadderOwner, m_iLadderComponentIndex, MAX_LADDER_TEST_DISTANCE, MAX_LADDER_ENTRY_ANGLE);
52  }
53 
54  protected override bool CanBeShownScript(IEntity user)
55  {
56  if (!m_pLadderOwner)
57  return false;
58 
59  // Already on a ladder
60  SCR_CharacterCommandHandlerComponent cmdHandler = FindCommandHandler(user);
61  return cmdHandler && !cmdHandler.GetCommandLadder();
62  }
63 
66  protected override bool HasLocalEffectOnlyScript()
67  {
68  return true;
69  }
70 };
SCR_LadderUserAction
Definition: SCR_LadderUserAction.c:2
ScriptedUserAction
Definition: ScriptedUserAction.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.