DayZ 1.24
Loading...
Searching...
No Matches
CTObjectFollower.c
Go to the documentation of this file.
2{
5
6 protected vector m_Position;
7 protected vector m_Orientation;
9
10 protected float m_MaxFade;
11 protected float m_MinFade;
12
13 protected CameraToolsMenu m_Menu;
14
16 {
17 DestroyFollowedObject();
18 delete m_FollowerRoot;
19 }
20
21 void CreateFollowedObject(string type)
22 {
23 m_FollowedObject = EntityAI.Cast(GetGame().CreateObject(type, m_Position, true));
26 }
27
29 {
30 if (m_FollowedObject)
31 GetGame().ObjectDelete(m_FollowedObject);
32 }
33
34 void Update(float timeslice)
35 {
36 UpdatePos();
37 }
38
40 {
41 return m_FollowedObject;
42 }
43
45 {
47 if (m_FollowedObject)
48 {
49 m_FollowedObject.SetPosition(position);
50 m_Position = m_FollowedObject.GetPosition();
51 }
52 UpdatePos();
53 }
54
56 {
57 m_Orientation = dir;
58 PlayerBase player = PlayerBase.Cast(m_FollowedObject);
59 if (player)
60 player.SetOrientation(m_Orientation);
61 UpdatePos();
62 }
63
65 {
66 if (m_FollowedObject && m_FollowedObject.GetPosition() != m_Position)
67 SetPosition(m_FollowedObject.GetPosition());
68 return m_Position;
69 }
70
72 {
73 if (m_FollowedObject)
74 return m_FollowedObject.GetOrientation();
75 return "0 0 0";
76 }
77
82 void UpdatePos()
83 {
85
86 relativePos = GetGame().GetScreenPosRelative(GetPosition());
87
88 if (relativePos[0] >= 1 || relativePos[0] == 0 || relativePos[1] >= 1 || relativePos[1] == 0)
89 {
90 m_FollowerRoot.Show(false);
91 return;
92 }
93 else if (relativePos[2] < 0)
94 {
95 m_FollowerRoot.Show(false);
96 return;
97 }
98 else
99 m_FollowerRoot.Show(true);
100
101 float x, y;
102 m_FollowerRoot.GetSize(x, y);
103
104 m_FollowerRoot.SetPos(relativePos[0], relativePos[1]);
105 }
106
107 void Show()
108 {
109 m_FollowerRoot.Show(true);
110 }
111
112 void Hide()
113 {
114 m_FollowerRoot.Show(false);
115 }
116
117 void Fade(bool fade)
118 {
119 if (fade)
120 m_FollowerRoot.SetAlpha(m_MinFade);
121 else
122 m_FollowerRoot.SetAlpha(m_MaxFade);
123 }
124
125 override bool OnClick(Widget w, int x, int y, int button)
126 {
127 return false;
128 }
129
130 override bool OnDoubleClick(Widget w, int x, int y, int button)
131 {
132 return false;
133 }
134
135 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
136 {
137 if (w == m_FollowerButton && button == MouseState.LEFT)
138 {
139 if (m_Menu)
140 m_Menu.SelectActor(CTActor.Cast(this));
141 return true;
142 }
143 return false;
144 }
145
146 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
147 {
148 if (w == m_FollowerButton && button == MouseState.LEFT)
149 {
150 if (m_Menu)
151 m_Menu.SelectActor(null);
152 return true;
153 }
154 return false;
155 }
156}
vector m_Orientation
vector m_Position
Cached world position.
Definition Effect.c:41
Icon x
Icon y
ServerBrowserMenuNew m_Menu
class JsonUndergroundAreaTriggerData GetPosition
void CTActor(int index, vector pos, vector orient, string type, array< string > items, string hands_item, CameraToolsMenu parent)
Definition CTActor.c:13
map: item x vector(index, width, height)
Definition EnWidgets.c:651
void UpdatePos()
Function updating the position of the tracker widget.
void Update(float timeslice)
void CreateFollowedObject(string type)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
override bool OnDoubleClick(Widget w, int x, int y, int button)
override bool OnClick(Widget w, int x, int y, int button)
void SetPosition(vector position)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
proto native CGame GetGame()
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:420
MouseState
Definition EnSystem.c:311
proto native void SetRotation(float roll, float pitch, float yaw, bool immedUpdate=true)