Fission FSN
Loading...
Searching...
No Matches
gfCParkClearComponent.h
Go to the documentation of this file.
1/********************************************************************
2*
3* File: gfCParkClearComponent.h
4*
5* Purpose: Transient "clear forest" tool. Lives on its own short-lived
6* entity, spawned by gfCParkHudGui when the player arms the clear
7* tool. A tile-sized marker follows the pointer, snapping to the
8* hovered grid cell and tinted green over clearable forest / red
9* otherwise. A valid tap clears that forest cell (charging coins
10* via gfCParkLevelComponent::forestClearAt) and stays armed so the
11* player can clear a run of tiles, until the HUD toggles it off.
12*
13*********************************************************************/
14
15#ifndef gfCParkClearComponenthdr
16#define gfCParkClearComponenthdr
17
19
21
22class fsCEntity;
23struct fsPoint;
24
25
27{
28 friend class fsCComponentFactory;
29
30public:
31
32 static const fsCUniqueId mTypeId;
33
34 // Arm the tool and show the hover marker. Called right after componentAdd.
35 void clearBegin();
36
37 // Cancel the tool when the HUD clear toggle is switched off. Destroys the
38 // marker and this component's host entity - clearing already persisted per tap.
39 void clearEnd();
40
41 virtual ~gfCParkClearComponent();
42
43protected:
44
45 void listenersRegisterDo() override;
46 void listenersDeregisterDo() override;
47 fsBool messageProcessDo(const fsCUniqueId& pMessageType,
48 const fsIMessageDispatcher::sMessageParameters& pParam) override;
49
50 static fsIComponent* const create(fsCEntity* const pParent);
51 gfCParkClearComponent(fsCEntity* const pParent);
52
53private:
54
55 void previewCreate();
56 void previewDestroy();
57 // Recompute the hovered cell and marker colour for a screen position. Returns
58 // true when that cell is a clearable forest tile the player can afford.
59 fsBool previewUpdate(const fsPoint& pScreenPos);
60
61 fsCEntity* mPreviewEntity;
62 fsS32 mHoverCol;
63 fsS32 mHoverRow;
64 fsBool mHoverValid;
65};
66
67#endif
Definition fsCEntity.h:39
Definition fsCUniqueId.h:21
fsIComponent(fsCEntity *pParent)
Definition fsIComponent.cpp:86
fsIMessageListenerComponent(fsCEntity *pParent)
Definition fsIMessageListenerComponent.cpp:9
void clearEnd()
Definition gfCParkClearComponent.cpp:94
static fsIComponent *const create(fsCEntity *const pParent)
Definition gfCParkClearComponent.cpp:241
fsBool messageProcessDo(const fsCUniqueId &pMessageType, const fsIMessageDispatcher::sMessageParameters &pParam) override
Definition gfCParkClearComponent.cpp:187
static const fsCUniqueId mTypeId
Definition gfCParkClearComponent.h:32
friend class fsCComponentFactory
Definition gfCParkClearComponent.h:28
void listenersDeregisterDo() override
Definition gfCParkClearComponent.cpp:234
void listenersRegisterDo() override
Definition gfCParkClearComponent.cpp:227
virtual ~gfCParkClearComponent()
Definition gfCParkClearComponent.cpp:255
gfCParkClearComponent(fsCEntity *const pParent)
Definition gfCParkClearComponent.cpp:246
void clearBegin()
Definition gfCParkClearComponent.cpp:88
bool fsBool
Definition fsBaseTypes.h:26
int fsS32
Definition fsBaseTypes.h:20
Definition fsIMessageDispatcher.h:32
Definition fsPoint.h:17