Dayz 1.25
Dayz Code Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл CrossHairSelector.c

См. исходные тексты.

Структуры данных

class  CrossHair
 

Функции

void CrossHairSelector ()
 
void ~CrossHairSelector ()
 
void Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
void OnWidgetScriptInit (Widget w)
 
void Update ()
 
void GetPlayer ()
 
void GetActionManager ()
 
CrossHair GetCrossHairByName (string widgetName)
 
CrossHair GetCurrentCrossHair ()
 
void SelectCrossHair ()
 
void ShowCrossHair (CrossHair crossHair)
 
void FloatingCrossHair (Widget widget)
 Highly WIP, do not use.
 

Переменные

class CrossHair m_Player
 
ActionManagerBase m_AM
 
Widget m_Root
 
ref set< ref CrossHairm_CrossHairs
 
vector m_PreviousDirection
 Floating crosshair.
 
bool m_PreviousDirectionSet
 

Функции

◆ CrossHairSelector()

void CrossHairSelector ( )
protected
68 {
69 m_Player = null;
70 m_AM = null;
72
73 GetGame().GetPostUpdateQueue(CALL_CATEGORY_GUI).Insert(Update);
74 }
ActionManagerBase m_AM
Definition CrossHairSelector.c:57
class CrossHair m_Player
ref set< ref CrossHair > m_CrossHairs
Definition CrossHairSelector.c:61
Definition EntityAI.c:95
proto native CGame GetGame()
const int CALL_CATEGORY_GUI
Definition tools.c:9
void Update()
Definition CrossHairSelector.c:101

Перекрестные ссылки CALL_CATEGORY_GUI, GetGame(), m_AM, m_CrossHairs, m_Player и Update().

◆ FloatingCrossHair()

void FloatingCrossHair ( Widget widget)
protected

Highly WIP, do not use.

Only intended to be used with track IR

230 {
231 HumanInputController hic = m_Player.GetInputController();
232
234 if (!hic.CameraIsTracking())
235 {
236 widget.SetPos(0, 0);
237 widget.Update();
238 return;
239 }
240
241 ActionBase action = m_AM.GetRunningAction();
242
243 float dt = GetDayZGame().GetDeltaT();
244
245 HumanCommandWeapons hcw = m_Player.GetCommandModifier_Weapons();
246
247 vector transform[4];
248 m_Player.GetTransformWS(transform);
249
250 vector aimAngles = Vector(hcw.GetBaseAimingAngleLR(), hcw.GetBaseAimingAngleUD(), 0.0);
252
253 aimAngles = Vector(0.0, hcw.GetBaseAimingAngleUD(), 0.0);
254 plrAngles = Vector(hic.GetHeadingAngle() * -Math.RAD2DEG, 0, 0);
255
257
259 MiscGameplayFunctions.GetHeadBonePos(m_Player, start);
260
261 vector direction = resAngle.AnglesToVector();
262
264 float range = 1.0;
265
267 if (Class.CastTo(weapon, m_Player.GetItemInHands()) && m_Player.IsRaised())
268 {
270 range = 10.0;
271
272 vector usti_hlavne_position = weapon.GetSelectionPositionMS( "usti hlavne" );
273 vector konec_hlavne_position = weapon.GetSelectionPositionMS( "konec hlavne" );
276
279
281 direction.Normalize();
282
284
286 }
287 else
288 {
290 {
293 }
294
295 float r0[4];
296 float r1[4];
297
298 vector t[4];
299
302
305
306 Math3D.QuatLerp(r0, r0, r1, 0.1);
307
309
310 direction = t[2];
311
313 }
314
317
319
320 /*
321 vector lines[2];
322 lines[0] = start;
323 lines[1] = end;
324
325 Shape.CreateSphere(0xFFFFFF00, ShapeFlags.ONCE, usti_hlavne_position, 0.1);
326 Shape.CreateSphere(0xFFFFFF00, ShapeFlags.ONCE, konec_hlavne_position, 0.1);
327 Shape.CreateLines(0xFF00FF00, ShapeFlags.ONCE, lines, 2);
328 */
329
330 vector screenSpace = GetGame().GetScreenPos(position);
331
332 float sx, sy;
333 widget.GetScreenSize(sx, sy);
334 screenSpace[0] = screenSpace[0] - (sx * 0.5);
335 screenSpace[1] = screenSpace[1] - (sy * 0.5);
336
337 widget.SetScreenPos(screenSpace[0], screenSpace[1]);
338 widget.Update();
339 }
vector m_PreviousDirection
Floating crosshair.
Definition CrossHairSelector.c:64
bool m_PreviousDirectionSet
Definition CrossHairSelector.c:65
DayZGame GetDayZGame()
Definition DayZGame.c:3748
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition DayZPhysics.c:124
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
Definition human.c:987
Definition human.c:18
Definition EnMath3D.c:28
Definition EnMath.c:7
shorthand
Definition BoltActionRifle_Base.c:6
Definition EnConvert.c:106
static const vector Up
Definition EnConvert.c:107
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto vector MatrixToAngles(vector mat[3])
Returns angles of rotation matrix.
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void QuatToMatrix(float q[4], out vector mat[3])
Converts quaternion to rotation matrix.
static proto void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4])
Creates rotation matrix from direction and up vector.
static proto void QuatLerp(out float qout[4], float q1[4], float q2[4], float frac)
Linear interpolation between q1 and q2 with weight 'frac' (0...1)
static const float RAD2DEG
Definition EnMath.c:16

