Subsystem: WorkerSlots - Adam-Poppenheimer/Civ-Clone GitHub Wiki

WorkerSlots is a very small subsystem, but an important one. It handles the objects citizens can work in to produce yield.

Every cell in the game possesses a single WorkerSlot that produces some amount of yield per turn if it's worked by a citizen in a city. Many buildings also have WorkerSlots that do the same.

The subsystem exists to create and support IWorkerSlot. IWorkerSlot keeps track of its parent (either an IBuilding or an IHexCell) and whether it is occupied or locked. It doesn't store reference to its yield, because the calculation of its yield is very complex. Its standard implementation, the basic class WorkerSlot, fires events when the slot becomes occupied, unoccupied, locked, and unlocked. IWorkerSlots are created by (I)WorkerSlotFactory. Its signals are stored in WorkerSlotSignals.

IWorkerSlots are locked when it's not valid for a citizen to work there. Currently that's done to make city centers unworkable, as is the case in Civilization 5.