Fission FSN
Loading...
Searching...
No Matches
gfCParkStaffViewComponent.h
Go to the documentation of this file.
1/********************************************************************
2*
3* File: gfCParkStaffViewComponent.h
4*
5* Purpose: Draws the park's staff: kiosk staff at their building,
6* repair staff out at a breakdown or idling at the
7* staffDepot. Positioning lives here (the sim is
8* spatial-free) and needs no new sim API - staff are
9* anonymous pools, so one entity per hired head is
10* reconciled to jobs derived from the slots. Keyed by
11* person, not job, so the same figure walks out and back
12* (see SStaffView).
13*
14*********************************************************************/
15
16#ifndef gfCParkStaffViewComponenthdr
17#define gfCParkStaffViewComponenthdr
18
19#include <vector>
20
22#include <fsCore/fsStr.h>
23#include <fsCore/fsVec2d.h>
24
26
27class fsCEntity;
28class gfCParkDaySim;
30
31namespace fsNTileMap
32{
33 class fsCView;
34}
35
37{
38 friend class fsCComponentFactory;
39
40public:
41
42 static const fsCUniqueId mTypeId;
43
44 // Shifts every staff member's position, target and path waypoints to stay
45 // attached to the ground as the camera scrolls (see
46 // gfCParkLevelComponent::scrollRefresh).
47 void scrollShift(const fsVec2d& pDelta);
48
50
51protected:
52
53 void updateDo(fsS32 pDeltaMs) override;
54
55 static fsIComponent* const create(fsCEntity* const pParent);
57
58private:
59
60 struct SStaffView
61 {
62 // A person, not a job: "<type>:<index>", stable while hired. Keying by
63 // job made counts drift (a walking-out repairer plus their replacement).
64 fsStr mKey;
65 fsStr mType;
66 fsS32 mIndex;
67 // Slot posted to (empty off duty). Kept so they don't swap buildings
68 // when the post list is rebuilt in a different order.
69 fsStr mAssignedSlot;
70 fsCEntity* mEntity;
71 fsVec2d mPos;
72 fsVec2d mTarget;
73 fsStr mAnimation;
74 // Remaining view-local waypoints of the current routed walk (front = next);
75 // mPathTarget* is the destination cell, so the route only recomputes when
76 // the target changes. Empty means walk straight.
77 std::vector<fsVec2d> mPath;
78 fsS32 mPathTargetCol = -999;
79 fsS32 mPathTargetRow = -999;
80 };
81
82 struct SStaffPost
83 {
84 fsStr mSlotName;
85 fsVec2d mPos;
86 };
87
88 fsNTileMap::fsCView* viewGet() const;
89 fsBool mapPointGet(fsNTileMap::fsCView* const pView, const fsStr& pObjectName, fsVec2d& pOut) const;
90
91 SStaffView* viewFind(const fsStr& pKey);
92 SStaffView& viewCreate(fsNTileMap::fsCView* const pView, const fsStr& pKey, const fsStr& pType,
93 fsS32 pIndex, const fsStr& pCharacterFolder, const fsVec2d& pAt);
94
95 void animationSet(SStaffView& pView, const fsStr& pAnimation);
96 fsBool moveToward(SStaffView& pView, const fsVec2d& pTarget, fsS32 pDeltaMs) const;
97
98 // Constant-speed walk that routes around uncleared forest via a BFS cell path
99 // (recomputed only when the destination cell changes), falling back to a
100 // straight line when no route exists. pView (the tile view) and pLevel supply
101 // the walkability grid.
102 fsBool moveTowardRouted(SStaffView& pStaff, fsNTileMap::fsCView* const pTileView,
103 const gfCParkLevelComponent* const pLevel,
104 const fsVec2d& pTarget, fsS32 pDeltaMs) const;
105
106 // Reconciles one staff type: exactly staffTotalGet(pType) entities exist,
107 // each keeps its post, spare posts go to the off-duty, the rest idle.
108 void staffTypeUpdate(fsNTileMap::fsCView* const pView, const gfCParkDaySim* const pSim,
109 const fsStr& pType, const fsStr& pCharacterFolder,
110 const std::vector<SStaffPost>& pPosts, const fsVec2d& pOfficePos,
111 fsBool pReWander);
112
113 std::vector<SStaffView> mViews;
114 fsS32 mIdleWanderMs;
115 fsS32 mWanderSeed;
116};
117
118#endif
Definition fsCEntity.h:39
Definition fsCUniqueId.h:21
fsIComponent(fsCEntity *pParent)
Definition fsIComponent.cpp:86
Definition fsCView.h:28
Definition fsStr.h:23
Definition gfCParkDaySim.h:25
Definition gfCParkLevelComponent.h:41
void updateDo(fsS32 pDeltaMs) override
Definition gfCParkStaffViewComponent.cpp:336
static fsIComponent *const create(fsCEntity *const pParent)
Definition gfCParkStaffViewComponent.cpp:487
friend class fsCComponentFactory
Definition gfCParkStaffViewComponent.h:38
void scrollShift(const fsVec2d &pDelta)
Definition gfCParkStaffViewComponent.cpp:470
gfCParkStaffViewComponent(fsCEntity *const pParent)
Definition gfCParkStaffViewComponent.cpp:492
static const fsCUniqueId mTypeId
Definition gfCParkStaffViewComponent.h:42
virtual ~gfCParkStaffViewComponent()
Definition gfCParkStaffViewComponent.cpp:499
bool fsBool
Definition fsBaseTypes.h:26
int fsS32
Definition fsBaseTypes.h:20
Definition fsILayer.h:21
Definition fsVec2d.h:16