1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655 | #include "gfCRoundCongratulationsGui.h"
#include <fsCore/src/fsNRnd.h>
#include <fsCore/src/fsNMaths.h>
#include <fsCore/fsIFile.h>
#include <fsCore/src/fsCAppSettings.h>
#include <fsRenderer/src/components/fsCParticleEmitterComponent.h>
#include <fsAppCore/src/components/fsCNameComponent.h>
#include <fsAppCore/src/fsCEntityFactory.h>
#include <fsAppCore/src/fsCAppMessageDispatcher.h>
#include <fsAppCore/src/fsILevelBasedAppCoreMain.h>
#include <fsAudio/fsIAudioManager.h>
#include <gfComponents/components/gfCLevelCompleteCheckerComponent.h>
#include <gfMinigameCore/components/gfCMinigameCompleteComponent.h>
#include <gfMinigameCore/components/slidasquare/gfCSlidasquareMinigameComponent.h>
#include <gfMinigameCore/components/jigsaw/gfCJigsawMinigameComponent.h>
#include <gfMinigameCore/components/wordGames/wordSearch/gfCWordSearchMinigameLogicComponent.h>
#include <gfComponents/components/gfCLockComponent.h>
#include "gfCGameGui.h"
#include "gfCRoundScoreGui.h"
#include "gfIHogLevel.h"
#include "src/fsCProfileManager.h"
#include "src/gfCHogUserSavedData.h"
const fsCUniqueId gfCRoundCongratulationsGui::mTypeId("fsCRoundCongratulationsGui");
namespace
{
// ======================================================================
// Round-complete effect tuning. All knobs live here on purpose - edit
// and rebuild, rather than spreading them across settings/asset files.
// ======================================================================
const fsF32 kMinStarSpacing = 100.0f; // cull pieces closer than this (screen units)
const fsS32 kMaxStars = 25; // hard cap on the number of pieces sparkled
const fsS32 kCometTravelMs = 2000; // total time to run the whole path, whatever its length
const fsS32 kCometChargeMs = 0; // pause on the first piece before setting off
const fsF32 kCometStarScale = 1.1f; // expanding-star bloom size at each piece reached
const fsF32 kFinishStarScale = 1.6f; // final burst size where the effect lands
const fsF32 kAxisAlignEps = 8.0f; // how close (px) two blooms count as sharing an axis
const fsF32 kAxisJitterMin = 30.0f; // nudge (px) when just a pair share an axis
const fsF32 kAxisJitterMax = 150.0f; // nudge (px) once a whole group shares an axis
const fsS32 kAxisJitterFullCount = 10; // group size at which the nudge reaches its max
// Catmull-Rom spline point: smooth curve passing through p1 and p2, shaped by
// the neighbours p0 and p3. Used to round the comet's path through the pieces
// so it flows rather than turning sharp corners at each one.
fsVec2d catmullRom(const fsVec2d& p0, const fsVec2d& p1,
const fsVec2d& p2, const fsVec2d& p3, const fsF32 t)
{
const fsF32 t2 = t * t;
const fsF32 t3 = t2 * t;
fsVec2d out;
out.x = 0.5f * (2.0f * p1.x + (-p0.x + p2.x) * t
+ (2.0f * p0.x - 5.0f * p1.x + 4.0f * p2.x - p3.x) * t2
+ (-p0.x + 3.0f * p1.x - 3.0f * p2.x + p3.x) * t3);
out.y = 0.5f * (2.0f * p1.y + (-p0.y + p2.y) * t
+ (2.0f * p0.y - 5.0f * p1.y + 4.0f * p2.y - p3.y) * t2
+ (-p0.y + 3.0f * p1.y - 3.0f * p2.y + p3.y) * t3);
return out;
}
fsF32 randSigned() // uniform in [-1, 1]
{
return (static_cast<fsF32>(fsNRnd::uInt32GetWithLimit(2001)) - 1000.0f) * 0.001f;
}
// Jitter amplitude for an axis, scaled by how many blooms share it: a lone piece
// gets none, a pair the min, and it ramps to the max as the shared group grows -
// so a whole column fans into a wide band while a small alignment barely shifts.
fsF32 axisJitterAmp(const fsS32 pShareCount)
{
if (pShareCount < 2)
{
return 0.0f;
}
fsF32 t = static_cast<fsF32>(pShareCount - 2) / static_cast<fsF32>(kAxisJitterFullCount - 2);
t = t < 0.0f ? 0.0f : (t > 1.0f ? 1.0f : t);
return fsNMaths::lerpF32(kAxisJitterMin, kAxisJitterMax, t);
}
// Bloom position for each piece. Count how many pieces share its x (a vertical
// column) or y (a row); the bigger that shared group, the further it is nudged off
// that axis - so lines and grids scatter into bands/clouds rather than blooming in
// dead-straight rows, while a piece off on its own keeps its real position.
void buildSparklePositions(const std::vector<fsCEntity*>& pEnts, std::vector<fsVec2d>& pOut)
{
pOut.clear();
pOut.reserve(pEnts.size());
const std::size_t n = pEnts.size();
for (std::size_t i = 0; i < n; ++i)
{
const fsVec2d pos = pEnts[i]->posGet();
fsS32 colCount = 0; // pieces sharing this x (incl. self)
fsS32 rowCount = 0; // pieces sharing this y (incl. self)
for (std::size_t j = 0; j < n; ++j)
{
const fsVec2d other = pEnts[j]->posGet();
if (fsNMaths::fabsF32(pos.x - other.x) < kAxisAlignEps)
{
++colCount;
}
if (fsNMaths::fabsF32(pos.y - other.y) < kAxisAlignEps)
{
++rowCount;
}
}
pOut.push_back(fsVec2d(pos.x + axisJitterAmp(colCount) * randSigned(),
pos.y + axisJitterAmp(rowCount) * randSigned()));
}
}
// Greedy nearest-neighbour reorder: keep the first entity, then repeatedly hop to
// the closest unvisited one. Gives the comet a short, natural flowing route instead
// of the perpendicular zig-zag the principal-axis ordering produces on a 2D cloud.
// Membership is unchanged - only the visit order.
void nearestNeighbourOrder(std::vector<fsCEntity*>& pEnts)
{
if (pEnts.size() < 3)
{
return;
}
std::vector<fsCEntity*> path;
path.reserve(pEnts.size());
path.push_back(pEnts.front());
std::vector<fsCEntity*> remaining(pEnts.begin() + 1, pEnts.end());
while (!remaining.empty())
{
const fsVec2d cur = path.back()->posGet();
std::size_t best = 0;
fsF32 bestDistSq = 1.0e30f;
for (std::size_t i = 0; i < remaining.size(); ++i)
{
const fsVec2d d = remaining[i]->posGet() - cur;
const fsF32 distSq = d.x * d.x + d.y * d.y;
if (distSq < bestDistSq)
{
bestDistSq = distSq;
best = i;
}
}
path.push_back(remaining[best]);
remaining.erase(remaining.begin() + static_cast<std::ptrdiff_t>(best));
}
pEnts = path;
}
// Direction of greatest spread across the collected entities (2-point PCA on
// their positions). Pieces are ordered along this axis before the count cap
// decimates them, so the survivors stay spread out rather than clustered.
fsVec2d principalAxisGet(const std::vector<fsCEntity*>& pEnts)
{
if (pEnts.size() < 2)
{
return fsVec2d(1.0f, 0.0f);
}
fsVec2d centroid;
for (const fsCEntity* ent : pEnts)
{
centroid += ent->posGet();<--- Consider using std::accumulate algorithm instead of a raw loop.
}
centroid = centroid / static_cast<fsS32>(pEnts.size());
fsF32 sxx = 0.0f;
fsF32 syy = 0.0f;
fsF32 sxy = 0.0f;
for (const fsCEntity* ent : pEnts)
{
const fsVec2d d = ent->posGet() - centroid;
sxx += d.x * d.x;
syy += d.y * d.y;
sxy += d.x * d.y;
}
const fsF32 angle = 0.5f * fsNMaths::atan2F32(2.0f * sxy, sxx - syy);
return fsVec2d(fsNMaths::cosF32(angle), fsNMaths::sinF32(angle));
}
}
void gfCRoundCongratulationsGui::resetDo()
{
mWaitMessage = false;
mState = eREADY;
mTime = 0;
levelCompleteSet();
ephemeralEntitiesDestroy();
}
void gfCRoundCongratulationsGui::serialiseDo()
{
parentGet()->s32Serialise(mTime);
parentGet()->s32Serialise(static_cast<fsS32>(mState));
}
void gfCRoundCongratulationsGui::deserialiseDo()
{
mTime = parentGet()->s32Deserialise();
mState = static_cast<eSTATE>(parentGet()->s32Deserialise());
stateInit();
}
fsBool gfCRoundCongratulationsGui::effectableEntityGet(fsCEntity* const pEnt) const
{
const fsCNameComponent* const nameComp = pEnt->componentGet<fsCNameComponent>();
return !nameComp ||
fsStr::npos == nameComp->nameSansSuffixGet().find(gfCJigsawMinigameComponent::mStartSuffix);
}
void gfCRoundCongratulationsGui::particleCreate(fsCEntity* const pEnt, const fsVec2d& pPos, const fsF32 pScale)
{
fsCResourceName particleEffectName(fsCAppCoreMain::instanceGet()->settingsGet()->strGetWithDefault(
"miniGameCompleteParticle", "particles/pMinigameCompleteEffect.txt"),
fsCResourceName::eRES_LOCATION_ASSETS);
if (fsIFile::fileExistsGet(particleEffectName))
{
if (effectableEntityGet(pEnt))
{
fsCEntity* newEnt = parentGet()->entityFactoryGet()->emptyEntityCreate(pEnt->nameGet());
fsCParticleEmitterComponent* effectComp = newEnt->componentAdd<fsCParticleEmitterComponent>();
effectComp->particelDataLoad(particleEffectName);
newEnt->posSet(pPos);
newEnt->scaleSet(fsVec2d(pScale, pScale));
pEnt->parentGet()->childAdd(newEnt);
mCongratulationParticles.push_back(newEnt);
}
}
}
void gfCRoundCongratulationsGui::miniGameEntityListTrim()
{
// rip out clone mini game ents as they'll get destroyed at some point....
for (std::vector<fsCEntity*>::iterator ent = mMinigameEnts.begin(); mMinigameEnts.end() != ent;)
{
if (fsStr::npos != (*ent)->nameGet().find(gfCSlidasquareMinigameComponent::mCloneName))
{
ent = mMinigameEnts.erase(ent);
}
else
{
++ent;
}
}
// Density cull: some puzzles pack their pieces tightly together, which floods
// the screen with overlapping stars. Keep an entity only when it is at least
// minSpacing away from one already kept (greedy over the axis-sorted list), so
// tight clusters get thinned while spread-out layouts are left untouched.
if (kMinStarSpacing > 0.0f)
{
const fsF32 minSpacingSq = kMinStarSpacing * kMinStarSpacing;
std::vector<fsCEntity*> spaced;
for (fsCEntity* const ent : mMinigameEnts)
{
const fsVec2d pos = ent->posGet();
fsBool tooClose = false;
for (const fsCEntity* const kept : spaced)
{
const fsVec2d d = kept->posGet() - pos;
if (d.x * d.x + d.y * d.y < minSpacingSq)
{
tooClose = true;
break;
}
}
if (!tooClose)
{
spaced.push_back(ent);
}
}
mMinigameEnts = spaced;
}
// Hard cap: never sparkle more than maxStars targets. Keep an evenly spaced
// subset of the (axis-sorted) list so the survivors stay spread across the
// screen rather than bunched at one end.
if (kMaxStars > 0 && static_cast<fsS32>(mMinigameEnts.size()) > kMaxStars)
{
std::vector<fsCEntity*> capped;
capped.reserve(static_cast<std::size_t>(kMaxStars));
const fsF32 stride = static_cast<fsF32>(mMinigameEnts.size()) / static_cast<fsF32>(kMaxStars);
for (fsS32 i = 0; i < kMaxStars; ++i)
{
capped.push_back(mMinigameEnts[static_cast<std::size_t>(static_cast<fsF32>(i) * stride)]);
}
mMinigameEnts = capped;
}
}
void gfCRoundCongratulationsGui::miniGameEntitiesCollect()
{
if (!gfCRoundScoreGui::miniGameCheck(fsILevelBasedAppCoreMain::instanceGet()->currentLevelNameGet()))
{
return;
}
mMinigameEnts = appSceneEntitiesWithComponentOfFamilyType<gfIMinigameComponent>();
if (mMinigameEnts.empty())
{
mMinigameEnts = appSceneEntitiesWithComponentOfFamilyType<gfCLockComponent>();
if (mMinigameEnts.empty())
{
if(auto wsl = appSceneFirstEntityWithComponentOfFamilyType<gfCWordSearchMinigameLogicComponent>())
{
mMinigameEnts = wsl->componentGet<gfCWordSearchMinigameLogicComponent>()->selectedWordsGet();
}
}
}
const fsVec2d axis = principalAxisGet(mMinigameEnts);
std::stable_sort(mMinigameEnts.begin(), mMinigameEnts.end(),
[&axis](fsCEntity* entA, fsCEntity* entB)
{
return entA->posGet().x * axis.x + entA->posGet().y * axis.y <
entB->posGet().x * axis.x + entB->posGet().y * axis.y;
});
miniGameEntityListTrim();
mCurrMinigameEnt = mMinigameEnts.begin();
}
void gfCRoundCongratulationsGui::cometCreate()
{
if (mMinigameEnts.empty())
{
return;
}
// order the pieces into a short flowing route (rebuilds the vector, so refresh
// the traversal iterator afterwards)
nearestNeighbourOrder(mMinigameEnts);
mCurrMinigameEnt = mMinigameEnts.begin();
// bloom positions: nudge pieces off any axis they share with a path-neighbour
buildSparklePositions(mMinigameEnts, mSparklePos);
fsCEntity* const anchor = mMinigameEnts.front();
mCometPos = anchor->posGet();
mCometT = 0.0f;
// derive speed from the total path length so the run always takes ~kCometTravelMs,
// regardless of how far apart the pieces are spread
fsF32 pathLen = 0.0f;
for (std::size_t i = 1; i < mMinigameEnts.size(); ++i)
{
const fsVec2d d = mMinigameEnts[i]->posGet() - mMinigameEnts[i - 1]->posGet();
pathLen += fsNMaths::sqrtF32(d.x * d.x + d.y * d.y);
}
mCometSpeed = pathLen > 1.0f ? pathLen / static_cast<fsF32>(kCometTravelMs) : 1.0f;
// invisible cursor that travels the path to pace/order the per-piece blooms;
// no trail emitter attached - the moving comet itself read as distracting
mCometEnt = parentGet()->entityFactoryGet()->emptyEntityCreate("congratsComet");
mCometEnt->posSet(mCometPos);
anchor->parentGet()->childAdd(mCometEnt);
// bloom the first piece immediately as the cursor sets off
particleCreate(anchor, mSparklePos.front(), kCometStarScale);
const fsStr sfx = fsCAppCoreMain::instanceGet()->settingsGet()->strGetWithDefault(
"sfxLevelComplete", "audio/sfx/levelComplete.wav");
fsIAudioManager::instanceGet()->effectPlay(fsCResourceName(sfx, fsCResourceName::eRES_LOCATION_ASSETS));
}
void gfCRoundCongratulationsGui::cometUpdate(const fsS32 pDeltaMs)
{
if (!mCometEnt || mMinigameEnts.empty())
{
stateAdvance();
return;
}
// optional charge-up: hold on the first piece before the cursor sets off (kCometChargeMs)
if (mTime > 0)
{
mTime -= pDeltaMs;
return;
}
const fsS32 count = static_cast<fsS32>(mMinigameEnts.size());
fsS32 seg = static_cast<fsS32>(mCurrMinigameEnt - mMinigameEnts.begin());
if (seg >= count - 1) // arrived at the last piece: climactic burst, turn the comet off, done
{
particleCreate(mMinigameEnts.back(), mSparklePos.back(), kFinishStarScale);
mCometEnt->destroy(); // stop the cursor
mCometEnt = nullptr;
stateAdvance();
return;
}
auto pointAt = [this, count](fsS32 i) -> fsVec2d
{
i = i < 0 ? 0 : (i >= count ? count - 1 : i);
return mMinigameEnts[static_cast<std::size_t>(i)]->posGet();
};
// advance the spline parameter at a roughly constant speed along the chord
const fsVec2d chord = pointAt(seg + 1) - pointAt(seg);
fsF32 chordLen = fsNMaths::sqrtF32(chord.x * chord.x + chord.y * chord.y);
if (chordLen < 1.0f)
{
chordLen = 1.0f;
}
mCometT += mCometSpeed * static_cast<fsF32>(pDeltaMs) / chordLen;
// cross into following segments, blooming a star on each intermediate piece
// reached (the final piece gets the bigger finish burst above instead)
while (mCometT >= 1.0f && seg < count - 1)
{
mCometT -= 1.0f;
++mCurrMinigameEnt;
++seg;
if (seg < count - 1)
{
particleCreate(mMinigameEnts[static_cast<std::size_t>(seg)],
mSparklePos[static_cast<std::size_t>(seg)], kCometStarScale);
}
}
// smooth Catmull-Rom curve through the pieces instead of straight-line hops
mCometPos = catmullRom(pointAt(seg - 1), pointAt(seg), pointAt(seg + 1), pointAt(seg + 2), mCometT);
mCometEnt->posSet(mCometPos);
}
fsBool gfCRoundCongratulationsGui::skippedMinigame() const
{
auto* const gameGui = fsILevelBasedAppCoreMain::instanceGet()->sceneGet()->firstEntityWithComponentsOfFamilyType<fsCGameGui>()->
firstComponentOfFamilyType<fsCGameGui>();
return gameGui->miniGameSkipGet();
}
void gfCRoundCongratulationsGui::bannerCreate()
{
if (fsIFile::fileExistsGet(fsCResourceName("gui/wellDone/wellDone1.txt", fsCResourceName::eRES_LOCATION_ASSETS)))
{
mCongratulationsBannerEnt = guiCreateFromFile(fsCResourceName(
fsStr("gui/wellDone/wellDone") +
fsStr(fsNRnd::uInt32GetWithLimit(3) + 1) +
fsStr(".txt"), fsCResourceName::eRES_LOCATION_ASSETS));
parentGet()->childAdd(mCongratulationsBannerEnt);
}
}
void gfCRoundCongratulationsGui::stateInit()
{
switch (mState)
{
case eSPARKLES:
{
miniGameEntitiesCollect();
cometCreate();
mTime = kCometChargeMs; // brief charge-up on the first piece before the comet sets off
break;
}
case eBANNER:
{
bannerCreate();
mTime = 3000;
break;
}
case ePAUSE_BEFORE_DONE:
{
mTime = 500;
break;
}
case eDONE:
{
ephemeralEntitiesDestroy();
mTime = 0;
completedMessageBroadcast();
levelCompleteSet();
break;
}
default:
break;
}
}
void gfCRoundCongratulationsGui::completedMessageBroadcast() const
{
fsCAppMessageDispatcher::instanceGet()->messageDispatch(
mWaitMessage
? gfCLevelCompleteCheckerComponent::mLevelCompleteWaitingMsg
: gfCLevelCompleteCheckerComponent::mLevelCompleterMsg,
fsIMessageDispatcher::sStrMessageParam(fsILevelBasedAppCoreMain::instanceGet()->currentLevelNameGet()));
}
void gfCRoundCongratulationsGui::ephemeralEntitiesDestroy()
{
if (mCometEnt)
{
mCometEnt->destroy();
mCometEnt = nullptr;
}
if (mCongratulationsBannerEnt)
{
mCongratulationsBannerEnt->destroy();
mCongratulationsBannerEnt = nullptr;
}
if (!mCongratulationParticles.empty())
{
std::for_each(mCongratulationParticles.begin(), mCongratulationParticles.end(),
[](fsCEntity* ent)
{
ent->destroy();
});
mCongratulationParticles.clear();
}
}
void gfCRoundCongratulationsGui::levelCompleteSet() const
{
appSceneFirstEntityWithComponentOfFamilyType<gfCMinigameCompleteComponent>()->componentGet<gfCMinigameCompleteComponent>()->
completedSet();
if (!skippedMinigame())
{
auto key= appSceneFirstEntityWithComponentOfFamilyType<gfIHogLevel>()->firstComponentOfFamilyType<gfIHogLevel>()->saveStateKeyGet();
key.replaceAll(gfCHogUserSavedData::mLevelDataPrefix,gfCHogUserSavedData::mLevelStatePrefix);
fsCProfileManager::instanceGet()->userSavedDataGet()->strSet(key, 1);
}
}
void gfCRoundCongratulationsGui::stateAdvance()
{
if (mState < eDONE)
{
mState = static_cast<eSTATE>(static_cast<fsU32>(mState) + 1);
stateInit();
}
}
void gfCRoundCongratulationsGui::updateDo(fsS32 pDeltaMs)
{
if (eREADY >= mState || mState >= eDONE)
{
return;
}
if (eSPARKLES == mState)
{
cometUpdate(pDeltaMs);
return;
}
// remaining timed states (eBANNER, ePAUSE_BEFORE_DONE) just advance when they expire
if (mTime)
{
mTime -= pDeltaMs;
if (mTime <= 0)
{
stateAdvance();
}
}
}
void gfCRoundCongratulationsGui::listenersRegisterDo()
{
fsCAppMessageDispatcher::instanceGet()->listenerRegister(
gfCLevelCompleteCheckerComponent::mLevelCompleteWaitingCongratsMsg, this);
fsCAppMessageDispatcher::instanceGet()->listenerRegister(
gfCLevelCompleteCheckerComponent::mLevelCompleterCongratsMsg, this);
fsIMessageListenerGuiComponent::listenersRegisterDo();
}
void gfCRoundCongratulationsGui::listenersDeregisterDo()
{
fsCAppMessageDispatcher::instanceGet()->listenerDeregister(
gfCLevelCompleteCheckerComponent::mLevelCompleteWaitingCongratsMsg, this);
fsCAppMessageDispatcher::instanceGet()->listenerDeregister(
gfCLevelCompleteCheckerComponent::mLevelCompleterCongratsMsg, this);
fsIMessageListenerGuiComponent::listenersDeregisterDo();
}
fsBool gfCRoundCongratulationsGui::messageProcessDo(const fsCUniqueId& pMessageType,
const fsIMessageDispatcher::sMessageParameters& pParam)
{
if (pMessageType == gfCLevelCompleteCheckerComponent::mLevelCompleterCongratsMsg ||
pMessageType == gfCLevelCompleteCheckerComponent::mLevelCompleteWaitingCongratsMsg)
{
if (pMessageType == gfCLevelCompleteCheckerComponent::mLevelCompleteWaitingCongratsMsg)
{
mWaitMessage = true;
}
// TEMP HACK: play the congrats effect even on a cheat-skipped level so the
// effect can be seen/tested. Restore the block below before shipping.
// if (skippedMinigame())
// {
// completedMessageBroadcast();
// return false;
// }
if (fsILevelBasedAppCoreMain::instanceGet()->levelSettingsGet()->boolGetWithDefault("skipCongrats", false))
{
mState = ePAUSE_BEFORE_DONE;
mTime = 1000;
}
else
{
stateAdvance();
}
}
return false;
}
fsIComponent* gfCRoundCongratulationsGui::create(fsCEntity* pParent)
{
return new gfCRoundCongratulationsGui(pParent);
}
gfCLevelCompleteCheckerComponent* gfCRoundCongratulationsGui::levelCompleteCheckComponentGet()
{
return fsCAppCoreMain::instanceGet()->sceneGet()->firstEntityWithComponentsOfFamilyType<gfCLevelCompleteCheckerComponent>()->
componentGet<gfCLevelCompleteCheckerComponent>();
}
gfCRoundCongratulationsGui::gfCRoundCongratulationsGui(fsCEntity* const pParent) :
fsIMessageListenerGuiComponent(pParent),
mState(eREADY),
mCongratulationsBannerEnt(nullptr),
mWaitMessage(false),
mCometEnt(nullptr),
mCometT(0.0f),
mCometSpeed(0.0f),
mTime(0)
{
levelCompleteCheckComponentGet()->congratulationsGuiRegister();
}
gfCRoundCongratulationsGui::~gfCRoundCongratulationsGui() = default;
|