Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ctobjectfollower.c
Go to the documentation of this file.
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 
15  void ~CTObjectFollower()
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 
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 
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 }
GetGame
proto native CGame GetGame()
Show
proto native void Show(bool show, bool immedUpdate=true)
m_Position
protected vector m_Position
Cached world position.
Definition: effect.c:41
y
Icon y
m_Menu
protected ServerBrowserMenuNew m_Menu
Definition: serverbrowsertab.c:30
SetRotation
proto native void SetRotation(float roll, float pitch, float yaw, bool immedUpdate=true)
CTObjectFollower
Definition: ctactor.c:1
OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition: radialmenu.c:668
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
OnDoubleClick
override bool OnDoubleClick(Widget w, int x, int y, int button)
Definition: missionloader.c:84
m_Orientation
vector m_Orientation
Definition: bleedingsource.c:15
MouseState
MouseState
Definition: ensystem.c:310
GetRotation
proto native vector GetRotation()
returns rotation of widget in order roll, pitch, yaw
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
x
Icon x
OnMouseButtonDown
bool OnMouseButtonDown(Widget w, int x, int y, int button)
Definition: pluginitemdiagnostic.c:117
SetPosition
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition: effect.c:436
Widget
Definition: enwidgets.c:189
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
Hide
void Hide()
Definition: dayzgame.c:165
EntityAI
Definition: building.c:5
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650