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 | #include "gfCHOGHint.h"
#include <fsCore/src/fsNRnd.h>
#include <fsCore/src/fsCAppSettings.h>
#include <fsAppCore/src/components/fsISubSceneComponent.h>
#include <fsAppCore/src/fsCEntityFactory.h>
#include <fsAppCore/src/fsILevelBasedAppCoreMain.h>
#include <fsAppCore/src/fsCProfileManager.h>
#include <fsRenderer/src/components/fsCParticleEmitterComponent.h>
#include <fsAppCore/src/components/fsCHookedLineTrailComponent.h>
#include <gfMinigameCore/components/spotTheDiff/gfCSpotTheDiffMinigameComponent.h>
#include <gfComponents/components/subScene/gfCSubSceneViewComponent.h>
#include <gfComponents/components/subScene/gfCSubSceneNavigateComponent.h>
#include "../components/gui/gfCGameGui.h"
#include "gfCHogUserSavedData.h"
#include "components/flipsaw/gfCFlipsawMinigameComponent.h"
#include "components/jigsaw/gfCJigsawMinigameComponent.h"
#include "components/joinTheDots/gfCJoinTheDotsMinigameComponent.h"
#include "components/pairs/gfCPairsMinigameComponent.h"
#include "components/rotate/gfCRotateMinigameComponent.h"
#include "components/wordGames/wordSearch/gfCWordSearchMinigameLogicComponent.h"
fsBool gfCHOGHint::hinted() const
{
auto hintActive = hintOnSubSceneNavigationComponents();
hintActive |= hintOnWordSearch();
hintActive |= hintOnMinigames<gfCSpotTheDiffMinigameComponent>();
hintActive |= hintOnMinigames<gfCRotateMinigameComponent>();
hintActive |= hintOnMinigames<gfCPairsMinigameComponent>();
hintActive |= hintOnMinigames<gfCFlipsawMinigameComponent>();
hintActive |= hintOnMinigames<gfCJoinTheDotsMinigameComponent>();
hintActive |= hintOnMinigames<gfCJigsawMinigameComponent>();
return hintActive;
}
fsBool gfCHOGHint::hintOnSubSceneNavigationComponents() const
{
auto navEnts = mParent->appSceneEntitiesWithComponentOfFamilyType<gfCSubSceneNavigateComponent>();
for (auto curr = navEnts.begin(); curr != navEnts.end(); /*inc in the loop coz of erase*/)
{
if (!(*curr)->visibleGet())
{
curr = navEnts.erase(curr);
}
else
{
++curr;
}
}
if (!navEnts.empty())
{
std::shuffle(navEnts.begin(), navEnts.end(), fsNRnd::randomDeviceGet());
auto* const gameGui = fsILevelBasedAppCoreMain::instanceGet()->sceneGet()->firstEntityWithComponentsOfFamilyType<fsCGameGui>()->
componentGet<fsCGameGui>();
return gameGui->hintActivate(navEnts.front(), nullptr);
}
return false;
}
fsBool gfCHOGHint::hintOnWordSearch() const
{
if (auto wordSearchEnt = mParent->appSceneFirstEntityWithComponentOfFamilyType<gfCWordSearchMinigameLogicComponent>())
{
wordSearchEnt->componentGet<gfCWordSearchMinigameLogicComponent>()->hintActivate();
return true;
}
return false;
}
fsBool gfCHOGHint::activate(fsCEntity* const pStartEnt, fsCEntity* const pEndEnt)
{
hintEffectActivate(pStartEnt);
if (pEndEnt)
{
hintEffectActivate(pEndEnt);
}
return true;
}
void gfCHOGHint::zoomedLevelReset() const
{
fsISubSceneComponent* const sub = fsILevelBasedAppCoreMain::instanceGet()->currentSubSceneGet();
if (gfCSubSceneViewComponent* const view = sub->parentGet()->componentGet<gfCSubSceneViewComponent>())
{
view->zoomClear();
}
}
void gfCHOGHint::hintEffectActivate(fsCEntity* const pTargetEntity) const
{
zoomedLevelReset();
fsCEntity* hintEnt = pTargetEntity->entityFactoryGet()->emptyEntityCreate("HintEffect");
fsCParticleEmitterComponent* parEmitComp = hintEnt->componentAdd<fsCParticleEmitterComponent>();
parEmitComp->particelDataLoad(fsCResourceName(fsCAppCoreMain::instanceGet()->settingsGet()->
strGetWithDefault("hintParticle", "particles/pHint.txt"),
fsCResourceName::eRES_LOCATION_ASSETS));
fsCHookedLineTrailComponent* trailComp = hintEnt->componentAdd<fsCHookedLineTrailComponent>();
fsCEntity* const subScene = fsILevelBasedAppCoreMain::instanceGet()->currentSubSceneGet()->parentGet();
fsVec2d hintButtonPos;
subScene->screenCoordConvertToLocal(
fsCAppCoreMain::instanceGet()->sceneGet()->entityNamed("gameGuiHintButton")->screenPositionGet(),
hintButtonPos);
trailComp->initialise(hintButtonPos, pTargetEntity->posGet(), 4000, true);
subScene->childAdd(hintEnt);
fsCProfileManager::instanceGet()->userSavedDataGet()->s32Set(gfCHogUserSavedData::mAchievementHint, -1);
}
fsBool gfCHOGHint::previoustlyHinted(fsCEntity* const pEnt) const
{
return mPreviouslyHintedEnts.end() != std::find(mPreviouslyHintedEnts.begin(), mPreviouslyHintedEnts.end(), pEnt);
}
fsBool gfCHOGHint::activate(std::vector<fsCEntity*>& pCandidates)<--- Parameter 'pCandidates' can be declared as reference to const
{
std::vector<fsCEntity*> validEntities = pCandidates;
if (!validEntities.empty())
{
validEntities.erase(std::remove_if(validEntities.begin(), validEntities.end(),
[this](fsCEntity* const ent) { return previoustlyHinted(ent); }),
validEntities.end());
if (validEntities.empty())
{
mPreviouslyHintedEnts.clear();
validEntities = pCandidates;
}
std::shuffle(validEntities.begin(), validEntities.end(), fsNRnd::randomDeviceGet());
hintEffectActivate(validEntities.front());
mPreviouslyHintedEnts.push_back(validEntities.front());
return true;
}
return false;
}
gfCHOGHint::gfCHOGHint(fsCGameGui* const pParent):
mParent(pParent)
{
}
gfCHOGHint::~gfCHOGHint()
{
}
|