DayZ 1.24
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 = 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);
81 p.DisableAutoDestroy();
82
84
85 AddFrameTest("CheckOnePlayingSA");
86
87 return BTFR(p.IsParticlePlaying());
88 }
89
90 //---------------------------------------------------------------------------
91 // Test wiggling
93 {
94 DayZPlayer player = GetGame().GetPlayer();
95
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);
111 p.DisableAutoDestroy();
112
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 return NTFR(TFR.PENDING);
133 else
135 }
136 else
137 return BTFR(Assert(false));
138 }
139 else
140 return BTFR(Assert(false));
141 }
142
143 //---------------------------------------------------------------------------
145 {
146 if (m_ParticleSources.IsValidIndex(m_OnePlayingSAADPSID))
147 {
149 if (p)
150 {
151 if (p.IsParticlePlaying())
152 return NTFR(TFR.PENDING);
153 else
154 {
156 {
157 // There might be one frame where it is still alive before getting cleaned up
158 return NTFR(TFR.PENDING);
159 }
160 else
161 {
162 // Should be gone when no longer playing
163 return BTFR(Assert(false));
164 }
165 }
166 }
167 else
168 {
169 // Make sure the particle ended, if it did, then success!
171 }
172 }
173 else
174 return BTFR(Assert(false));
175 }
176
177 //---------------------------------------------------------------------------
179 {
180 if (m_ParticleSources.IsValidIndex(m_OnePlayingSAPSID))
181 {
183 if (p)
184 {
185 if (p.IsParticlePlaying())
186 return NTFR(TFR.PENDING);
187 else
188 {
189 // Clean up the Particle, no leaking from tests!
190 GetGame().ObjectDelete(p);
191 // Make sure the particle ended, if it did, then success!
193 }
194 }
195 else
196 {
197 // It should not be gone, no autodestroy
198 return BTFR(Assert(false));
199 }
200 }
201 else
202 return BTFR(Assert(false));
203 }
204
205 //---------------------------------------------------------------------------
207 {
209
210 if (m_ParticleSources.IsValidIndex(m_StopPSID))
211 {
213 if (p)
214 {
215 if (p.IsParticlePlaying())
216 {
218 {
219 p.StopParticle();
221 m_bStopWasStopped = true;
222 }
223
224 return NTFR(TFR.PENDING);
225 }
226 else
227 {
228 // Means it was stopped before it was supposed to
229 // Possibly because particle length is shorter than STOP_ACCUMULATED_TIME_CUTOFF
231 return BTFR(false);
233 {
234 p.PlayParticle();
235 m_bStopWasResumed = true;
236 }
237 else if (m_bStopEnded)
238 {
239 // Clean up the Particle, no leaking from tests!
240 GetGame().ObjectDelete(p);
241 return BTFR(true);
242 }
243
244 return NTFR(TFR.PENDING);
245 }
246 }
247 else
248 {
249 // It should not be gone, no autodestroy
250 return BTFR(Assert(false));
251 }
252 }
253 else
254 return BTFR(Assert(false));
255 }
256
257 //---------------------------------------------------------------------------
258 // Passes
259 //---------------------------------------------------------------------------
264
265 //---------------------------------------------------------------------------
266 // Helpers
267 //---------------------------------------------------------------------------
272
273 //---------------------------------------------------------------------------
278
279 //---------------------------------------------------------------------------
281 {
282 m_bStopEnded = true;
283 }
284}
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
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)
Definition PMTF.c:2
bool GetManager(int id, out ParticleManager pm)
Definition PMTF.c:17
int InsertManager(ParticleManager pm)
Definition PMTF.c:9
ParticleManager CreatePMFixedBlocking(int size)
Definition PMTF.c:42
void OnePlayingSAADEnded(ParticleSource p)
TFResult CheckOnePlayingSAAD()
TFResult TestStopping()
ref array< ParticleSource > m_ParticleSources
Definition PMTPlayback.c:3
TFResult CheckOnePlayingSA()
bool m_bOnePlayingTestSuccess
Definition PMTPlayback.c:7
bool m_bStopEnded
Definition PMTPlayback.c:24
TFResult TestOnePlayingStandAloneAutoDestroy()
Definition PMTPlayback.c:59
TFResult TestOnePlaying()
Definition PMTPlayback.c:42
bool m_bOnePlayingSAADEnded
Definition PMTPlayback.c:11
void OnePlayingSAEnded(ParticleSource p)
int m_OnePlayingSAADPSID
Definition PMTPlayback.c:10
static const float STOP_ACCUMULATED_TIME_STOP_CUTOFF
Definition PMTPlayback.c:20
void PMTPlayback()
Definition PMTPlayback.c:29
TFResult TestOnePlayingStandAlone()
Definition PMTPlayback.c:75
TFResult CheckStop(float dt)
float m_StopAccumulatedTime
Definition PMTPlayback.c:19
void StopEnded(ParticleSource p)
int m_OnePlayingSAPSID
Definition PMTPlayback.c:14
bool m_bOnePlayingSAEnded
Definition PMTPlayback.c:15
TFResult TestWiggleStress()
Definition PMTPlayback.c:92
bool m_bStopWasResumed
Definition PMTPlayback.c:23
void PassOnePlaying(ParticleSource p)
static const float STOP_ACCUMULATED_TIME_PLAY_CUTOFF
Definition PMTPlayback.c:21
int m_OnePlayingManagerID
Definition PMTPlayback.c:6
TFResult CheckOnePlaying()
bool m_bStopWasStopped
Definition PMTPlayback.c:22
static const int EXPLOSION_LANDMINE
static const int ROADFLARE_BURNING_MAIN
Entity which has the particle instance as an ObjectComponent.
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.
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()