DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
HitDirectionBase.c
См. документацию.
1
2
4{
5 const float DURATION_COEF_MIN = 0.6;
6 const float INTENSITY_MIN = 0.6;
7
9 float m_Duration;
13
16
18
22 float m_PosX;
23 float m_PosY;
28 float m_SmoothVel[1];
29
31
33 {
34 m_Initialized = false;
35 m_PosX = 0.0;
36 m_PosY = 0.0;
37 m_AngleRad = 0.0;
38 m_SmoothVel[0] = 0.0;
39
41 m_ImageData.GetCurrentImageData(m_LayoutRoot,m_Image);
42 }
43
45 void Init(DayZPlayer player, float hit_direction, float intensity_max)
46 {
47 m_Player = player;
48 float duration_coef = Math.Clamp(intensity_max,DURATION_COEF_MIN,1);
49 m_IntensityMax = Math.Clamp(intensity_max,INTENSITY_MIN,1);
50 m_Duration = m_DurationMax * duration_coef;
52 m_Scatter = Math.Clamp(m_Scatter,0.0,180.0);
54
56 w = w.GetChildren();
57 while (w)
58 {
59 w.Show(m_Image == w);
60 w = w.GetSibling();
61 }
62
63 m_Image.SetColor(m_Color);
64
65 m_LayoutRoot.Show(true);
66
70 m_Initialized = true;
71 }
72
74
76 {
77 m_LayoutRoot.Show(false);
78 delete m_LayoutRoot;
79 }
80
82 {
83 if ( m_TimeActive >= m_Duration )
84 {
85 return true;
86 }
87 return false;
88 }
89
90 void Update( float timeslice )
91 {
92 float intensity;
93
95 {
96 intensity = m_IntensityMax;
97 }
98 else
99 {
101 intensity = Math.Lerp(m_IntensityMax,0.0,tmp_value);
102 }
103
104 m_TimeActive += timeslice;
105 intensity = Math.Clamp(intensity,0,1);
106
107 if ( m_TimeActive >= m_Duration )
108 {
109 m_LayoutRoot.Show(false);
110 }
111 else
112 {
113 m_LayoutRoot.SetAlpha(intensity);
114 if ( m_Mode == HitDirectionModes.DYNAMIC )
115 {
116 CalculateArrowPosition(timeslice);
117 SetIndicatorPositon(timeslice);
118 SetIndicatorRotation(timeslice);
119 }
120 }
121 }
122
123 void CalculateArrowPosition(float timeslice = -1.0)
124 {
126
127 float angle_direction = m_Player.GetOrientation()[0];
128 angle_direction = Math.NormalizeAngle(angle_direction);
129 float camera_angle = GetGame().GetCurrentCameraDirection().VectorToAngles()[0];
130 camera_angle = Math.NormalizeAngle(camera_angle);
131
132 float angle_camera_diff = angle_direction - camera_angle;
133 m_AngleRad = m_HitDirection + angle_camera_diff;
136
137 m_PosX = 0.0;
138 m_PosY = 0.0;
139
141
142 if ( m_Initialized && timeslice != -1.0 )
143 {
144 float val = m_AngleRadPrev - m_AngleRad + Math.PI;
145 val = Math.ModFloat(val, Math.PI2);
146 val -= Math.PI;
147 m_AngleRad = m_AngleRadPrev - Math.SmoothCD(0, val, m_SmoothVel, 0.1, 1000, timeslice);
148 }
150
153
155 }
156
159 void SetIndicatorRotation(float timeslice = -1.0){}
160
161 void SetIndicatorPositon(float timeslice = -1.0)
162 {
163 m_LayoutRoot.SetPos(m_PosX,m_PosY,true);
164 }
165
166 //-----------------------------------------------------------------------
167 //Static stuff below
168 //-----------------------------------------------------------------------
170 static int m_Mode;
171 static int m_ID;
172 static int m_Color;
173 static protected typename m_Type;
174 static float m_DurationMax;
175 static float m_BreakPointBase;
176 static float m_DistanceAdjust;
178 static float m_Scatter;
179
181 static void CheckValues()
182 {
185 {
192 }
193 else
194 {
195 m_Mode = HitDirectionModes.STATIC;
196 m_ID = HitIndicatorType.SPLASH;
197 m_Color = HitDirectionConstants.COLOR_DEFAULT;
198 m_DurationMax = HitDirectionConstants.DURATION_BASE;
199 m_BreakPointBase = HitDirectionConstants.BREAKPOINT_BASE;
200 m_Scatter = HitDirectionConstants.SCATTER;
201 }
202 m_DistanceAdjust = HitDirectionConstants.DISTANCE_ADJUST;
203 m_RotationOverride = HitDirectionConstants.ROTATION_DEFAULT;
204 }
205
206 static typename GetCurrentType()
207 {
208 switch (m_ID)
209 {
210 case HitIndicatorType.SPLASH:
211 m_Type = HitDirectionEffectSplash;
212 break;
213
214 case HitIndicatorType.SPIKE:
215 m_Type = HitDirectionEffectSpike;
216 break;
217
218 case HitIndicatorType.ARROW:
219 m_Type = HitDirectionEffectArrow;
220 break;
221
222 default:
223 ErrorEx("Unknown HitDirection mode, using HitIndicatorType.SPLASH",ErrorExSeverity.INFO);
224 m_Type = HitDirectionEffectSplash;
225 break;
226 }
227
228 return m_Type;
229 }
230}
proto native vector GetCurrentCameraDirection()
static bool GetHitIndicationOverrideEnabled()
Определения CfgGameplayHandler.c:342
static int GetHitIndicationIndicatorColor()
Определения CfgGameplayHandler.c:357
static int GetHitIndicationMode()
Определения CfgGameplayHandler.c:347
static float GetHitIndicationMaxDuration()
Определения CfgGameplayHandler.c:362
static int GetHitIndicationTypeID()
Определения CfgGameplayHandler.c:352
static float GetHitIndicationBreakPoint()
Определения CfgGameplayHandler.c:367
static float GetHitIndicationScatter()
Определения CfgGameplayHandler.c:372
static int m_RotationOverride
Определения HitDirectionBase.c:177
static float m_Scatter
Определения HitDirectionBase.c:178
ref HitDirectionImagesBase m_ImageData
Определения HitDirectionBase.c:30
float m_PosYScreenEdge
Определения HitDirectionBase.c:25
void CalculateArrowPosition(float timeslice=-1.0)
Определения HitDirectionBase.c:123
float m_IntensityMax
Определения HitDirectionBase.c:12
Widget m_Image
Определения HitDirectionBase.c:15
void ~HitDirectionEffectBase()
Определения HitDirectionBase.c:75
float m_BreakPoint
Определения HitDirectionBase.c:10
void Update(float timeslice)
Определения HitDirectionBase.c:90
override HitDirectionImagesBase GetImageData()
Определения HitDirectionArrow.c:4
float m_HitDirection
Определения HitDirectionBase.c:8
const float DURATION_COEF_MIN
Определения HitDirectionBase.c:5
static int m_Color
Определения HitDirectionBase.c:172
static int m_ID
Определения HitDirectionBase.c:171
static int m_Mode
Определения HitDirectionBase.c:170
float m_SmoothVel[1]
Определения HitDirectionBase.c:28
override void FinalizePositionCalculation()
Определения HitDirectionArrow.c:11
float m_PosY
Определения HitDirectionBase.c:23
float m_Duration
Определения HitDirectionBase.c:9
float m_PosX
Определения HitDirectionBase.c:22
DayZPlayer m_Player
Определения HitDirectionBase.c:17
bool DurationCheck()
Определения HitDirectionBase.c:81
static float m_DurationMax
Определения HitDirectionBase.c:174
void SetIndicatorPositon(float timeslice=-1.0)
Определения HitDirectionBase.c:161
Widget m_LayoutRoot
Определения HitDirectionBase.c:14
void Init(DayZPlayer player, float hit_direction, float intensity_max)
Called manually after object spawn.
Определения HitDirectionBase.c:45
static float m_BreakPointBase
Определения HitDirectionBase.c:175
int m_SizeXEnf
Определения HitDirectionBase.c:20
bool m_Initialized
Определения HitDirectionBase.c:19
static GetCurrentType()
Определения HitDirectionBase.c:206
float m_TimeActive
Определения HitDirectionBase.c:11
static void CheckValues()
range 0..180, randomized offset of direction to make it less acurate
Определения HitDirectionBase.c:181
int m_SizeYEnf
Определения HitDirectionBase.c:21
void SetIndicatorRotation(float timeslice=-1.0)
Определения HitDirectionBase.c:159
static float m_DistanceAdjust
range 0..1, a point where the fading starts
Определения HitDirectionBase.c:176
void FinalizePositionCalculation()
specific handling on individual indicator type
Определения HitDirectionBase.c:158
HitDirectionImagesBase GetImageData()
Определения HitDirectionBase.c:73
static bool m_ServerOverrideEnabled
Определения HitDirectionBase.c:169
float m_PosXScreenEdge
Определения HitDirectionBase.c:24
void HitDirectionEffectBase()
Определения HitDirectionBase.c:32
const float INTENSITY_MIN
Определения HitDirectionBase.c:6
float m_AngleRadPrev
Определения HitDirectionBase.c:27
float m_AngleRad
Определения HitDirectionBase.c:26
override void SetIndicatorRotation(float timeslice=-1.0)
Определения HitDirectionArrow.c:20
Определения EnMath.c:7
Определения EnWidgets.c:190
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
proto native CGame GetGame()
HitDirectionModes
Определения constants.c:98
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
static const float PI2
Определения EnMath.c:13
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float ModFloat(float x, float y)
Returns the floating-point remainder of x/y rounded towards zero.
static proto float NormalizeAngle(float ang)
Normalizes the angle (0...360)
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:106
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float Pow(float v, float power)
Return power of v ^ power.
static const float DEG2RAD
Определения EnMath.c:17
static proto float SmoothCD(float val, float target, inout float velocity[], float smoothTime, float maxVelocity, float dt)
Does the CD smoothing function - easy in | easy out / S shaped smoothing.
static const float PI
Определения EnMath.c:12
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
proto void GetScreenSize(out int x, out int y)