Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
pmtplayback.c
Go to the documentation of this file.
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 = g_Game.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 = g_Game.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 = g_Game.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 = g_Game.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 = g_Game.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!
204 g_Game.ObjectDelete(p);
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!
258 g_Game.ObjectDelete(p);
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}
Definition pmtf.c:2
int InsertManager(ParticleManager pm)
Definition pmtf.c:9
ParticleManager CreatePMFixedBlocking(int size)
Definition pmtf.c:42
bool m_bOnePlayingSAADEnded
Definition pmtplayback.c:11
static const float STOP_ACCUMULATED_TIME_PLAY_CUTOFF
Definition pmtplayback.c:21
TFResult TestOnePlayingStandAlone()
Definition pmtplayback.c:75
TFResult TestWiggleStress()
Definition pmtplayback.c:92
static const float STOP_ACCUMULATED_TIME_STOP_CUTOFF
Definition pmtplayback.c:20
bool m_bStopWasStopped
Definition pmtplayback.c:22
int m_OnePlayingSAADPSID
Definition pmtplayback.c:10
void StopEnded(ParticleSource p)
TFResult CheckStop(float dt)
TFResult CheckOnePlayingSAAD()
bool m_bOnePlayingSAEnded
Definition pmtplayback.c:15
TFResult TestOnePlayingStandAloneAutoDestroy()
Definition pmtplayback.c:59
void PassOnePlaying(ParticleSource p)
bool m_bStopWasResumed
Definition pmtplayback.c:23
void OnePlayingSAADEnded(ParticleSource p)
TFResult TestStopping()
void OnePlayingSAEnded(ParticleSource p)
TFResult CheckOnePlayingSA()
void PMTPlayback()
Definition pmtplayback.c:29
TFResult CheckOnePlaying()
float m_StopAccumulatedTime
Definition pmtplayback.c:19
int m_OnePlayingSAPSID
Definition pmtplayback.c:14
bool m_bOnePlayingTestSuccess
Definition pmtplayback.c:7
int m_OnePlayingManagerID
Definition pmtplayback.c:6
bool m_bStopEnded
Definition pmtplayback.c:24
TFResult TestOnePlaying()
Definition pmtplayback.c:42
ref array< ParticleSource > m_ParticleSources
Definition pmtplayback.c:3
override void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
Definition particle.c:203
static const int EXPLOSION_LANDMINE
static const int ROADFLARE_BURNING_MAIN
Entity which has the particle instance as an ObjectComponent.
bool GetParticle(out string path, EGetParticleMode mode)
Gets the path to the currently assigned particle.
void DisableAutoDestroy()
Disables the particle automatically cleaning up itself when ending or stopping.
override void SetWiggle(float random_angle, float random_interval)
Makes the particle change direction by random_angle every random_interval seconds.
override bool IsParticlePlaying()
Ask if the particle is still playing.
override bool StopParticle(int flags=0)
Method to tell the particle to stop playing.
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.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Definition enconvert.c:123
DayZGame g_Game
Definition dayzgame.c:3942
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).
PlayerStats GetManager()
TFResult NTFR(TFR result)
bool Assert(bool condition)
void TFResult(TFR result)
TFR
void AddFrameTest(string test)
void AddInitTest(string test)
TFResult BTFR(bool result)