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 | /********************************************************************
*
* File: fsCHogLevel.h
*
* Purpose: Create and control game entities.
*
*********************************************************************/
#ifndef gfCHogLevelhdr
#define gfCHogLevelhdr
#include <vector>
#include <fsCore/fsStr.h>
#include <fsCore/fsPoint.h>
#include "../gfIHogLevel.h"
#include "components/gfIMinigameLogic.h"
#include "src/fsCEntityFactory.h"
class gfCSubSceneComponent;
class fsRect;
class gfCHogLevelComponent : public gfIHogLevel
{
friend class fsCComponentFactory;
public:
static const fsCUniqueId mTypeId;
static const fsCUniqueId mLevelSkippedMsg;
void renderEffectRefresh();
void listenersDeregisterDo() override;
void listenersRegisterDo() override;
fsBool messageProcessDo(const fsCUniqueId& pMessageType,
const fsIMessageDispatcher::sMessageParameters& pParam) override;
protected:
static fsIComponent* create(fsCEntity* pParent);
void skipDo() override;
void updateDo(fsS32 pDeltaMs) override;<--- Function in derived class
void renderDo() override;
virtual void actAdvance();
virtual fsStr rewardSequencFileNameGetIfActive();
virtual void levelResetDo();
void abortDo() override;
void doLevelCreate() override;
gfCHogLevelComponent(fsCEntity* pParent);
virtual ~gfCHogLevelComponent();<--- Destructor in derived class
private:
enum eDebugRenderEffect
{
eDEBUG_RENDER_EFFECT_NONE,
eDEBUG_RENDER_EFFECT_MAGNIFY,
eDEBUG_RENDER_EFFECT_TORCH
};
template<typename TLogic, typename TMinigame>
void minigameLogicAdd(std::vector<gfIMinigameLogic*>& pLogicEntities);
template<typename TLogic>
void minigameLogicAdd(std::vector<gfIMinigameLogic*>& pLogicEntities, const fsStr& pEntityName = "");
fsBool devCheatKeyTest(fsS32 pTypedChar);
void renderEffectApply(eDebugRenderEffect pEffect);
void debugRenderEffectCycle();
fsBool releaseCheatKeyTest(fsS32 pTypedChar);
void tutorialAdd();
void levelReset();
void reset();
void miniGameLogicComponentsAdd();
void actCompleteHandle();
fsBool levelSkippedForAnalytics() const;
fsS32 adFreeLevelCountGet() const;
fsS32 rewardPackSizeGet() const;
fsS32 rewardTailGraceCountGet() const;
fsS32 rewardUnlockedLevelCountGet(fsS32 pTotalLevels) const;
void rewardUnlockedLevelCountSet(fsS32 pUnlockedCount) const;
fsBool rewardGateRequiredForNextLevel() const;
void rewardUnlockGrantForCurrentBoundary();
fsBool interstitialAllowedForCurrentLevel() const;
void rewardGatePaywallShow();
fsBool typedCharacterHandle(fsS32 pTypedChar);
fsBool mResetDuringFade;
fsBool mPendingInterstitialOnFadeOut;
fsBool mRewardGatePending;
fsBool mPaywallDestroyOnFadeOut;
fsBool mSkipInterstitialOnce;
fsBool mLevelSkippedForAnalytics;
eDebugRenderEffect mDebugRenderEffect;
fsS32 mDebugRenderEffectCycleIndex;
};
// Always add/collect the logic, using its full construction plan when an entity name is supplied.
template<typename TLogic>
void gfCHogLevelComponent::minigameLogicAdd(std::vector<gfIMinigameLogic*>& logicEntities,
const fsStr& entityName)
{
auto* parent = parentGet();
auto* logicEntity = parent->firstChildEntityWithComponentsOfFamilyType<TLogic>();
if (!logicEntity)
{
if (entityName.emptyGet())
{
logicEntity = parent->entityFactoryGet()->emptyEntityCreate("minigameLogic");
logicEntity->template componentAdd<TLogic>();
}
else
{
logicEntity = parent->entityFactoryGet()->entityConstruct(entityName);
}
parent->childAdd(logicEntity);
}
auto* logic = logicEntity->template firstComponentOfFamilyType<TLogic>();
if (std::find(logicEntities.begin(), logicEntities.end(), logic) ==
logicEntities.end())
{
logicEntities.push_back(logic);
}
}
// Add/collect the logic only when the minigame exists.
template<typename TLogic, typename TMinigame>
void gfCHogLevelComponent::minigameLogicAdd(std::vector<gfIMinigameLogic*>& logicEntities)
{
if (!parentGet()->template firstChildEntityWithComponentsOfFamilyType<TMinigame>())
{
return;
}
minigameLogicAdd<TLogic>(logicEntities);
}
#endif
|