Loading...
Searching...
No Matches
CityBuilderCore.DefaultPopulationManager Class Reference

Detailed Description

default implementation of all people systems bundeld up into one for convenience

https://citybuilder.softleitner.com/manual/people

Inheritance diagram for CityBuilderCore.DefaultPopulationManager:
CityBuilderCore.IPopulationManager CityBuilderCore.IEmploymentManager CityBuilderCore.IWorkplaceFinder

Classes

class  EmploymentData
 
class  EmploymentGroupData
 
class  PopulationData
 

Public Member Functions

Migration GetMigration (Population population)
 
IEnumerable< IHousingGetHousings ()
 
int GetQuantity (Population population, bool includeReserved=false)
 calculates the total quantity of a population currently being housed in the city
 
int GetCapacity (Population population)
 calculates the total quantity of a population that can be housed in the city
 
int GetRemainingCapacity (Population population)
 calculated how many more of a population fits into the city
 
void AddHomeless (Population population, IHousing housing, int quantity)
 spawns homeless walkers that carry the population quantity and try to find new housing
used when housing downgrades and can no longer hold the quantity it did before
 
void AddEmployment (IEmployment employment)
 registers an employment with the manager so that it can now be considered when distributing available employees
typically called in Start
 
void RemoveEmployment (IEmployment employment)
 removes an employment that was previously added to the manager, the employment will no longer have any employees assigned
typically called in OnDestroy
 
int GetNeeded (Population population, EmploymentGroup group=null)
 checks how many employees in a population are currently needed
 
int GetAvailable (Population population, EmploymentGroup group=null)
 checks how many employees in a population are available for work
 
int GetEmployed (Population population, EmploymentGroup group=null)
 checks how many employees in a population are currently employed
 
float GetEmploymentRate (Population population)
 calculates employment rate for a population(needed/available) 100 jobs for 200 employees > 0.5
300 jobs for 100 employees > 3.0
 
float GetWorkerRate (Population population)
 calculates worker rate for population(available/needed) 100 jobs for 200 employees > 2.0
300 jobs for 150 employees > 0.5
 
void CheckEmployment ()
 forces immediate redistribution of employees
ususally the manager does this itself, this is called after loading so there is no wait time
 
int GetPriority (EmploymentGroup group)
 checks the current priority of an employment group
the priority determines in which order employees are assigned
 
void SetPriority (EmploymentGroup group, int priority)
 changes the priority of an employment group
this changes which employment groups employees are distributed to first
 
WorkerPath GetWorkerPath (IBuilding building, Vector2Int? currentPoint, Worker worker, ItemStorage storage, float maxDistance, PathType pathType, object pathTag)
 attempts to find a worker path for a worker
 
WorkerPathQuery GetWorkerPathQuery (IBuilding building, Vector2Int? currentPoint, Worker worker, ItemStorage storage, float maxDistance, PathType pathType, object pathTag)
 attempts to find a worker path for a worker
 

Protected Member Functions

virtual void Awake ()
 
virtual void Start ()
 

Member Function Documentation

◆ AddEmployment()

void CityBuilderCore.DefaultPopulationManager.AddEmployment ( IEmployment employment)
inline

registers an employment with the manager so that it can now be considered when distributing available employees
typically called in Start

Parameters
employmentthe employment to add to the manager

Implements CityBuilderCore.IEmploymentManager.

◆ AddHomeless()

void CityBuilderCore.DefaultPopulationManager.AddHomeless ( Population population,
IHousing housing,
int quantity )
inline

spawns homeless walkers that carry the population quantity and try to find new housing
used when housing downgrades and can no longer hold the quantity it did before

Parameters
populationthe type of population(plebs, aristocrats, ...)
housingthe housing that downgraded
quantityquantity that no longer fits into the housing

Implements CityBuilderCore.IPopulationManager.

◆ CheckEmployment()

void CityBuilderCore.DefaultPopulationManager.CheckEmployment ( )
inline

forces immediate redistribution of employees
ususally the manager does this itself, this is called after loading so there is no wait time

Implements CityBuilderCore.IEmploymentManager.

◆ GetAvailable()

int CityBuilderCore.DefaultPopulationManager.GetAvailable ( Population population,
EmploymentGroup group = null )
inline

checks how many employees in a population are available for work

Parameters
populationthe populatio to check
groupthe group, null for all groups
Returns
employee count available for work

Implements CityBuilderCore.IEmploymentManager.

◆ GetCapacity()

int CityBuilderCore.DefaultPopulationManager.GetCapacity ( Population population)
inline

calculates the total quantity of a population that can be housed in the city

Parameters
populationthe type of population(plebs, aristocrats, ...)
Returns
total capacit

Implements CityBuilderCore.IPopulationManager.

◆ GetEmployed()

