DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 {
32 GetGame().ObjectDelete( m_FollowedObject );
33 }
34 }
35
36 void Update( float timeslice )
37 {
38 UpdatePos();
39 }
40
42 {
43 return m_FollowedObject;
44 }
45
46 void SetPosition( vector position )
47 {
48 m_Position = position;
49 if( m_FollowedObject )
50 {
51 m_FollowedObject.SetPosition( position );
52 m_Position = m_FollowedObject.GetPosition();
53 }
54 UpdatePos();
55 }
56
57 void SetRotation( vector dir )
58 {
59 m_Orientation = dir;
60 PlayerBase player = PlayerBase.Cast( m_FollowedObject );
61 if( player )
62 {
63 player.SetOrientation( m_Orientation );
64 }
65 UpdatePos();
66 }
67
69 {
70 if( m_FollowedObject && m_FollowedObject.GetPosition() != m_Position )
71 {
72 SetPosition( m_FollowedObject.GetPosition() );
73 }
74 return m_Position;
75 }
76
78 {
79 if( m_FollowedObject )
80 {
81 return m_FollowedObject.GetOrientation();
82 }
83 return "0 0 0";
84 }
85
90 void UpdatePos()
91 {
92 vector relativePos;
93
94 relativePos = GetGame().GetScreenPosRelative( GetPosition() );
95
96 if( relativePos[0] >= 1 || relativePos[0] == 0 || relativePos[1] >= 1 || relativePos[1] == 0 )
97 {
98 m_FollowerRoot.Show( false );
99 return;
100 }
101 else if( relativePos[2] < 0 )
102 {
103 m_FollowerRoot.Show( false );
104 return;
105 }
106 else
107 {
108 m_FollowerRoot.Show( true );
109 }
110
111 float x, y;
112 m_FollowerRoot.GetSize( x, y );
113
114 m_FollowerRoot.SetPos( relativePos[0], relativePos[1] );
115 }
116
117 void Show()
118 {
119 m_FollowerRoot.Show( true );
120 }
121
122 void Hide()
123 {
124 m_FollowerRoot.Show( false );
125 }
126
127 void Fade( bool fade )
128 {
129 if( fade )
130 {
131 m_FollowerRoot.SetAlpha( m_MinFade );
132 }
133 else
134 {
135 m_FollowerRoot.SetAlpha( m_MaxFade );
136 }
137 }
138
139 override bool OnClick( Widget w, int x, int y, int button )
140 {
141 return false;
142 }
143
144 override bool OnDoubleClick( Widget w, int x, int y, int button )
145 {
146 return false;
147 }
148
149 override bool OnMouseButtonDown( Widget w, int x, int y, int button )
150 {
151 if( w == m_FollowerButton && button == MouseState.LEFT )
152 {
153 if( m_Menu )
154 {
155 m_Menu.SelectActor( CTActor.Cast( this ) );
156 }
157 return true;
158 }
159 return false;
160 }
161
162 override bool OnMouseButtonUp( Widget w, int x, int y, int button )
163 {
164 if( w == m_FollowerButton && button == MouseState.LEFT )
165 {
166 if( m_Menu )
167 {
168 m_Menu.SelectActor( null );
169 }
170 return true;
171 }
172 return false;
173 }
174}
vector m_Orientation
protected vector m_Position
Cached world position.
Definition Effect.c:41
Icon x
Icon y
protected ServerBrowserMenuNew m_Menu
class JsonUndergroundAreaTriggerData GetPosition
proto native void ObjectDelete(Object obj)
proto native vector GetScreenPosRelative(vector world_pos)
Transforms position in world to position in screen in percentage (0.0 - 1.0) as x,...
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:538
void CreateFollowedObject(string type)
override bool OnDoubleClick(Widget w, int x, int y, int button)
void Update(float timeslice)
void UpdatePos()
Function updating the position of the tracker widget.
protected Widget m_FollowerRoot
void SetPosition(vector position)
protected Widget m_FollowerButton
protected EntityAI m_FollowedObject
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
override bool OnClick(Widget w, int x, int y, int button)
override bool OnMouseButtonUp(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:427
MouseState
Definition EnSystem.c:311
proto native void SetRotation(float roll, float pitch, float yaw, bool immedUpdate=true)