Перекрестные ссылки Class::CastTo(), Math3D::DirectionAndUpMatrix(), GetDayZGame(), GetGame(), DayZPlayer::IsRaised(), m_AM, m_Player, m_PreviousDirection, m_PreviousDirectionSet, Math3D::MatrixToAngles(), Math3D::MatrixToQuat(), Math3D::QuatLerp(), Math3D::QuatToMatrix(), Math::RAD2DEG, DayZPhysics::RaycastRV(), vector::Up и Vector().

Используется в ShowCrossHair().

◆ GetActionManager()

◆ GetCrossHairByName()

CrossHair GetCrossHairByName ( string widgetName)
protected
143 {
144 for(int i = 0; i < m_CrossHairs.Count(); i++)
145 {
146 if(m_CrossHairs.Get(i).GetName() == widgetName)
147 return m_CrossHairs.Get(i);
148 }
149
150 return null;
151 }

Перекрестные ссылки m_CrossHairs.

Используется в SelectCrossHair().

◆ GetCurrentCrossHair()

CrossHair GetCurrentCrossHair ( )
protected
154 {
155 for(int i = 0; i < m_CrossHairs.Count(); i++)
156 {
157 if(m_CrossHairs.Get(i).IsCurrent())
158 return m_CrossHairs.Get(i);
159 }
160
161 return null;
162 }

Перекрестные ссылки m_CrossHairs.

Используется в ShowCrossHair() и Update().

◆ GetPlayer()

void GetPlayer ( )
protected
128 {
130 }
void GetPlayer()
Definition CrossHairSelector.c:127

Перекрестные ссылки Class::CastTo(), GetGame(), ScriptedWidgetEventHandler::GetPlayer() и m_Player.

◆ Init()

void Init ( )
protected

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

pre-init arrays

82 {
83 m_CrossHairs.Clear();
84
85 Widget child = m_Root.GetChildren();
86 while(child)
87 {
89 child = child.GetSibling();
90 }
91 }
Widget m_Root
Definition CrossHairSelector.c:59
Definition CrossHairSelector.c:2
Definition EnWidgets.c:190

Перекрестные ссылки m_CrossHairs и m_Root.

◆ OnWidgetScriptInit()

