Fission FSN
Loading...
Searching...
No Matches
gfCParkDaySim.h
Go to the documentation of this file.
1/********************************************************************
2*
3* File: gfCParkDaySim.h
4*
5* Purpose: Headless day-loop orchestrator: arrival director, visitors,
6* service slots and economy. Exploring is primary; authored
7* service needs are optional diversions during a park visit.
8*
9*********************************************************************/
10
11#ifndef gfCParkDaySimhdr
12#define gfCParkDaySimhdr
13
14#include <vector>
15
16#include <fsCore/fsStr.h>
17#include <fsCore/fsBaseTypes.h>
18
19#include "gfCSlotSim.h"
20#include "gfCGuestAgentSim.h"
22#include "gfCDayEconomySim.h"
23
25{
26public:
27
28 gfCParkDaySim(fsS32 pSpawnIntervalMs, fsS32 pMaxGuests, fsS32 pCoinGoal);
29
30 void slotAdd(const fsStr& pName, const fsStr& pSlotType, fsS32 pServiceTimeMs, fsS32 pMaxQueueLength,
31 fsBool pUnlocked);
32
33 // Unlocks a registered slot when its building is purchased. False if no
34 // such slot exists.
35 fsBool slotUnlock(const fsStr& pName);
36
37 // Staff types (kiosk mans a building, repair fixes broken ones). Keyed by
38 // string so staff.yml stays the source of truth for roles.
39 static const fsStr mStaffTypeKiosk;
40 static const fsStr mStaffTypeRepair;
41
42 // Genre guard: staff are a scarce, player-deployed resource. Growing the
43 // pool doesn't staff anything - only deploy/recall does.
44 void staffPoolGrow(const fsStr& pStaffType, fsS32 pBy = 1);
45 fsS32 staffTotalGet(const fsStr& pStaffType) const;
46 fsS32 staffAvailableGet(const fsStr& pStaffType) const;
47
48 // Untyped overloads mean "kiosk" (keeps the doctests unchanged).
52
53 // False (no-op) if there's no such slot, it's already staffed, or the
54 // pool has nobody available.
55 fsBool staffDeploy(const fsStr& pSlotName);
56
57 // False (no-op) if there's no such slot or it isn't staffed.
58 fsBool staffRecall(const fsStr& pSlotName);
59
60 fsBool slotStaffedGet(const fsStr& pSlotName) const;
61 fsBool slotBrokenGet(const fsStr& pSlotName) const;
62 fsBool slotRepairingGet(const fsStr& pSlotName) const;
63
64 // Applied to every slot; 0 for a limit means "never breaks that way". Both
65 // default to 0, so slots are indestructible unless a game opts in.
66 void slotWearLimitsSetAll(fsS32 pServicesBeforeBreak, fsS32 pOpenMsBeforeBreak);
67 void repairTimeMsSet(fsS32 pRepairTimeMs) { mRepairTimeMs = pRepairTimeMs; }
68
69 // Sends an idle repairer to a slot (fix or preventive), tying them up until
70 // done. False if none free or one is already on it.
71 fsBool slotRepairBegin(const fsStr& pSlotName);
72
73 // Registers a visitor type selected by smooth catalogue-authored weighting.
74 // The single-need overload keeps small callers concise; catalogue content
75 // uses the vector overload to author a sequence of secondary needs.
76 void guestTemplateAdd(const fsStr& pNamePrefix, const fsStr& pNeedSlotType,
77 fsS32 pSpend, fsS32 pPatienceMs, fsS32 pVisitMs = 5000,
78 fsS32 pNeedIntervalMs = 0, fsS32 pArrivalWeight = 1,
79 fsS32 pPartySize = 1);
80 void guestTemplateAdd(const fsStr& pNamePrefix, const std::vector<fsStr>& pNeedSlotTypes,
81 fsS32 pSpend, fsS32 pPatienceMs, fsS32 pVisitMs,
82 fsS32 pNeedIntervalMs, fsS32 pArrivalWeight = 1,
83 fsS32 pPartySize = 1);
84
85 // Walk time to a slot before service can start. Defaults to 0 (keeps the
86 // doctests' timings); the game sets a real value.
87 void guestTravelMsSet(fsS32 pTravelMs) { mGuestTravelMs = pTravelMs; }
88 // Environmental comfort changes the value of the wandering portion of every
89 // visit. It applies to current guests as well as future arrivals.
91 fsS32 walkingSatisfactionPercentGet() const { return mWalkingSatisfactionPercent; }
92
93 // Daily admissions cap supplied by the best owned entrance. It can increase
94 // mid-day when an entrance is built without resetting the spawn timer.
95 void visitorQuotaSet(fsS32 pVisitorQuota);
96 fsS32 visitorQuotaGet() const { return mVisitorQuota; }
97 void visitorDemandSet(fsS32 pVisitorDemand);
98 fsS32 visitorDemandGet() const { return mVisitorDemand; }
99 fsS32 visitorArrivalTargetGet() const { return mArrivalDirector.maxGuestsGet(); }
100
101 // Chance that a guest who reaches an unstaffed matching building completes a
102 // self-guided visit and leaves happy. Zero preserves the strict staffed-only
103 // simulation; the park game opts into a content-tuned percentage.
104 void unstaffedVisitHappyChancePercentSet(fsS32 pChancePercent);
105
106 // Overrides one walking guest's remaining travel time. The sim is
107 // spatial-free, so it can only apply a flat guestTravelMs to every walk -
108 // which makes distant slots look faster (same time, more distance). The
109 // presentation layer, which knows the real distance, calls this so travel
110 // time tracks distance and the sprite walks at a constant speed. No-op if
111 // there's no such guest. See gfCParkGuestViewComponent.
112 void guestTravelTimeSet(const fsStr& pGuestName, fsS32 pTravelMs);
113
114 // Applied when a building is purchased into the slot. False if no such slot.
115 fsBool slotServiceTimeMsSet(const fsStr& pSlotName, fsS32 pServiceTimeMs);
116 fsBool slotMaxQueueLengthSet(const fsStr& pSlotName, fsS32 pMaxQueueLength);
117
118 void tick(fsS32 pDeltaMs);
119
120 fsS32 activeGuestCountGet() const { return static_cast<fsS32>(mGuests.size()); }
121 fsS32 guestsSpawnedGet() const { return mGuestsSpawnedCount; }
122
123 // Read-only guest enumeration for presentation, paired with
124 // activeGuestCountGet(). Null if out of range. Guests are erased the tick
125 // they enter LEAVING_*, so a caller wanting to animate departures must hold
126 // its own copy (see gfCParkGuestViewComponent).
127 const gfCGuestAgentSim* guestGetByIndex(fsS32 pIndex) const;
128
129 // Departures from the most recent tick (name + why), cleared at the start of
130 // the next - the only place to see *why* a guest left, since they're erased
131 // the same tick. A caller running after each tick sees each one once.
138
139 fsS32 departureCountGet() const { return static_cast<fsS32>(mDepartures.size()); }
140 const SDeparture* departureGetByIndex(fsS32 pIndex) const;
141 const gfCDayEconomySim& economyGet() const { return mEconomy; }
142 gfCDayEconomySim& economyGet() { return mEconomy; }
143
144private:
145
146 struct SGuestTemplate
147 {
148 fsStr mNamePrefix;
149 std::vector<fsStr> mNeedSlotTypes;
150 fsS32 mSpend;
151 fsS32 mPatienceMs;
152 fsS32 mVisitMs;
153 fsS32 mNeedIntervalMs;
154 fsS32 mArrivalWeight;
155 fsS32 mPartySize;
156 fsS32 mSelectionCredit;
157 };
158
159 void guestSpawn();
160 gfCGuestAgentSim* guestFind(const fsStr& pName);
161
162 // Prefer a staffed matching slot whose wait fits this guest's patience;
163 // otherwise fall back to an unstaffed matching building with room.
164 gfCSlotSim* slotWithRoomFind(const fsStr& pSlotType, fsS32 pPatienceRemainingMs);
165 fsBool unstaffedVisitHappyRoll();
166
167 // Joins the guest's assigned slot, setting state. False if it filled up
168 // while they walked over.
169 fsBool guestSlotJoin(gfCGuestAgentSim& pGuest);
170 void guestServiceComplete(gfCGuestAgentSim& pGuest);
171
172 std::vector<gfCSlotSim> mSlots;
173 std::vector<gfCGuestAgentSim> mGuests;
174 std::vector<SDeparture> mDepartures;
175 std::vector<SGuestTemplate> mGuestTemplates;
176
177 gfCArrivalDirectorSim mArrivalDirector;
178 gfCDayEconomySim mEconomy;
179
180 fsS32 mGuestsSpawnedCount;
181 fsS32 mVisitorQuota;
182 fsS32 mVisitorDemand;
183
184 struct SStaffPool
185 {
186 fsStr mType;
187 fsS32 mTotal;
188 fsS32 mDeployed;
189 };
190
191 SStaffPool* staffPoolFind(const fsStr& pStaffType);
192 const SStaffPool* staffPoolFind(const fsStr& pStaffType) const;
193
194 std::vector<SStaffPool> mStaffPools;
195 fsS32 mGuestTravelMs;
196 fsS32 mWalkingSatisfactionPercent;
197 fsS32 mRepairTimeMs;
198 fsS32 mUnstaffedVisitHappyChancePercent;
199 fsU32 mUnstaffedVisitRandomState;
200
201 // Slots being repaired, so the repairer is handed back on completion.
202 std::vector<fsStr> mSlotsUnderRepair;
203
204 gfCSlotSim* slotFind(const fsStr& pName);
205 const gfCSlotSim* slotFind(const fsStr& pName) const;
206};
207
208#endif
Definition fsStr.h:23
Definition gfCDayEconomySim.h:19
Definition gfCGuestAgentSim.h:35
fsS32 staffAvailableGet() const
Definition gfCParkDaySim.h:51
fsBool slotBrokenGet(const fsStr &pSlotName) const
Definition gfCParkDaySim.cpp:203
gfCDayEconomySim & economyGet()
Definition gfCParkDaySim.h:142
void staffPoolGrow(const fsStr &pStaffType, fsS32 pBy=1)
Definition gfCParkDaySim.cpp:118
fsBool slotUnlock(const fsStr &pName)
Definition gfCParkDaySim.cpp:59
fsBool slotServiceTimeMsSet(const fsStr &pSlotName, fsS32 pServiceTimeMs)
Definition gfCParkDaySim.cpp:403
void unstaffedVisitHappyChancePercentSet(fsS32 pChancePercent)
Definition gfCParkDaySim.cpp:305
void visitorQuotaSet(fsS32 pVisitorQuota)
Definition gfCParkDaySim.cpp:35
const gfCDayEconomySim & economyGet() const
Definition gfCParkDaySim.h:141
void slotAdd(const fsStr &pName, const fsStr &pSlotType, fsS32 pServiceTimeMs, fsS32 pMaxQueueLength, fsBool pUnlocked)
Definition gfCParkDaySim.cpp:49
fsS32 visitorQuotaGet() const
Definition gfCParkDaySim.h:96
fsS32 guestsSpawnedGet() const
Definition gfCParkDaySim.h:121
fsBool staffRecall(const fsStr &pSlotName)
Definition gfCParkDaySim.cpp:167
fsS32 staffTotalGet() const
Definition gfCParkDaySim.h:50
const SDeparture * departureGetByIndex(fsS32 pIndex) const
Definition gfCParkDaySim.cpp:284
void guestTravelTimeSet(const fsStr &pGuestName, fsS32 pTravelMs)
Definition gfCParkDaySim.cpp:425
static const fsStr mStaffTypeRepair
Definition gfCParkDaySim.h:40
fsS32 walkingSatisfactionPercentGet() const
Definition gfCParkDaySim.h:91
void visitorDemandSet(fsS32 pVisitorDemand)
Definition gfCParkDaySim.cpp:42
gfCParkDaySim(fsS32 pSpawnIntervalMs, fsS32 pMaxGuests, fsS32 pCoinGoal)
Definition gfCParkDaySim.cpp:10
void repairTimeMsSet(fsS32 pRepairTimeMs)
Definition gfCParkDaySim.h:67
fsBool slotRepairingGet(const fsStr &pSlotName) const
Definition gfCParkDaySim.cpp:209
fsBool staffDeploy(const fsStr &pSlotName)
Definition gfCParkDaySim.cpp:145
fsBool slotStaffedGet(const fsStr &pSlotName) const
Definition gfCParkDaySim.cpp:237
void guestTemplateAdd(const fsStr &pNamePrefix, const fsStr &pNeedSlotType, fsS32 pSpend, fsS32 pPatienceMs, fsS32 pVisitMs=5000, fsS32 pNeedIntervalMs=0, fsS32 pArrivalWeight=1, fsS32 pPartySize=1)
Definition gfCParkDaySim.cpp:243
void staffPoolGrow(fsS32 pBy=1)
Definition gfCParkDaySim.h:49
static const fsStr mStaffTypeKiosk
Definition gfCParkDaySim.h:39
void tick(fsS32 pDeltaMs)
Definition gfCParkDaySim.cpp:469
const gfCGuestAgentSim * guestGetByIndex(fsS32 pIndex) const
Definition gfCParkDaySim.cpp:275
fsS32 activeGuestCountGet() const
Definition gfCParkDaySim.h:120
void slotWearLimitsSetAll(fsS32 pServicesBeforeBreak, fsS32 pOpenMsBeforeBreak)
Definition gfCParkDaySim.cpp:195
void guestTravelMsSet(fsS32 pTravelMs)
Definition gfCParkDaySim.h:87
fsS32 departureCountGet() const
Definition gfCParkDaySim.h:139
fsBool slotRepairBegin(const fsStr &pSlotName)
Definition gfCParkDaySim.cpp:215
fsS32 visitorDemandGet() const
Definition gfCParkDaySim.h:98
void walkingSatisfactionPercentSet(fsS32 pPercent)
Definition gfCParkDaySim.cpp:24
fsS32 visitorArrivalTargetGet() const
Definition gfCParkDaySim.h:99
fsBool slotMaxQueueLengthSet(const fsStr &pSlotName, fsS32 pMaxQueueLength)
Definition gfCParkDaySim.cpp:414
unsigned int fsU32
Definition fsBaseTypes.h:21
bool fsBool
Definition fsBaseTypes.h:26
int fsS32
Definition fsBaseTypes.h:20
Definition gfCParkDaySim.h:133
fsS32 mSatisfactionPercent
Definition gfCParkDaySim.h:136
fsBool mHappy
Definition gfCParkDaySim.h:135
fsStr mName
Definition gfCParkDaySim.h:134