Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
ctobjectfollower.c
Go to the documentation of this file.
1class CTObjectFollower extends ScriptedWidgetEventHandler
2{
3 protected Widget m_FollowerRoot;
4 protected Widget m_FollowerButton;
5
6 protected vector m_Position;
7 protected vector m_Orientation;
8 protected EntityAI m_FollowedObject;
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 ) );
25 SetRotation( m_Orientation );
26 }
27
28 void DestroyFollowedObject()
29 {
30 if( m_FollowedObject )
31 {
32 GetGame().ObjectDelete( m_FollowedObject );
33 }
34 }
35
36 void Update( float timeslice )
37 {
38 UpdatePos();
39 }
40
41 EntityAI GetObj()
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
77 vector GetRotation()
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
void CTActor(int index, vector pos, vector orient, string type, array< string > items, string hands_item, CameraToolsMenu parent)
Definition ctactor.c:13
void Hide()
Definition dayzgame.c:170
void Show()
Definition dayzgame.c:162
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition dayzgame.c:151
vector m_Position
Cached world position.
Definition effect.c:43
proto native CGame GetGame()
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition effect.c:463
MouseState
Definition ensystem.c:311
class JsonUndergroundAreaTriggerData GetPosition
Icon x
Icon y
override bool OnDoubleClick(Widget w, int x, int y, int button)
bool OnMouseButtonDown(Widget w, int x, int y, int button)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition radialmenu.c:668
ServerBrowserMenuNew m_Menu