void OnWidgetScriptInit ( Widget w)
protected
94 {
95 m_Root = w;
96 m_Root.SetHandler(this);
97 Init();
98 m_Root.Update();
99 }
void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition CrossHairSelector.c:81

Перекрестные ссылки ScriptedWidgetEventHandler::Init() и m_Root.

◆ SelectCrossHair()

void SelectCrossHair ( )
protected

firearms

On Continuous Actions

raised hands(bare + non-firearm) + melee cmd

handle unconscious state

default

165 {
166 if(!m_AM) return;
167
168 HumanInputController hic = m_Player.GetInputController();
169 ActionBase action = m_AM.GetRunningAction();
170
171 bool firearmInHands = m_Player.GetItemInHands() && m_Player.GetItemInHands().IsWeapon();
172
174 if ( firearmInHands && m_Player.IsRaised() && !m_Player.IsInIronsights() && !m_Player.IsInOptics() && !hic.CameraIsFreeLook() && !m_Player.GetCommand_Melee2() )
175 {
176 ShowCrossHair(GetCrossHairByName("crossT_128x128"));
177 }
179 else if (action && action.GetActionCategory() == AC_CONTINUOUS)
180 {
181 int actionState = m_AM.GetActionState(action);
182
183 if ( actionState != UA_NONE )
185 }
187 else if ( m_Player.IsRaised() || m_Player.GetCommand_Melee2() || GetGame().GetUIManager().GetMenu() != null )
188 {
190 }
192 else if ( m_Player.GetCommand_Unconscious() )
193 {
195 }
197 else
198 {
200 }
201 }
const int AC_CONTINUOUS
Definition _constants.c:3
CrossHair GetCrossHairByName(string widgetName)
Definition CrossHairSelector.c:142
void ShowCrossHair(CrossHair crossHair)
Definition CrossHairSelector.c:203
const int UA_NONE
Definition constants.c:432

Перекрестные ссылки AC_CONTINUOUS, GetCrossHairByName(), GetGame(), DayZPlayer::IsInIronsights(), DayZPlayer::IsInOptics(), DayZPlayer::IsRaised(), m_AM, m_Player, ShowCrossHair() и UA_NONE.

Используется в Update().

◆ ShowCrossHair()

void ShowCrossHair ( CrossHair crossHair)
protected

no crosshair + clean + hide the previous

hide prev crosshair

show the new one

204 {
206 if (!crossHair)
207 {
210
211 return;
212 }
213 else
214 {
217 }
218
220 if (!crossHair.IsCurrent() && crossHair.IsShown())
221 crossHair.Show();
222
223#ifdef WIP_TRACKIR
224 FloatingCrossHair(crossHair.GetWidget());
225#endif
226 }
void FloatingCrossHair(Widget widget)
Highly WIP, do not use.
Definition CrossHairSelector.c:229
CrossHair GetCurrentCrossHair()
Definition CrossHairSelector.c:153
void Hide()
Definition CrossHairSelector.c:41

Перекрестные ссылки FloatingCrossHair(), GetCurrentCrossHair() и CrossHair::Hide().

Используется в SelectCrossHair() и Update().

◆ ~CrossHairSelector()

void ~CrossHairSelector ( )
protected
77 {
78 GetGame().GetPostUpdateQueue(CALL_CATEGORY_GUI).Remove(Update);
79 }

Перекрестные ссылки CALL_CATEGORY_GUI, GetGame() и Update().

Переменные

◆ m_AM

◆ m_CrossHairs

ref set<ref CrossHair> m_CrossHairs
protected

◆ m_Player

class CrossHair m_Player

◆ m_PreviousDirection

vector m_PreviousDirection
protected

Floating crosshair.

Используется в FloatingCrossHair().

◆ m_PreviousDirectionSet

bool m_PreviousDirectionSet
protected

Используется в FloatingCrossHair().

◆ m_Root

Widget m_Root
protected