DayZ
1.24
Loading...
Searching...
No Matches
ObjectFollower.c
Go to the documentation of this file.
1
class
ObjectFollower
extends
ScriptedWidgetEventHandler
2
{
3
reference
int
m_PivotYOffset
;
4
5
protected
Widget
m_Root
;
6
protected
Object
m_TargetObject
;
7
protected
bool
m_Visible
;
8
9
void
ObjectFollower
()
10
{
11
m_Visible
=
false
;
12
//GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(Update);
13
}
14
15
void
~ObjectFollower
()
16
{
17
//GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Remove(Update);
18
}
19
20
protected
void
OnWidgetScriptInit
(
Widget
w
)
21
{
22
m_Root
=
w
;
23
m_Root
.SetHandler(
this
);
24
}
25
26
void
SetTarget
(
Object
obj)
27
{
28
m_TargetObject
= obj;
29
}
30
31
override
bool
OnUpdate
(
Widget
w
)
32
{
33
if
(
m_Root
==
w
)
34
{
35
Update
();
36
return
true
;
37
}
38
39
return
false
;
40
}
41
42
void
Update
()
43
{
44
float
x
,
y
;
45
46
if
(
m_Visible
)
47
{
48
if
(
m_TargetObject
)
49
GetOnScreenPosition
(
x
,
y
);
50
51
m_Root
.Show(
true
);
52
}
53
else
54
m_Root
.Show(
false
);
55
}
56
57
protected
void
GetOnScreenPosition
(
out
float
x
,
out
float
y
)
58
{
59
const
float
DEFAULT_HANDLE_OFFSET
= 0.2;
60
61
float
pivotYOffset
= 0.0;
62
63
bool
ignorePivot
=
false
;
64
bool
traceMatched
=
false
;
65
bool
isDefaultPos
=
false
;
66
67
vector
objectPos
;
68
69
if
(
m_TargetObject
)
70
{
71
pivotYOffset
=
m_PivotYOffset
;
72
73
traceMatched
=
true
;
74
objectPos
=
m_TargetObject
.GetPosition();
75
if
(
pivotYOffset
!= 0.0)
76
objectPos
[1] =
objectPos
[1] +
pivotYOffset
;
77
else
78
objectPos
[1] =
objectPos
[1] +
DEFAULT_HANDLE_OFFSET
;
79
}
80
else
81
{
82
// default position for the action cursor
83
traceMatched
=
false
;
84
isDefaultPos
=
true
;
85
}
86
87
if
(
ignorePivot
&& !
traceMatched
)
88
{
89
// hides the widget if we are in situation that the widget will be displayed on pivot point
90
// and we do not want to display it
91
x
= 0.0;
92
y
= 0.0;
93
}
94
else
95
{
96
// calculate screen position from traced results
97
if
(
isDefaultPos
)
98
{
99
int
w
,
h
;
100
GetScreenSize
(
w
,
h
);
101
x
=
w
/ 2;
102
y
=
h
/ 2;
103
}
104
else
105
{
106
vector
screen_pos
=
GetGame
().GetScreenPos(
objectPos
);
107
x
=
screen_pos
[0];
108
y
=
screen_pos
[1];
109
}
110
}
111
112
objectPos
=
"0 0 0"
;
113
isDefaultPos
=
false
;
114
}
115
}
m_TargetObject
Object m_TargetObject
Targets - types.
Definition
DayZPlayerImplementMeleeCombat.c:40
x
Icon x
y
Icon y
m_Root
Widget m_Root
Definition
SizeToChild.c:85
Object
Definition
ObjectTyped.c:2
Param3
Definition
EntityAI.c:95
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition
EnWidgets.c:651
ScriptedWidgetEventHandler::OnWidgetScriptInit
void OnWidgetScriptInit(Widget w)
Definition
ObjectFollower.c:20
ScriptedWidgetEventHandler::SetTarget
void SetTarget(Object obj)
Definition
ObjectFollower.c:26
ScriptedWidgetEventHandler::m_PivotYOffset
reference int m_PivotYOffset
Definition
ObjectFollower.c:3
ScriptedWidgetEventHandler::m_Root
Widget m_Root
Definition
SizeToChild.c:9
ScriptedWidgetEventHandler::m_TargetObject
Object m_TargetObject
Definition
ObjectFollower.c:6
ScriptedWidgetEventHandler::GetOnScreenPosition
void GetOnScreenPosition(out float x, out float y)
Definition
ObjectFollower.c:57
ScriptedWidgetEventHandler::OnUpdate
override bool OnUpdate(Widget w)
Definition
ObjectFollower.c:31
ScriptedWidgetEventHandler::~ObjectFollower
void ~ObjectFollower()
Definition
ObjectFollower.c:15
ScriptedWidgetEventHandler::ObjectFollower
void ObjectFollower()
Definition
ObjectFollower.c:9
ScriptedWidgetEventHandler::m_Visible
bool m_Visible
Definition
ObjectFollower.c:7
ScriptedWidgetEventHandler::Update
void Update()
Definition
ContinuousActionProgress.c:56
Widget
Definition
EnWidgets.c:190
vector
Definition
EnConvert.c:106
GetGame
proto native CGame GetGame()
m_Visible
bool m_Visible
Definition
EnEntity.c:847
GetScreenSize
proto void GetScreenSize(out int x, out int y)
scripts
5_Mission
GUI
ObjectFollower.c
Generated by
1.10.0