Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
CrosshairDebug.c
Go to the documentation of this file.
2 {
3  private BaseWeaponManagerComponent m_WeaponManager;
4  private ImageWidget m_CrosshairMuzzleDebugWidget;
5 
6  //------------------------------------------------------------------------------------------------
7  void Update(ChimeraCharacter owner, float timeSlice)
8  {
9  if (!m_CrosshairMuzzleDebugWidget)
10  return;
11 
12  bool debugEnabled = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_CHARACTER_MUZZLE_CROSSHAIR);
13  m_CrosshairMuzzleDebugWidget.SetVisible(debugEnabled);
14 
15  if (!debugEnabled)
16  return;
17 
18  vector muzzleMat[4];
19  m_WeaponManager.GetCurrentMuzzleTransform(muzzleMat);
20 
21  float traceDistance = 100;
22  vector traceStart = muzzleMat[3];
23  vector traceEnd = muzzleMat[3] + muzzleMat[2] * traceDistance;
24 
25  autoptr TraceParam p = new TraceParam();
26  p.Start = traceStart;
27  p.End = traceEnd;
28  p.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
29  p.Exclude = owner;
30  p.LayerMask = TRACE_LAYER_CAMERA;
31  BaseWorld world = owner.GetWorld();
32  float hit = world.TraceMove(p, null);
33 
34  vector endPos = hit * (traceEnd - traceStart) + traceStart;
35  vector screenVect = GetGame().GetWorkspace().ProjWorldToScreen(endPos, world);
36  FrameSlot.SetPos(m_CrosshairMuzzleDebugWidget, screenVect[0],screenVect[1]);
37  }
38 
39  //------------------------------------------------------------------------------------------------
40  void SCR_CrosshairDebug(ChimeraCharacter owner, Widget root)
41  {
42  // Detect and store weapon manager
43  m_WeaponManager = BaseWeaponManagerComponent.Cast(owner.FindComponent(BaseWeaponManagerComponent));
44  if (!m_WeaponManager)
45  return;
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  void ~SCR_CrosshairDebug()
50  {
51  }
52 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_WeaponManager
protected BaseWeaponManagerComponent m_WeaponManager
Definition: SCR_CharacterCommandHandler.c:120
TRACE_LAYER_CAMERA
const int TRACE_LAYER_CAMERA
Definition: Constants.c:14
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
SCR_CrosshairDebug
Definition: CrosshairDebug.c:1