DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
DustKickupEffects.c
См. документацию.
13
16{
17 void DustKickupParticleData(string path, int id, string className)
18 {
20 m_ID = id;
21 m_ParticleClass = className;
22 }
24 string m_Path;
26 int m_ID;
27}
28
30{
31 void DustKickupEffectDistanceData(float minDist, float maxDist, array<string> variants)
32 {
33 m_MinDistance = minDist;
34 m_MaxDistance = maxDist;
35 m_Variants = variants;
36 }
37
41};
42
44{
45 private string m_DustKickupSoundSetName = "KickupDustEffect_SoundSet";
46
48
50
51 private static ref DustKickupEffects m_DustKickupEffects = NULL;
52
53 private const float MAX_DISTANCE_FOR_EFFECT = 2.0;
54
56 private const float EFFECT_COOLDOWN_MIN = 0.5;
57 private const float EFFECT_COOLDOWN_MAX = 1.0;
58
59 private float m_TimeUntilNextEffect = 0.0;
60
62 {
63 Init();
64 }
65
66 void Init()
67 {
70 }
71
73 {
75 {
77 }
78
80 }
81
82 static void CleanupInstance()
83 {
87 }
88
89 private void LoadAmmoTypes()
90 {
91 string configPath = "CfgMagazines ";
92 string childClass = "";
93
94 int count = g_Game.ConfigGetChildrenCount(configPath);
95
97 for (int i = 0; i < count; ++i)
98 {
99 g_Game.ConfigGetChildName(configPath, i, childClass);
100 if (!childClass.Contains("Ammo"))
101 continue;
102
103 string ammoType = "";
104
105 int effCount = g_Game.ConfigGetChildrenCount(configPath + childClass + " Effects");
106 array<ref DustKickupEffectDistanceData> dataArray = new array <ref DustKickupEffectDistanceData>();
107
109 for (int j = 0; j < effCount; ++j)
110 {
111 string stance;
112 g_Game.ConfigGetChildName(configPath + childClass + " Effects", j, stance);
113
114 string effectPath = configPath + childClass + " Effects" + " " + stance;
115
116 float minDist;
117 float maxDist;
118 array<string> effects = new array<string>();
119
120 minDist = g_Game.ConfigGetFloat(effectPath + " minDist");
121 maxDist = g_Game.ConfigGetFloat(effectPath + " maxDist");
122 g_Game.ConfigGetTextArray(effectPath + " Effects", effects);
123
124 dataArray.Insert(new DustKickupEffectDistanceData(minDist, maxDist, effects));
125 }
126
127 if (effCount > 0)
128 {
129 m_EffectRanges.Insert(childClass, dataArray);
130 }
131 }
132 }
133
135 private void LoadDustEffectPaths()
136 {
137 string configPath = "CfgSurfaces ";
138 string childClass = "";
139
140 int count = g_Game.ConfigGetChildrenCount(configPath);
141
143 for (int i = 0; i < count; ++i)
144 {
145 g_Game.ConfigGetChildName(configPath, i, childClass);
146
148
149 int effectsCount = g_Game.ConfigGetChildrenCount(configPath + childClass + " DustEffects");
150
152 for (int j = 0; j < effectsCount; j++)
153 {
154 string dustPath = " ";
155 string effectClass = " ";
156
157 g_Game.ConfigGetChildName(configPath + childClass + " DustEffects", j, effectClass);
158
160 g_Game.ConfigGetText(configPath + childClass + " DustEffects" + " " + effectClass + " path", dustPath);
161
162 if (dustPath.Length() > 1)
163 {
164 int particleID = ParticleList.RegisterParticleByFullPath(dustPath);
165 dustEffectParticles.Insert(effectClass, new DustKickupParticleData(dustPath, particleID, effectClass));
166 }
167 }
168 if (effectsCount > 0)
169 {
170 m_DustEffPaths.Insert(childClass, dustEffectParticles);
171 }
172 }
173 }
174
176 private array<string> DetermineParticles(string ammoType, float fraction, float depth)
177 {
179 float distance = fraction * depth;
181 if (!distances)
182 return null;
183
184 foreach (DustKickupEffectDistanceData data : distances)
185 {
186 if (distance >= data.m_MinDistance && distance < data.m_MaxDistance)
187 return data.m_Variants;
188 }
189
190 return null;
191 }
192
194 {
196
197 if (!dustKickupSound)
198 {
199 string errorMsgSound = "Soundset is invalid, please check the value of m_DustKickupSoundSetName, as well as the config to see if the soundset is correct";
200 ErrorEx(string.Format("%1: SoundSetName: '%2' :: %3", this, m_DustKickupSoundSetName, errorMsgSound));
201 }
202
203 params.object.PlaySoundSet(dustKickupSound, m_DustKickupSoundSetName, 0.0, 0.0); //the two zeros are fade in/out values, will leave them as is and add constants in the future if needed
204 dustKickupSound.SetPosition(params.position);
205 dustKickupSound.SetAutodestroy(true);
206 }
207
209 {
210 float now = g_Game.GetTickTime();
211
212 if (now < m_TimeUntilNextEffect)
213 return;
214
215 float distanceMeters = params.hitFraction * params.traceDepth;
216
217 if (distanceMeters >= MAX_DISTANCE_FOR_EFFECT)
218 return;
219
220 array<string> particleNames = DetermineParticles(params.ammoType, params.hitFraction, params.traceDepth);
221 if (!particleNames)
222 return;
223
225 if (!surfaceVariants)
226 return;
227
228 bool effectPlayed = false;
229
230 foreach (string name : particleNames)
231 {
232 DustKickupParticleData data = surfaceVariants.Get(name);
233
234 if (!data)
235 {
236 string errorMsg = "No such particles exists. Check to see if the name of the particle inside the ammo config is correct";
237 ErrorEx(string.Format("Particle: '%1'", name, errorMsg));
238 continue;
239 }
240
241 ParticleSource particle = ParticleManager.GetInstance().CreateParticleEx(data.m_ID, params.position);
242 particle.SetOrientation(params.orientation);
244 particle.PlayParticle();
245
246 effectPlayed = true;
247 }
248
249 if (effectPlayed)
250 {
252 }
253
254 PlaySoundEffect(params);
255 }
256};
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:4074
class DustKickupEffectDistanceData DustKickupParticleData
string m_Path
Определения DustKickupEffects.c:24
string m_ParticleClass
Определения DustKickupEffects.c:25
string ammoType
Определения DustKickupEffects.c:24
int m_ID
Определения DustKickupEffects.c:26
string path
Определения OptionSelectorMultistate.c:142
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
ParticleAutoDestroyFlags
Flags to pass to ParticleSource.SetParticleAutoDestroyFlags.
Определения ParticleSource.c:3
ref array< string > m_Variants
Определения DustKickupEffects.c:40
void DustKickupEffectDistanceData(float minDist, float maxDist, array< string > variants)
Определения DustKickupEffects.c:31
float m_TimeUntilNextEffect
Определения DustKickupEffects.c:59
const float EFFECT_COOLDOWN_MAX
Определения DustKickupEffects.c:57
void LoadAmmoTypes()
Определения DustKickupEffects.c:89
void LoadDustEffectPaths()
Going over all surfaces, extracting all dust particles paths from each surface.
Определения DustKickupEffects.c:135
void Init()
Определения DustKickupEffects.c:66
const float EFFECT_COOLDOWN_MIN
vlaues for the cooldown are in seconds
Определения DustKickupEffects.c:56
static ref DustKickupEffects m_DustKickupEffects
Определения DustKickupEffects.c:51
static DustKickupEffects GetInstance()
Определения DustKickupEffects.c:72
string m_DustKickupSoundSetName
Определения DustKickupEffects.c:45
void DustKickupEffects()
Определения DustKickupEffects.c:61
array< string > DetermineParticles(string ammoType, float fraction, float depth)
Determines what particles should play based on the ammo type and distance of the weapon from the grou...
Определения DustKickupEffects.c:176
void PlayParticle(DustKickupParams params)
Определения DustKickupEffects.c:208
const float MAX_DISTANCE_FOR_EFFECT
Определения DustKickupEffects.c:53
ref map< string, ref array< ref DustKickupEffectDistanceData > > m_EffectRanges
Определения DustKickupEffects.c:49
ref map< string, ref map< string, ref DustKickupParticleData > > m_DustEffPaths
Определения DustKickupEffects.c:47
static void CleanupInstance()
Определения DustKickupEffects.c:82
void PlaySoundEffect(DustKickupParams params)
Определения DustKickupEffects.c:193
Object object
Определения DustKickupEffects.c:4
float hitFraction
Определения DustKickupEffects.c:9
string surfaceName
Определения DustKickupEffects.c:5
float traceDepth
Определения DustKickupEffects.c:11
vector orientation
Определения DustKickupEffects.c:7
int playerStance
Определения DustKickupEffects.c:8
string ammoType
Определения DustKickupEffects.c:10
vector position
Определения DustKickupEffects.c:6
We use this as an argument in the PlayParticle function, simply for readability's sake.
Определения DustKickupEffects.c:3
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:607
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения EnMath.c:7
Определения ObjectTyped.c:2
override void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
Определения Particle.c:203
static int RegisterParticleByFullPath(string fullPath)
Определения ParticleList.c:421
Определения ParticleList.c:12
proto native void SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags flags)
Enables the particle to automatically clean up itself when ending or stopping.
Entity which has the particle instance as an ObjectComponent.
Определения ParticleSource.c:128
static EffectSound CreateSound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false, bool enviroment=false)
Create an EffectSound.
Определения EffectManager.c:153
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения Transport.c:70
Определения EnConvert.c:119
enum ShapeType ErrorEx
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
proto native int Length()
Returns length of string.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286