DayZ
1.24
Loading...
Searching...
No Matches
ProjectedCrosshair.c
Go to the documentation of this file.
1
class
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
11
void
ProjectedCrosshair
()
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
21
void
~ProjectedCrosshair
()
22
{
23
GetGame
().GetUpdateQueue(
CALL_CATEGORY_GUI
).Remove(this.
Update
);
24
}
25
26
void
OnWidgetScriptInit
(
Widget
w
)
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
46
GetCrosshairPosition
();
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
);
59
m_Position
=
vector
.
Zero
;
60
}
61
}
62
63
// getters
64
protected
void
GetPlayer
()
65
{
66
Class
.
CastTo
(
m_Player
,
GetGame
().
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
};
m_Weapon
InventoryItem m_Weapon
Weapons - cache.
Definition
DayZPlayerImplementMeleeCombat.c:57
DiagMenuIDs
DiagMenuIDs
Definition
EDiagMenuIDs.c:2
m_Position
vector m_Position
Cached world position.
Definition
Effect.c:41
m_Player
DayZPlayer m_Player
Definition
Hand_Events.c:42
m_Root
Widget m_Root
Definition
SizeToChild.c:85
Class
Super root of all classes in Enforce script.
Definition
EnScript.c:11
DayZPlayer::IsInIronsights
bool IsInIronsights()
Definition
DayZPlayerImplement.c:229
DayZPlayer::IsPlayerSelected
bool IsPlayerSelected()
Definition
DayZPlayerImplement.c:3265
DayZPlayer::IsRaised
bool IsRaised()
Definition
DayZPlayerImplement.c:3331
DiagMenu
Definition
EnDebug.c:233
ItemBase
Definition
InventoryItem.c:697
Param3
Definition
EntityAI.c:95
PlayerBase
Definition
PlayerBaseClient.c:2
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition
EnWidgets.c:651
ScriptedWidgetEventHandler::m_Player
PlayerBase m_Player
Definition
ContinuousActionProgress.c:5
ScriptedWidgetEventHandler::~ProjectedCrosshair
void ~ProjectedCrosshair()
Definition
ProjectedCrosshair.c:21
ScriptedWidgetEventHandler::OnWidgetScriptInit
void OnWidgetScriptInit(Widget w)
Definition
ProjectedCrosshair.c:26
ScriptedWidgetEventHandler::GetCrosshairPosition
void GetCrosshairPosition()
Definition
ProjectedCrosshair.c:69
ScriptedWidgetEventHandler::m_Root
Widget m_Root
Definition
SizeToChild.c:9
ScriptedWidgetEventHandler::m_Weapon
Weapon_Base m_Weapon
Definition
ProjectedCrosshair.c:9
ScriptedWidgetEventHandler::GetPlayer
void GetPlayer()
Definition
ContinuousActionProgress.c:111
ScriptedWidgetEventHandler::m_Position
vector m_Position
Definition
CTKeyframe.c:7
ScriptedWidgetEventHandler::m_Debug
bool m_Debug
Definition
ProjectedCrosshair.c:6
ScriptedWidgetEventHandler::ProjectedCrosshair
void ProjectedCrosshair()
Definition
ProjectedCrosshair.c:11
ScriptedWidgetEventHandler::m_Visible
bool m_Visible
Definition
ObjectFollower.c:7
ScriptedWidgetEventHandler::Update
void Update()
Update.
Definition
ProjectedCrosshair.c:34
Weapon_Base
shorthand
Definition
BoltActionRifle_Base.c:6
Widget
Definition
EnWidgets.c:190
vector
Definition
EnConvert.c:106
vector::Zero
static const vector Zero
Definition
EnConvert.c:110
GetGame
proto native CGame GetGame()
DiagMenu::GetBool
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
Class::CastTo
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
m_Visible
bool m_Visible
Definition
EnEntity.c:847
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition
tools.c:9
Update
proto native volatile void Update()
Definition
PlayerSoundManager.c:118
scripts
5_Mission
GUI
ProjectedCrosshair.c
Generated by
1.10.0