Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SetTargetsModeUserAction.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  // Member variables
5  private SCR_FiringRangeController m_LineController;
6  private SCR_FiringRangeManager m_FiringRangeManager;
7  private SignalsManagerComponent m_SignalManager;
8  private int m_iPushButtonStart;
9 
10  const static int RESET_BUTTON_TIME = 500;
11  const static float BUTTON_PRESSED_STATE = -0.005;
12  const static int BUTTON_DEFAULT_STATE = 0;
13 
14  //------------------------------------------------------------------------------------------------
15  override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
16  {
17  m_LineController = SCR_FiringRangeController.Cast(pOwnerEntity);
18  m_FiringRangeManager = SCR_FiringRangeManager.Cast(pOwnerEntity.GetParent());
19  m_SignalManager = SignalsManagerComponent.Cast(pOwnerEntity.FindComponent(SignalsManagerComponent));
20  }
21 
22  //------------------------------------------------------------------------------------------------
23  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
24  {
25 
26  // Find local player controller
27  PlayerController playerController = GetGame().GetPlayerController();
28  if (!playerController)
29  return;
30 
31  // Find conflict network entity to send RPC to server
32  SCR_FiringRangeNetworkEntity firingRangeNetworkEntity = SCR_FiringRangeNetworkEntity.GetInstance();
33  if (!firingRangeNetworkEntity)
34  return;
35 
36  // Get player ID
37  int playerID = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity);
38 
39  // Clear player score from previous match
40  firingRangeNetworkEntity.ClearPlayerScore(playerID, m_FiringRangeManager);
41  // Delete all decals on indicator of the given firing line
42  firingRangeNetworkEntity.RemoveIndicators(pOwnerEntity, m_FiringRangeManager);
43  // Count maximal possible score player can foreach
44  firingRangeNetworkEntity.SetPlayerScoreMax(playerID, m_LineController.GetMaxScoreInRound(), m_FiringRangeManager);
45  // Start with the erectign random targets
46  firingRangeNetworkEntity.ErectRandomTargets(pOwnerEntity,playerID);
47 
48  m_iPushButtonStart = m_SignalManager.FindSignal("StartRound");
49  m_SignalManager.SetSignalValue(m_iPushButtonStart, BUTTON_PRESSED_STATE);
50  GetGame().GetCallqueue().CallLater(ResetStartButton, RESET_BUTTON_TIME, false);
51  }
52 
53  //------------------------------------------------------------------------------------------------
54  override bool CanBeShownScript(IEntity user)
55  {
56  // Check if the firing line is currently assigned to any player. If so, other players can't interact with this firing range controller.
57  if (m_FiringRangeManager)
58  return m_LineController.GetFiringLineOwnerId() == m_LineController.NO_TARGET_OWNER;
59 
60  return false;
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  override bool GetActionNameScript(out string outName)
65  {
66  outName = ("#AR-FiringRange_ActionStartRound-UC");
67  return true;
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  override bool HasLocalEffectOnlyScript()
72  {
73  return true;
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  void ResetStartButton()
78  {
79  m_SignalManager.SetSignalValue(m_iPushButtonStart, BUTTON_DEFAULT_STATE);
80  }
81 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ScriptedUserAction
Definition: ScriptedUserAction.c:12
m_SignalManager
protected SignalsManagerComponent m_SignalManager
Definition: SCR_WristwatchComponent.c:55
SCR_FiringRangeManager
Definition: SCR_FiringRangeManager.c:7
SCR_FiringRangeNetworkEntity
Definition: SCR_FiringRangeNetworkEntity.c:7
SCR_SetTargetsModeUserAction
Definition: SCR_SetTargetsModeUserAction.c:2
SCR_FiringRangeController
Definition: SCR_FiringRangeController.c:9