int CityBuilderCore.DefaultPopulationManager.GetEmployed ( Population population,
EmploymentGroup group = null )

checks how many employees in a population are currently employed

Parameters
populationthe populatio to check
groupthe group, null for all groups
Returns
employee count currently employed

Implements CityBuilderCore.IEmploymentManager.

◆ GetEmploymentRate()

float CityBuilderCore.DefaultPopulationManager.GetEmploymentRate ( Population population)
inline

calculates employment rate for a population(needed/available) 100 jobs for 200 employees > 0.5
300 jobs for 100 employees > 3.0

Parameters
populationthe populatio to check
Returns
employment rate(below 1 when more people than jobs)

Implements CityBuilderCore.IEmploymentManager.

◆ GetNeeded()

int CityBuilderCore.DefaultPopulationManager.GetNeeded ( Population population,
EmploymentGroup group = null )
inline

checks how many employees in a population are currently needed

Parameters
populationthe populatio to check
groupthe group, null for all groups
Returns
employee count currently needed

Implements CityBuilderCore.IEmploymentManager.

◆ GetPriority()

int CityBuilderCore.DefaultPopulationManager.GetPriority ( EmploymentGroup group)
inline

checks the current priority of an employment group
the priority determines in which order employees are assigned

Parameters
groupthe group to check
Returns
current priority

Implements CityBuilderCore.IEmploymentManager.

◆ GetQuantity()

int CityBuilderCore.DefaultPopulationManager.GetQuantity ( Population population,
bool includeReserved = false )
inline

calculates the total quantity of a population currently being housed in the city

Parameters
populationthe type of population(plebs, aristocrats, ...)
includeReservedwhether migrants that have not arrived at their housing should be counted
Returns
total population count

Implements CityBuilderCore.IPopulationManager.

◆ GetRemainingCapacity()

int CityBuilderCore.DefaultPopulationManager.GetRemainingCapacity ( Population population)
inline

calculated how many more of a population fits into the city

Parameters
populationthe type of population(plebs, aristocrats, ...)
Returns
remaining capacity in the city

Implements CityBuilderCore.IPopulationManager.

◆ GetWorkerPath()

WorkerPath CityBuilderCore.DefaultPopulationManager.GetWorkerPath ( IBuilding building,
Vector2Int? currentPoint,
Worker worker,
ItemStorage storage,
float maxDistance,
PathType pathType,
object pathTag )
inline

attempts to find a worker path for a worker

Parameters
buildingthe structure the worker hails from
currentPointthe current position of the worker
workerthe type of worker(mason, carpenter, ...)
storagethe storage the worker has available to carry supply to its workplace
maxDistancemaximum distance to workplace
pathTypethe type of pathing the worker uses to get around
pathTagadditional parameter for pathfinding
Returns
if found, a workplace and a path to get there(possibly a path to some items the worker needs to pick up beforehand)

Implements CityBuilderCore.IWorkplaceFinder.

◆ GetWorkerPathQuery()

WorkerPathQuery CityBuilderCore.DefaultPopulationManager.GetWorkerPathQuery ( IBuilding building,
Vector2Int? currentPoint,
Worker worker,
ItemStorage storage,
float maxDistance,
PathType pathType,
object pathTag )
inline

attempts to find a worker path for a worker

Parameters
buildingthe structure the worker hails from
currentPointthe current position of the worker
workerthe type of worker(mason, carpenter, ...)
storagethe storage the worker has available to carry supply to its workplace
maxDistancemaximum distance to workplace
pathTypethe type of pathing the worker uses to get around
pathTagadditional parameter for pathfinding
Returns
a query that on completion may return, if found, a workplace and a path to get there(possibly a path to some items the worker needs to pick up beforehand)

Implements CityBuilderCore.IWorkplaceFinder.

◆ GetWorkerRate()

float CityBuilderCore.DefaultPopulationManager.GetWorkerRate ( Population population)
inline

calculates worker rate for population(available/needed) 100 jobs for 200 employees > 2.0
300 jobs for 150 employees > 0.5

Parameters
populationthe populatio to check
Returns
worker rate(below 1 when more jobs than people)

Implements CityBuilderCore.IEmploymentManager.

◆ RemoveEmployment()

void CityBuilderCore.DefaultPopulationManager.RemoveEmployment ( IEmployment employment)
inline

removes an employment that was previously added to the manager, the employment will no longer have any employees assigned
typically called in OnDestroy

Parameters
employmentthe employment that will no longer be managed here

Implements CityBuilderCore.IEmploymentManager.

◆ SetPriority()

void CityBuilderCore.DefaultPopulationManager.SetPriority ( EmploymentGroup group,
int priority )
inline

changes the priority of an employment group
this changes which employment groups employees are distributed to first

Parameters
group
priority

Implements CityBuilderCore.IEmploymentManager.