forked from themrdemonized/xray-monolith
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHudItem.h
More file actions
315 lines (250 loc) · 8.46 KB
/
HudItem.h
File metadata and controls
315 lines (250 loc) · 8.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#pragma once
class CSE_Abstract;
class CPhysicItem;
class NET_Packet;
class CInventoryItem;
class CMotionDef;
class CUIWindow;
#include "actor_defs.h"
#include "inventory_space.h"
#include "hudsound.h"
#include "HUDManager.h"
#define TENDTO_SPEED 1.0f // Модификатор силы инерции (больше - чувствительней)
#define TENDTO_SPEED_AIM 1.0f // (Для прицеливания)
#define TENDTO_SPEED_RET 5.0f // Модификатор силы отката инерции (больше - быстрее)
#define TENDTO_SPEED_RET_AIM 5.0f // (Для прицеливания)
#define INERT_MIN_ANGLE 0.0f // Минимальная сила наклона, необходимая для старта инерции
#define INERT_MIN_ANGLE_AIM 3.5f // (Для прицеливания)
// Пределы смещения при инерции (лево / право / верх / низ)
#define ORIGIN_OFFSET 0.04f, 0.04f, 0.04f, 0.02f
#define ORIGIN_OFFSET_AIM 0.015f, 0.015f, 0.01f, 0.005f
struct attachable_hud_item;
class motion_marks;
enum ENearWallMode {
NW_OFF = 0,
NW_FOV,
NW_POS,
NW_MAX
};
enum ENearWallTrace {
NT_CAM = 0,
NT_ITEM,
NT_MAX
};
class CHUDState
{
public:
enum EHudStates
{
eIdle = 0,
eShowing,
eHiding,
eHidden,
eBore,
eLastBaseState = eBore,
};
private:
u32 m_hud_item_state;
u32 m_nextState;
u32 m_dw_curr_state_time;
protected:
u32 m_dw_curr_substate_time;
u32 m_lastState;
public:
CHUDState() { SetState(eHidden); }
IC u32 GetNextState() const { return m_nextState; }
IC u32 GetState() const { return m_hud_item_state; }
IC void SetState(u32 v)
{
m_hud_item_state = v;
m_dw_curr_state_time = Device.dwTimeGlobal;
ResetSubStateTime();
}
IC void SetNextState(u32 v) { m_nextState = v; }
IC u32 CurrStateTime() const { return Device.dwTimeGlobal - m_dw_curr_state_time; }
IC void ResetSubStateTime() { m_dw_curr_substate_time = Device.dwTimeGlobal; }
virtual void SwitchState(u32 S) = 0;
virtual void OnStateSwitch(u32 S, u32 oldState) = 0;
};
class CHudItem : public CHUDState
{
protected:
CHudItem();
virtual ~CHudItem();
virtual DLL_Pure* _construct();
Flags16 m_huditem_flags;
enum
{
fl_pending = (1 << 0),
fl_renderhud = (1 << 1),
fl_inertion_enable = (1 << 2),
fl_inertion_allow = (1 << 3),
};
struct
{
const CMotionDef* m_current_motion_def;
shared_str m_current_motion;
u32 m_dwMotionCurrTm;
u32 m_dwMotionStartTm;
u32 m_dwMotionEndTm;
u32 m_startedMotionState;
u8 m_started_rnd_anim_idx;
bool m_bStopAtEndAnimIsRunning;
};
attachable_hud_item* m_attachable;
float m_fLR_CameraFactor; // Фактор бокового наклона худа при ходьбе [-1; +1]
float m_fLR_MovingFactor; // Фактор бокового наклона худа при движении камеры [-1; +1]
float m_fLR_InertiaFactor; // Фактор горизонтальной инерции худа при движении камеры [-1; +1]
float m_fUD_InertiaFactor; // Фактор вертикальной инерции худа при движении камеры [-1; +1]
CUIWindow* script_ui;
LPCSTR script_ui_funct;
LPCSTR script_ui_bone;
Fvector script_ui_offset[2]; //pos, rot
Fmatrix script_ui_matrix;
public:
virtual void Load(LPCSTR section);
virtual BOOL net_Spawn(CSE_Abstract* DC) { return TRUE; };
virtual void net_Destroy()
{
};
virtual void OnEvent(NET_Packet& P, u16 type);
virtual void OnH_A_Chield();
virtual void OnH_B_Chield();
virtual void OnH_B_Independent(bool just_before_destroy);
virtual void OnH_A_Independent();
virtual void PlaySound(LPCSTR alias, const Fvector& position);
virtual void PlaySound(LPCSTR alias, const Fvector& position, u8 index); //Alundaio: Play at index
virtual bool Action(u16 cmd, u32 flags) { return false; }
virtual void OnMovementChanged(ACTOR_DEFS::EMoveCommand cmd);
virtual u8 GetCurrentHudOffsetIdx() { return 0; }
BOOL GetHUDmode();
void PlayBlendAnm(LPCSTR name, float speed = 1.f, float power = 1.f, bool stop_old = true);
IC bool IsPending() const { return !!m_huditem_flags.test(fl_pending); }
virtual void DeleteHudItemData();
virtual bool ActivateItem();
virtual void DeactivateItem();
virtual void SendDeactivateItem();
virtual void OnActiveItem()
{
};
virtual void OnHiddenItem()
{
};
virtual void SendHiddenItem(); //same as OnHiddenItem but for client... (sends message to a server)...
virtual void OnMoveToRuck(const SInvItemPlace& prev);
bool IsHidden() const { return GetState() == eHidden; } // Does weapon is in hidden state
bool IsHiding() const { return GetState() == eHiding; }
bool IsShowing() const { return GetState() == eShowing; }
virtual void SwitchState(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);
virtual void OnAnimationEnd(u32 state);
virtual void OnMotionMark(u32 state, const motion_marks& M);
virtual void PlayAnimIdle();
virtual bool TryPlayAnimBore();
virtual bool TryPlayAnimIdle();
virtual bool MovingAnimAllowedNow() { return true; }
virtual bool NeedBlendAnm();
virtual void PlayAnimIdleMoving();
virtual void PlayAnimIdleSprint();
virtual void UpdateCL();
virtual void renderable_Render();
virtual void UpdateHudAdditional(Fmatrix& trans);
virtual void UpdateXForm() = 0;
u32 PlayHUDMotion(shared_str M, BOOL bMixIn, CHudItem* W, u32 state, float speed = 1.f, float end = 0.f, bool bMixIn2 = true);
u32 PlayHUDMotion_noCB(const shared_str& M, BOOL bMixIn, float speed = 1.f, bool bMixIn2 = true);
void StopCurrentAnimWithoutCallback();
IC void RenderHud(BOOL B) { m_huditem_flags.set(fl_renderhud, B); }
IC BOOL RenderHud() { return m_huditem_flags.test(fl_renderhud); }
attachable_hud_item* HudItemData();
bool IsAttachedToHUD();
virtual bool ParentIsActor();
virtual float GetNearWallRange();
virtual float GetBaseHudFov();
virtual float GetTargetHudFov();
virtual float GetTargetNearWallOffset();
float GetNearWallOffset();
float GetHudFov();
virtual void on_outfit_changed();
virtual void on_a_hud_attach();
virtual void on_b_hud_detach();
IC BOOL HudInertionEnabled() const { return m_huditem_flags.test(fl_inertion_enable); }
IC BOOL HudInertionAllowed() const { return m_huditem_flags.test(fl_inertion_allow); }
virtual float GetInertionAimFactor() { return 1.f; }; //--#SM+#--
virtual void render_hud_mode()
{
};
virtual bool need_renderable() { return true; };
virtual void render_item_3d_ui();
virtual bool render_item_3d_ui_query() { return true; }
virtual bool CheckCompatibility(CHudItem*) { return true; }
protected:
IC void SetPending(bool H) { m_huditem_flags.set(fl_pending, H); }
shared_str hud_sect;
//êàäðû ìîìåíòà ïåðåñ÷åòà XFORM è FirePos
u32 dwFP_Frame;
u32 dwXF_Frame;
IC void EnableHudInertion(BOOL B) { m_huditem_flags.set(fl_inertion_enable, B); }
IC void AllowHudInertion(BOOL B) { m_huditem_flags.set(fl_inertion_allow, B); }
u32 m_animation_slot;
HUD_SOUND_COLLECTION_LAYERED m_sounds;
private:
CPhysicItem* m_object;
CInventoryItem* m_item;
public:
const shared_str& HudSection() const { return hud_sect; }
bool has_object() const
{
return m_object;
}
IC CPhysicItem& object() const
{
VERIFY(m_object);
return (*m_object);
}
IC CInventoryItem& item() const
{
VERIFY(m_item);
return (*m_item);
}
IC u32 animation_slot() { return m_animation_slot; }
virtual void on_renderable_Render() = 0;
virtual void debug_draw_firedeps()
{
};
float m_hud_fov_add_mod;
float m_nearwall_dist_max;
float m_nearwall_dist_min;
float m_nearwall_factor;
float m_nearwall_target_hud_fov;
float m_nearwall_speed_mod;
float m_base_fov;
float m_hud_fov;
float m_nearwall_ofs;
virtual CHudItem* cast_hud_item() { return this; }
virtual bool PlayAnimCrouchIdleMoving(); //AVO: new crouch idle animation
bool HudAnimationExist(LPCSTR anim_name);
private:
SPickParam PP;
public:
virtual void OnFrame();
void net_Relcase(CObject* O);
virtual Fmatrix RayTransform();
virtual void g_fireParams(SPickParam& pp);
virtual void Ray(SPickParam& pp);
SPickParam& GetPick() { return PP; };
collide::rq_result& GetRQ() { return GetPick().result; };
float GetRQVis() { return PP.power; };
};
class CAnonHudItem : public CHudItem
{
private:
typedef CHudItem inherited;
public:
CAnonHudItem();
virtual ~CAnonHudItem();
virtual void UpdateXForm();
virtual void on_renderable_Render();
virtual bool TryPlayAnimIdle() { return false; }
virtual void UpdateHudAdditional(Fmatrix& trans) { }
DECLARE_SCRIPT_REGISTER_FUNCTION
};