DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PMTPlayback.c
См. документацию.
2{
4
5 // TestOnePlaying
8
9 // TestOnePlayingStandAloneAutoDestroy
12
13 // TestOnePlayingStandAlone
16
17 // TestStop
20 static const float STOP_ACCUMULATED_TIME_STOP_CUTOFF = 2;
21 static const float STOP_ACCUMULATED_TIME_PLAY_CUTOFF = 3;
22 bool m_bStopWasStopped = false;
23 bool m_bStopWasResumed = false;
24 bool m_bStopEnded = false;
25
26 //---------------------------------------------------------------------------
27 // Ctor - Decides the tests to run
28 //---------------------------------------------------------------------------
30 {
31 //AddInitTest("TestOnePlaying");
32 //AddInitTest("TestOnePlayingStandAloneAutoDestroy");
33 //AddInitTest("TestOnePlayingStandAlone");
34 //AddInitTest("TestWiggleStress");
35 AddInitTest("TestStopping");
36 }
37
38 //---------------------------------------------------------------------------
39 // Tests
40 //---------------------------------------------------------------------------
41 // Test one particle playing
43 {
46
47 DayZPlayer player = GetGame().GetPlayer();
48
49 ParticleSource p = pm.CreateParticleById(ParticleList.EXPLOSION_LANDMINE, new ParticleProperties(player.GetPosition() + player.GetDirection() * 3, true));
50 p.GetEvents().Event_OnParticleEnd.Insert(PassOnePlaying);
51
52 AddFrameTest("CheckOnePlaying");
53
54 return BTFR(p.IsParticlePlaying());
55 }
56
57 //---------------------------------------------------------------------------
58 // Test one standalone particle playing which will auto destroy
60 {
61 DayZPlayer player = GetGame().GetPlayer();
62
63 ParticleSource p = ParticleSource.CreateParticle(ParticleList.EXPLOSION_LANDMINE, player.GetPosition() + player.GetDirection() * 3 + player.GetDirectionAside() * 3, true);
64 p.GetEvents().Event_OnParticleEnd.Insert(OnePlayingSAADEnded);
65
67
68 AddFrameTest("CheckOnePlayingSAAD");
69
70 return BTFR(p.IsParticlePlaying());
71 }
72
73 //---------------------------------------------------------------------------
74 // Test one standalone particle playing which will not auto destroy
76 {
77 DayZPlayer player = GetGame().GetPlayer();
78
79 ParticleSource p = ParticleSource.CreateParticle(ParticleList.EXPLOSION_LANDMINE, player.GetPosition() + player.GetDirection() * 3 - player.GetDirectionAside() * 3, true);
80 p.GetEvents().Event_OnParticleEnd.Insert(OnePlayingSAEnded);
82
84
85 AddFrameTest("CheckOnePlayingSA");
86
87 return BTFR(p.IsParticlePlaying());
88 }
89
90 //---------------------------------------------------------------------------
91 // Test wiggling
93 {
94 DayZPlayer player = GetGame().GetPlayer();
95
96 ParticleSource p = ParticleSource.CreateParticle(ParticleList.ROADFLARE_BURNING_MAIN, player.GetPosition() + player.GetDirection() * 4, true);
97 p.SetWiggle(90, 0.1);
98
99 return BTFR(p.IsParticlePlaying());
100 }
101
102 //---------------------------------------------------------------------------
103 // Test stop
105 {
106 DayZPlayer player = GetGame().GetPlayer();
107
108 //ParticleSource p = ParticleSource.CreateParticle(ParticleList.EXPLOSION_LANDMINE, player.GetPosition() + player.GetDirection() * 4, true);
110 p.GetEvents().Event_OnParticleEnd.Insert(StopEnded);
112
113 m_StopPSID = m_ParticleSources.Insert(p);
114
115 AddFrameTest("CheckStop");
116
117 return BTFR(p.IsParticlePlaying());
118 }
119
120 //---------------------------------------------------------------------------
121 // OnFrame Checks
122 //---------------------------------------------------------------------------
124 {
127 {
128 if (pm)
129 {
130 ParticleSource p = pm.GetParticle(0);
131 if (p.IsParticlePlaying())
132 {
133 return NTFR(TFR.PENDING);
134 }
135 else
136 {
138 }
139 }
140 else
141 {
142 return BTFR(Assert(false));
143 }
144 }
145 else
146 {
147 return BTFR(Assert(false));
148 }
149 }
150
151 //---------------------------------------------------------------------------
153 {
154 if (m_ParticleSources.IsValidIndex(m_OnePlayingSAADPSID))
155 {
157 if (p)
158 {
159 if (p.IsParticlePlaying())
160 {
161 return NTFR(TFR.PENDING);
162 }
163 else
164 {
166 {
167 // There might be one frame where it is still alive before getting cleaned up
168 return NTFR(TFR.PENDING);
169 }
170 else
171 {
172 // Should be gone when no longer playing
173 return BTFR(Assert(false));
174 }
175 }
176 }
177 else
178 {
179 // Make sure the particle ended, if it did, then success!
181 }
182 }
183 else
184 {
185 return BTFR(Assert(false));
186 }
187 }
188
189 //---------------------------------------------------------------------------
191 {
192 if (m_ParticleSources.IsValidIndex(m_OnePlayingSAPSID))
193 {
195 if (p)
196 {
197 if (p.IsParticlePlaying())
198 {
199 return NTFR(TFR.PENDING);
200 }
201 else
202 {
203 // Clean up the Particle, no leaking from tests!
205 // Make sure the particle ended, if it did, then success!
207 }
208 }
209 else
210 {
211 // It should not be gone, no autodestroy
212 return BTFR(Assert(false));
213 }
214 }
215 else
216 {
217 return BTFR(Assert(false));
218 }
219 }
220
221 //---------------------------------------------------------------------------
223 {
225
226 if (m_ParticleSources.IsValidIndex(m_StopPSID))
227 {
229 if (p)
230 {
231 if (p.IsParticlePlaying())
232 {
234 {
235 p.StopParticle();
237 m_bStopWasStopped = true;
238 }
239
240 return NTFR(TFR.PENDING);
241 }
242 else
243 {
244 // Means it was stopped before it was supposed to
245 // Possibly because particle length is shorter than STOP_ACCUMULATED_TIME_CUTOFF
247 {
248 return BTFR(false);
249 }
251 {
252 p.PlayParticle();
253 m_bStopWasResumed = true;
254 }
255 else if (m_bStopEnded)
256 {
257 // Clean up the Particle, no leaking from tests!
259 return BTFR(true);
260 }
261
262 return NTFR(TFR.PENDING);
263 }
264 }
265 else
266 {
267 // It should not be gone, no autodestroy
268 return BTFR(Assert(false));
269 }
270 }
271 else
272 {
273 return BTFR(Assert(false));
274 }
275 }
276
277 //---------------------------------------------------------------------------
278 // Passes
279 //---------------------------------------------------------------------------
284
285 //---------------------------------------------------------------------------
286 // Helpers
287 //---------------------------------------------------------------------------
292
293 //---------------------------------------------------------------------------
298
299 //---------------------------------------------------------------------------
301 {
302 m_bStopEnded = true;
303 }
304}
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
PlayerStats GetManager()
Определения PlayerStatBase.c:198
TFResult NTFR(TFR result)
Определения TestFramework.c:273
bool Assert(bool condition)
Определения TestFramework.c:262
void TFResult(TFR result)
Определения TestFramework.c:12
TFR
Определения TestFramework.c:2
void AddFrameTest(string test)
Определения TestFramework.c:254
void AddInitTest(string test)
Определения TestFramework.c:249
TFResult BTFR(bool result)
Определения TestFramework.c:278
proto native DayZPlayer GetPlayer()
proto native void ObjectDelete(Object obj)
int InsertManager(ParticleManager pm)
Определения PMTF.c:9
ParticleManager CreatePMFixedBlocking(int size)
Определения PMTF.c:42
Определения PMTF.c:2
int m_StopPSID
Определения PMTPlayback.c:18
void OnePlayingSAADEnded(ParticleSource p)
Определения PMTPlayback.c:288
TFResult CheckOnePlayingSAAD()
Определения PMTPlayback.c:152
TFResult TestStopping()
Определения PMTPlayback.c:104
ref array< ParticleSource > m_ParticleSources
Определения PMTPlayback.c:3
TFResult CheckOnePlayingSA()
Определения PMTPlayback.c:190
bool m_bOnePlayingTestSuccess
Определения PMTPlayback.c:7
bool m_bStopEnded
Определения PMTPlayback.c:24
TFResult TestOnePlayingStandAloneAutoDestroy()
Определения PMTPlayback.c:59
TFResult TestOnePlaying()
Определения PMTPlayback.c:42
bool m_bOnePlayingSAADEnded
Определения PMTPlayback.c:11
void OnePlayingSAEnded(ParticleSource p)
Определения PMTPlayback.c:294
int m_OnePlayingSAADPSID
Определения PMTPlayback.c:10
static const float STOP_ACCUMULATED_TIME_STOP_CUTOFF
Определения PMTPlayback.c:20
void PMTPlayback()
Определения PMTPlayback.c:29
TFResult TestOnePlayingStandAlone()
Определения PMTPlayback.c:75
TFResult CheckStop(float dt)
Определения PMTPlayback.c:222
float m_StopAccumulatedTime
Определения PMTPlayback.c:19
void StopEnded(ParticleSource p)
Определения PMTPlayback.c:300
int m_OnePlayingSAPSID
Определения PMTPlayback.c:14
bool m_bOnePlayingSAEnded
Определения PMTPlayback.c:15
TFResult TestWiggleStress()
Определения PMTPlayback.c:92
bool m_bStopWasResumed
Определения PMTPlayback.c:23
void PassOnePlaying(ParticleSource p)
Определения PMTPlayback.c:280
static const float STOP_ACCUMULATED_TIME_PLAY_CUTOFF
Определения PMTPlayback.c:21
int m_OnePlayingManagerID
Определения PMTPlayback.c:6
TFResult CheckOnePlaying()
Определения PMTPlayback.c:123
bool m_bStopWasStopped
Определения PMTPlayback.c:22
override void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
Определения Particle.c:203
static const int EXPLOSION_LANDMINE
Определения ParticleList.c:267
static const int ROADFLARE_BURNING_MAIN
Определения ParticleList.c:84
Определения ParticleList.c:12
override bool StopParticle(int flags=0)
Method to tell the particle to stop playing.
Определения ParticleSource.c:372
bool GetParticle(out string path, EGetParticleMode mode)
Gets the path to the currently assigned particle.
Определения ParticleSource.c:492
static ParticleSource CreateParticle(int id, vector pos, bool playOnCreation=false, Object parent=null, vector ori=vector.Zero, bool forceWorldRotation=false, Class owner=null)
Create function.
Определения ParticleSource.c:178
override bool IsParticlePlaying()
Ask if the particle is still playing.
Определения ParticleSource.c:417
override void SetWiggle(float random_angle, float random_interval)
Makes the particle change direction by random_angle every random_interval seconds.
Определения ParticleSource.c:929
void DisableAutoDestroy()
Disables the particle automatically cleaning up itself when ending or stopping.
Определения ParticleSource.c:151
Entity which has the particle instance as an ObjectComponent.
Определения ParticleSource.c:124
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:110
Определения EnConvert.c:106
proto native CGame GetGame()