Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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;
9 protected Weapon_Base m_Weapon;
10
12 {
13 m_Player = NULL;
14 m_Weapon = NULL;
15 m_Visible = false;
16 m_Debug = false;
17
18 g_Game.GetUpdateQueue(CALL_CATEGORY_GUI).Insert(this.Update);
19 }
20
22 {
23 g_Game.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() && !g_Game.IsInventoryOpen() )
43 {
44 float sx, sy;
45
47 vector screenSpace = g_Game.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 {
66 Class.CastTo(m_Player, g_Game.GetPlayer());
67 }
68
69 protected void GetCrosshairPosition()
70 {
71 m_Visible = false;
72 ItemBase itemInHands;
73 itemInHands = m_Player.GetItemInHands();
74 if ( itemInHands && itemInHands.IsWeapon() )
75 {
76 if( Class.CastTo(m_Weapon, itemInHands) )
77 {
78 //m_Visible = MiscGameplayFunctions.GetProjectedCursorPos3d(m_Position, m_Weapon);
79 }
80 }
81 }
82};
Super root of all classes in Enforce script.
Definition enscript.c:11
map: item x vector(index, width, height)
Definition enwidgets.c:657
void Update(float timeslice)
static const vector Zero
Definition enconvert.c:123
DayZGame g_Game
Definition dayzgame.c:3942
DiagMenuIDs
Definition ediagmenuids.c:2
vector m_Position
Cached world position.
Definition effect.c:43
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:852
const int CALL_CATEGORY_GUI
Definition tools.c:9
WorkspaceWidget Widget
Defined in code.
Widget m_Root
Definition sizetochild.c:91