Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TeleportPlayerManualCameraComponent.c
Go to the documentation of this file.
1 
4 [BaseContainerProps(), SCR_BaseManualCameraComponentTitle()]
6 {
7  //------------------------------------------------------------------------------------------------
8  protected void TeleportPlayer()
9  {
10  if (!IsEnabled() || !GetCameraEntity().GetCameraParam().isManualInputEnabled)
11  return;
12 
13  ArmaReforgerScripted game = GetGame();
14  if (!game)
15  return;
16 
17  WorkspaceWidget workspace = game.GetWorkspace();
18  if (!workspace)
19  return;
20 
21  BaseWorld world = game.GetWorld();
22  if (!world)
23  return;
24 
25  IEntity player = SCR_PlayerController.GetLocalControlledEntity();
26  if (!player)
27  return;
28 
29  InputManager inputManager = game.GetInputManager();
30  if (!inputManager)
31  return;
32 
33  float mouseX = inputManager.GetActionValue("MouseX");
34  float mouseY = inputManager.GetActionValue("MouseY");
35 
36  vector outDir;
37  vector startPos = workspace.ProjScreenToWorld(workspace.DPIUnscale(mouseX), workspace.DPIUnscale(mouseY), outDir, world, -1);
38  outDir *= 10000;
39 
40  TraceParam trace = new TraceParam();
41  trace.Start = startPos;
42  trace.End = startPos + outDir;
43  trace.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
44  trace.LayerMask = TRACE_LAYER_CAMERA;
45  trace.Exclude = player;
46 
47  if (startPos[1] > world.GetOceanBaseHeight())
48  trace.Flags = trace.Flags | TraceFlags.OCEAN;
49 
50  float traceDis = world.TraceMove(trace, null);
51  if (traceDis == 1)
52  return;
53 
54  vector endPos = startPos + outDir * traceDis;
55 
56  SCR_Global.TeleportLocalPlayer(endPos);
57  }
58 
59 //#ifdef WORKBENCH
60 // //------------------------------------------------------------------------------------------------
61 // override void EOnCameraFrame(SCR_ManualCameraParam param)
62 // {
63 // if (!param.isManualInputEnabled) return;
64 //
65 // if (GetInputManager().GetActionTriggered("ManualCameraTeleportPlayer"))
66 // {
67 // TeleportPlayer();
68 // }
69 // }
70 
71  //------------------------------------------------------------------------------------------------
72  override bool EOnCameraInit()
73  {
74  GetInputManager().AddActionListener("ManualCameraTeleportPlayer", EActionTrigger.DOWN, TeleportPlayer);
75  return false;
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  override void EOnCameraExit()
80  {
81  GetInputManager().RemoveActionListener("ManualCameraTeleportPlayer", EActionTrigger.DOWN, TeleportPlayer);
82  }
83 //#endif // WORKBENCH
84 }
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_BaseManualCameraComponent
Parent class from which all SCR_ManualCamera components inherit.
Definition: SCR_BaseManualCameraComponent.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_TeleportPlayerManualCameraComponent
Teleports the player.
Definition: SCR_TeleportPlayerManualCameraComponent.c:5
IsEnabled
int IsEnabled()
Definition: SCR_BaseManualCameraComponent.c:99
TRACE_LAYER_CAMERA
const int TRACE_LAYER_CAMERA
Definition: Constants.c:14
GetCameraEntity
protected SCR_ManualCamera GetCameraEntity()
Definition: SCR_BaseManualCameraComponent.c:59
SCR_Global
Definition: Functions.c:6
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468