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* staffOffice. 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
45
46protected:
47
48 void updateDo(fsS32 pDeltaMs) override;
49
50 static fsIComponent* const create(fsCEntity* const pParent);
52
53private:
54
55 struct SStaffView
56 {
57 // A person, not a job: "<type>:<index>", stable while hired. Keying by
58 // job made counts drift (a walking-out repairer plus their replacement).
59 fsStr mKey;
60 fsStr mType;
61 fsS32 mIndex;
62 // Slot posted to (empty off duty). Kept so they don't swap buildings
63 // when the post list is rebuilt in a different order.
64 fsStr mAssignedSlot;
65 fsCEntity* mEntity;
66 fsVec2d mPos;
67 fsVec2d mTarget;
68 fsStr mAnimation;
69 // Remaining view-local waypoints of the current routed walk (front = next);
70 // mPathTarget* is the destination cell, so the route only recomputes when
71 // the target changes. Empty means walk straight.
72 std::vector<fsVec2d> mPath;
73 fsS32 mPathTargetCol = -999;
74 fsS32 mPathTargetRow = -999;
75 };
76
77 struct SStaffPost
78 {
79 fsStr mSlotName;
80 fsVec2d mPos;
81 };
82
83 fsNTileMap::fsCView* viewGet() const;
84 fsBool mapPointGet(fsNTileMap::fsCView* const pView, const fsStr& pObjectName, fsVec2d& pOut) const;
85
86 SStaffView* viewFind(const fsStr& pKey);
87 SStaffView& viewCreate(fsNTileMap::fsCView* const pView, const fsStr& pKey, const fsStr& pType,
88 fsS32 pIndex, const fsStr& pCharacterFolder, const fsVec2d& pAt);
89
90 void animationSet(SStaffView& pView, const fsStr& pAnimation);
91 fsBool moveToward(SStaffView& pView, const fsVec2d& pTarget, fsS32 pDeltaMs) const;
92
93 // Constant-speed walk that routes around uncleared forest via a BFS cell path
94 // (recomputed only when the destination cell changes), falling back to a
95 // straight line when no route exists. pView (the tile view) and pLevel supply
96 // the walkability grid.
97 fsBool moveTowardRouted(SStaffView& pStaff, fsNTileMap::fsCView* const pTileView,
98 const gfCParkLevelComponent* const pLevel,
99 const fsVec2d& pTarget, fsS32 pDeltaMs) const;
100
101 // Reconciles one staff type: exactly staffTotalGet(pType) entities exist,
102 // each keeps its post, spare posts go to the off-duty, the rest idle.
103 void staffTypeUpdate(fsNTileMap::fsCView* const pView, const gfCParkDaySim* const pSim,
104 const fsStr& pType, const fsStr& pCharacterFolder,
105 const std::vector<SStaffPost>& pPosts, const fsVec2d& pOfficePos,
106 fsBool pReWander);
107
108 std::vector<SStaffView> mViews;
109 fsS32 mIdleWanderMs;
110 fsS32 mWanderSeed;
111};
112
113#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:331
static fsIComponent *const create(fsCEntity *const pParent)
Definition gfCParkStaffViewComponent.cpp:456
friend class fsCComponentFactory
Definition gfCParkStaffViewComponent.h:38
gfCParkStaffViewComponent(fsCEntity *const pParent)
Definition gfCParkStaffViewComponent.cpp:461
static const fsCUniqueId mTypeId
Definition gfCParkStaffViewComponent.h:42
virtual ~gfCParkStaffViewComponent()
Definition gfCParkStaffViewComponent.cpp:468
bool fsBool
Definition fsBaseTypes.h:26
int fsS32
Definition fsBaseTypes.h:20
Definition fsILayer.h:21
Definition fsVec2d.h:16