DayZ 1.24
Loading...
Searching...
No Matches
ProjectedCrosshair.c
Go to the documentation of this file.
1class ProjectedCrosshair extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4 protected vector m_Position;
5 protected bool m_Visible;
6 protected bool m_Debug;
7
8 protected PlayerBase m_Player;
10
12 {
13 m_Player = NULL;
14 m_Weapon = NULL;
15 m_Visible = false;
16 m_Debug = false;
17
18 GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(this.Update);
19 }
20
22 {
23 GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Remove(this.Update);
24 }
25
27 {
28 m_Root = w;
29 m_Root.SetHandler(this);
30 m_Root.Update();
31 }
32
34 protected void Update()
35 {
36#ifdef DIAG_DEVELOPER
37 m_Debug = DiagMenu.GetBool(DiagMenuIDs.WEAPON_DEBUG);
38#endif
39 if (!m_Debug) return;
40 if (!m_Player) GetPlayer();
41
42 if (m_Player && m_Player.IsPlayerSelected() && m_Player.IsRaised() && !m_Player.IsInIronsights() && !GetGame().IsInventoryOpen())
43 {
44 float sx, sy;
45
47 vector screenSpace = GetGame().GetScreenPos(m_Position);
48
49 m_Root.GetSize(sx, sy);
50 screenSpace[0] = screenSpace[0] - sx / 2;
51 screenSpace[1] = screenSpace[1] - sy / 2;
52
53 m_Root.SetPos(screenSpace[0], screenSpace[1]);
54 m_Root.Show(m_Visible);
55 }
56 else
57 {
58 m_Root.Show(false);
60 }
61 }
62
63 // getters
64 protected void GetPlayer()
65 {
67 }
68
69 protected void GetCrosshairPosition()
70 {
71 m_Visible = false;
73 itemInHands = m_Player.GetItemInHands();
74 if (itemInHands && itemInHands.IsWeapon())
75 {
77 {
78 //m_Visible = MiscGameplayFunctions.GetProjectedCursorPos3d(m_Position, m_Weapon);
79 }
80 }
81 }
82};
InventoryItem m_Weapon
Weapons - cache.
DiagMenuIDs
Definition EDiagMenuIDs.c:2
vector m_Position
Cached world position.
Definition Effect.c:41
DayZPlayer m_Player
Definition Hand_Events.c:42
Widget m_Root
Definition SizeToChild.c:85
Super root of all classes in Enforce script.
Definition EnScript.c:11
map: item x vector(index, width, height)
Definition EnWidgets.c:651
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
bool m_Visible
Definition EnEntity.c:847
const int CALL_CATEGORY_GUI
Definition tools.c:9
proto native volatile void Update()