DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CrossHairSelector.c
См. документацию.
2{
3 protected string m_Name;
4 protected bool m_Shown;
5 protected bool m_Current;
6
7 protected Widget m_Widget;
8
10 {
11 m_Widget = w;
12 m_Name = w.GetName();
13 m_Shown = true;
14 m_Current = false;
15 }
16
17 string GetName()
18 {
19 return m_Name;
20 }
21
22 bool IsCurrent()
23 {
24 return m_Current;
25 }
26
27 bool IsShown()
28 {
29 return m_Shown;
30 }
31
32 void Show()
33 {
34 m_Shown = false;
35 m_Current = true;
36 m_Widget.Show(true);
37 }
38
39 void Hide()
40 {
41 m_Shown = true;
42 m_Current = false;
43 m_Widget.Show(false);
44 }
45
47 {
48 return m_Widget;
49 }
50}
51
53{
56
57 protected Widget m_Root;
58
59 protected ref set<ref CrossHair> m_CrossHairs;
60
63 protected bool m_PreviousDirectionSet;
64
66 {
67 m_Player = null;
68 m_AM = null;
69 m_CrossHairs = new set<ref CrossHair>;
70
71 g_Game.GetPostUpdateQueue(CALL_CATEGORY_GUI).Insert(Update);
72 }
73
75 {
76 g_Game.GetPostUpdateQueue(CALL_CATEGORY_GUI).Remove(Update);
77 }
78
79 protected void Init()
80 {
81 m_CrossHairs.Clear();
82
83 Widget child = m_Root.GetChildren();
84 while(child)
85 {
86 m_CrossHairs.Insert(CrossHair(child));
87 child = child.GetSibling();
88 }
89 }
90
91 protected void OnWidgetScriptInit(Widget w)
92 {
93 m_Root = w;
94 m_Root.SetHandler(this);
95 Init();
96 m_Root.Update();
97 }
98
99 protected void Update()
100 {
102 if(!g_Game.GetProfileOption(EDayZProfilesOptions.CROSSHAIR) || g_Game.GetWorld().IsCrosshairDisabled())
103 {
105 ShowCrossHair(null);
106
107 return;
108 }
109
110 if(m_Player && !m_Player.IsAlive()) // handle respawn
111 {
112 m_Player = null;
113 m_AM = null;
114 }
115
116 if(!m_Player)
117 GetPlayer();
118 if(!m_AM)
120
121 if(m_Player && m_Player.IsPlayerSelected())
123 }
124
125 // getters
126 protected void GetPlayer()
127 {
128 m_Player = PlayerBase.Cast(g_Game.GetPlayer());
129 }
130
131 protected void GetActionManager()
132 {
133 if(m_Player && m_Player.IsPlayerSelected())
134 m_AM = ActionManagerBase.Cast(m_Player.GetActionManager());
135 else
136 m_AM = null;
137 }
138
139 protected CrossHair GetCrossHairByName(string widgetName)
140 {
141 for(int i = 0; i < m_CrossHairs.Count(); i++)
142 {
143 if(m_CrossHairs.Get(i).GetName() == widgetName)
144 return m_CrossHairs.Get(i);
145 }
146
147 return null;
148 }
149
151 {
152 for(int i = 0; i < m_CrossHairs.Count(); i++)
153 {
154 if(m_CrossHairs.Get(i).IsCurrent())
155 return m_CrossHairs.Get(i);
156 }
157
158 return null;
159 }
160
161 protected void SelectCrossHair()
162 {
163 if(!m_AM)
164 return;
165
166 HumanInputController hic = m_Player.GetInputController();
167 ActionBase action = m_AM.GetRunningAction();
168
169 bool firearmInHands = m_Player.GetItemInHands() && m_Player.GetItemInHands().IsWeapon();
170
172 if (firearmInHands && m_Player.IsRaised() && !m_Player.IsInIronsights() && !m_Player.IsInOptics() && !hic.CameraIsFreeLook() && !m_Player.GetCommand_Melee2())
173 ShowCrossHair(GetCrossHairByName("crossT_128x128"));
175 else if (action && action.GetActionCategory() == AC_CONTINUOUS)
176 {
177 int actionState = m_AM.GetActionState(action);
178
179 if (actionState != UA_NONE)
180 ShowCrossHair(null);
181 }
183 else if ( m_Player.IsRaised() || m_Player.GetCommand_Melee2() || g_Game.GetUIManager().GetMenu() != null )
184 ShowCrossHair(null);
186 else if (m_Player.GetCommand_Unconscious())
187 ShowCrossHair(null);
189 else if (m_Player.IsInVehicle() && m_Player.IsInThirdPerson())
190 ShowCrossHair(null);
192 else
194 }
195
196 protected void ShowCrossHair(CrossHair crossHair)
197 {
199 if (!crossHair)
200 {
203
204 return;
205 }
206 else
207 {
208 if (GetCurrentCrossHair() && GetCurrentCrossHair() != crossHair)
210 }
211
213 if (!crossHair.IsCurrent() && crossHair.IsShown())
214 crossHair.Show();
215
216#ifdef WIP_TRACKIR
217 FloatingCrossHair(crossHair.GetWidget());
218#endif
219 }
220
223 {
224 HumanInputController hic = m_Player.GetInputController();
225
227 if (!hic.CameraIsTracking())
228 {
229 widget.SetPos(0, 0);
230 widget.Update();
231 return;
232 }
233
234 ActionBase action = m_AM.GetRunningAction();
235
236 float dt = GetDayZGame().GetDeltaT();
237
238 HumanCommandWeapons hcw = m_Player.GetCommandModifier_Weapons();
239
240 vector transform[4];
241 m_Player.GetTransformWS(transform);
242
243 vector aimAngles = Vector(hcw.GetBaseAimingAngleLR(), hcw.GetBaseAimingAngleUD(), 0.0);
244 vector plrAngles = Math3D.MatrixToAngles(transform);
245
246 aimAngles = Vector(0.0, hcw.GetBaseAimingAngleUD(), 0.0);
247 plrAngles = Vector(hic.GetHeadingAngle() * -Math.RAD2DEG, 0, 0);
248
249 vector resAngle = aimAngles + plrAngles;
250
251 vector start;
252 MiscGameplayFunctions.GetHeadBonePos(m_Player, start);
253
254 vector direction = resAngle.AnglesToVector();
255
256 int layer = ObjIntersectView;
257 float range = 1.0;
258
259 Weapon_Base weapon;
260 if (Class.CastTo(weapon, m_Player.GetItemInHands()) && m_Player.IsRaised())
261 {
262 layer = ObjIntersectFire;
263 range = 10.0;
264
265 vector usti_hlavne_position = weapon.GetSelectionPositionMS( "usti hlavne" );
266 vector konec_hlavne_position = weapon.GetSelectionPositionMS( "konec hlavne" );
267 usti_hlavne_position = m_Player.ModelToWorld(usti_hlavne_position);
268 konec_hlavne_position = m_Player.ModelToWorld(konec_hlavne_position);
269
270 vector contact_dir;
271 int contact_component;
272
273 direction = konec_hlavne_position - usti_hlavne_position;
274 direction.Normalize();
275
276 start = konec_hlavne_position;
277
279 }
280 else
281 {
283 {
285 m_PreviousDirection = direction;
286 }
287
288 float r0[4];
289 float r1[4];
290
291 vector t[4];
292
294 Math3D.MatrixToQuat(t, r0);
295
296 Math3D.DirectionAndUpMatrix(direction, vector.Up, t);
297 Math3D.MatrixToQuat(t, r1);
298
299 Math3D.QuatLerp(r0, r0, r1, 0.1);
300
301 Math3D.QuatToMatrix(r0, t);
302
303 direction = t[2];
304
305 m_PreviousDirection = direction;
306 }
307
308 vector end = start + (direction * range);
309 vector position = end;
310
311 DayZPhysics.RaycastRV(start, end, position, contact_dir, contact_component, null, m_Player, m_Player, false, false, layer);
312
313 /*
314 vector lines[2];
315 lines[0] = start;
316 lines[1] = end;
317
318 Shape.CreateSphere(0xFFFFFF00, ShapeFlags.ONCE, usti_hlavne_position, 0.1);
319 Shape.CreateSphere(0xFFFFFF00, ShapeFlags.ONCE, konec_hlavne_position, 0.1);
320 Shape.CreateLines(0xFF00FF00, ShapeFlags.ONCE, lines, 2);
321 */
322
323 vector screenSpace = g_Game.GetScreenPos(position);
324
325 float sx, sy;
326 widget.GetScreenSize(sx, sy);
327 screenSpace[0] = screenSpace[0] - (sx * 0.5);
328 screenSpace[1] = screenSpace[1] - (sy * 0.5);
329
330 widget.SetScreenPos(screenSpace[0], screenSpace[1]);
331 widget.Update();
332 }
333}
const int AC_CONTINUOUS
void ActionBase()
Определения ActionBase.c:82
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
ActionManagerBase m_AM
Определения CrossHairSelector.c:55
void SelectCrossHair()
Определения CrossHairSelector.c:161
vector m_PreviousDirection
Floating crosshair.
Определения CrossHairSelector.c:62
void CrossHairSelector()
Определения CrossHairSelector.c:65
CrossHair GetCrossHairByName(string widgetName)
Определения CrossHairSelector.c:139
void FloatingCrossHair(Widget widget)
Highly WIP, do not use.
Определения CrossHairSelector.c:222
void ShowCrossHair(CrossHair crossHair)
Определения CrossHairSelector.c:196
CrossHair GetCurrentCrossHair()
Определения CrossHairSelector.c:150
bool m_PreviousDirectionSet
Определения CrossHairSelector.c:63
ref set< ref CrossHair > m_CrossHairs
Определения CrossHairSelector.c:59
void ~CrossHairSelector()
Определения CrossHairSelector.c:74
DayZGame g_Game
Определения DayZGame.c:4074
DayZGame GetDayZGame()
Определения DayZGame.c:4076
vector position
Определения DustKickupEffects.c:20
EDayZProfilesOptions
Определения EDayZProfilesOptions.c:2
DayZPlayer m_Player
Определения Hand_Events.c:42
Widget m_Root
Определения SizeToChild.c:91
Super root of all classes in Enforce script.
Определения EnScript.c:11
Widget GetWidget()
Определения CrossHairSelector.c:46
void Hide()
Определения CrossHairSelector.c:39
bool IsShown()
Определения CrossHairSelector.c:27
bool m_Current
Определения CrossHairSelector.c:5
bool m_Shown
Определения CrossHairSelector.c:4
void Show()
Определения CrossHairSelector.c:32
string GetName()
Определения CrossHairSelector.c:17
void CrossHair(Widget w)
Определения CrossHairSelector.c:9
string m_Name
Определения CrossHairSelector.c:3
Widget m_Widget
Определения CrossHairSelector.c:7
bool IsCurrent()
Определения CrossHairSelector.c:22
Определения CrossHairSelector.c:2
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.
Определения DayZPhysics.c:124
proto native float GetBaseAimingAngleLR()
returns base aiming angle LR - without sway/offsets/...
proto native float GetBaseAimingAngleUD()
returns base aiming angle UD - without sway/offsets/...
Определения human.c:1027
proto native bool CameraIsFreeLook()
returns true if freelook is active
proto native bool CameraIsTracking()
returns if camera is tracking (using IR device)
proto native float GetHeadingAngle()
returns main heading angle (in radians) -PI .. PI (this is world Y angle player is actualy pointing t...
Определения human.c:18
Определения EnMath3D.c:28
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
void OnWidgetScriptInit(Widget w)
Определения SizeToChild.c:14
void Init()
Определения MainMenuPromo.c:47
Deprecated.
Определения EnWidgets.c:657
shorthand
Определения BoltActionRifle_Base.c:6
Определения EnWidgets.c:190
proto float Normalize()
Normalizes vector. Returns length.
static const vector Up
Определения EnConvert.c:120
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
Определения EnConvert.c:119
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto void QuatToMatrix(float q[4], out vector mat[3])
Converts quaternion to rotation matrix.
static proto vector MatrixToAngles(vector mat[3])
Returns angles of rotation matrix.
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)
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4])
Creates rotation matrix from direction and up vector.
static const float RAD2DEG
Определения EnMath.c:16
const int CALL_CATEGORY_GUI
Определения 3_Game/DayZ/tools/tools.c:9
const int UA_NONE
Определения 3_Game/DayZ/constants.c:494
proto native volatile void Update()
Определения PlayerSoundManager.c:125