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

Detailed Description

building component that uses employees to influence the buildings efficiency
for example in THREE most buildings employ workers
how fast mines and farms create items and whether storage works is bound to employment

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

Inheritance diagram for CityBuilderCore.EmploymentComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IEmployment CityBuilderCore.IEfficiencyFactor CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingComponent CityBuilderCore.ISaveData CityBuilderCore.ISaveData CityBuilderCore.EmploymentWalkerComponent

Public Member Functions

override void InitializeComponent ()
 initialization is performed when the building is placed or loaded
use to create references, register traits, ...
 
int GetNeeded (EmploymentGroup employmentGroup, Population population)
 check how many workers of a population the component needs for a certain employment group
 
virtual int AssignAvailable (EmploymentGroup employmentGroup, Population population, int quantity)
 assigns the quantity needed and returns the rest
 
IEnumerable< EmploymentGroupGetEmploymentGroups ()
 returns which employment groups the employer needs
 
IEnumerable< PopulationGetPopulations ()
 returns which populations this component uses
 
override string GetDebugText ()
 returns text that gets displayed for debugging in the scene editor
 
override string GetDescription ()
 gets displayed in dialogs to show the component status to players
 
- Public Member Functions inherited from CityBuilderCore.BuildingComponent
virtual void SetupComponent ()
 only called when the building is originally placed, before Initialize
 
virtual void OnReplacing (IBuilding replacement)
 called when a component gets replaced
use to transfer resources, replace references
 
virtual void TerminateComponent ()
 termination is performed when the building is destroyed
use to deregister traits, remove references from other systems
 
virtual void OnMoving ()
 called when the building is about to be moved
can be used to remove/deregister stuff from the old position
 
virtual void OnMoved (Vector2Int oldPoint, BuildingRotation oldRotation)
 called after a building has been moved
can be used to register things at the new position
 
virtual void SuspendComponent ()
 temporarily stops the component from working
 
virtual void ResumeComponent ()
 resumes work in the component after SuspendComponent has been called
 
virtual string SaveData ()
 serializes the objects state(usually to json) and returns it
 
virtual void LoadData (string json)
 deserializes the serialized json data and loads the data as its new state
 

Public Attributes

PopulationEmployment[] PopulationEmployments
 
BoolEvent IsFullyStaffedChanged
 

Properties

override string Key [get]
 unique key used to identify the component in save/load
 
bool IsFullyStaffed [get]
 all needed employees are assigned
 
float EmploymentRate [get]
 the rate of employees assigned from 0 to 1
 
bool IsWorking [get]
 false disrupts the building
 
float Factor [get]
 how efficiency is changed by this component(0-1), a buildings efficiency is calculated by multiplying all of its efficiency factors
 
- Properties inherited from CityBuilderCore.BuildingComponent
string Key [get]
 unique key used to identify the component in save/load
 
IBuilding Building [get, set]
 the building the component is attached to
is set by the building in awake
 
- Properties inherited from CityBuilderCore.IBuildingComponent
- Properties inherited from CityBuilderCore.IEmployment
- Properties inherited from CityBuilderCore.IEfficiencyFactor

Additional Inherited Members

- Protected Member Functions inherited from CityBuilderCore.BuildingComponent
getOther< T > ()
 gets the first building component of the specified type on the same building
 
IEnumerable< T > getOthers< T > ()
 gets all building components of the specified type on the same building
 
BuildingComponentReference< T > registerTrait< T > (T trait)
 registers the building component as a trait so it is globally accessible
usually done in InitializeComponent
 
void replaceTrait< T > (T trait, T replacement)
 replaces the reference a trait points to in the global manager
done when a building is replaced(OnReplacing(IBuilding)) so the trait now points to the new component instead of the one that has been removed
 
void deregisterTrait< T > (T trait)
 removes a previously registered trait
usually when a building is removed which calls TerminateComponent
 

Member Function Documentation

◆ AssignAvailable()

virtual int CityBuilderCore.EmploymentComponent.AssignAvailable ( EmploymentGroup employmentGroup,
Population population,
int quantity )
inlinevirtual

assigns the quantity needed and returns the rest

Parameters
employmentGroup
population
quantity
Returns
workers count remaining

Implements CityBuilderCore.IEmployment.

Reimplemented in CityBuilderCore.EmploymentWalkerComponent.

◆ GetDebugText()

override string CityBuilderCore.EmploymentComponent.GetDebugText ( )
virtual

returns text that gets displayed for debugging in the scene editor

Returns
a debugging string or null

Reimplemented from CityBuilderCore.BuildingComponent.

◆ GetDescription()

override string CityBuilderCore.EmploymentComponent.GetDescription ( )
inlinevirtual

gets displayed in dialogs to show the component status to players

Returns
a descriptive string or an empty one

Reimplemented from CityBuilderCore.BuildingComponent.

◆ GetEmploymentGroups()

IEnumerable< EmploymentGroup > CityBuilderCore.EmploymentComponent.GetEmploymentGroups ( )

returns which employment groups the employer needs

Returns
the employment groups used by this component

Implements CityBuilderCore.IEmployment.

◆ GetNeeded()

int CityBuilderCore.EmploymentComponent.GetNeeded ( EmploymentGroup employmentGroup,
Population population )
inline

check how many workers of a population the component needs for a certain employment group

Parameters
employmentGroupthe group to check
populationthe relevant population
Returns
how many workers are needed in total

Implements CityBuilderCore.IEmployment.

◆ GetPopulations()

IEnumerable< Population > CityBuilderCore.EmploymentComponent.GetPopulations ( )

returns which populations this component uses

Returns
the populations this component uses

Implements CityBuilderCore.IEmployment.

◆ InitializeComponent()

override void CityBuilderCore.EmploymentComponent.InitializeComponent ( )
inlinevirtual

initialization is performed when the building is placed or loaded
use to create references, register traits, ...

Reimplemented from CityBuilderCore.BuildingComponent.

Property Documentation

◆ EmploymentRate

float CityBuilderCore.EmploymentComponent.EmploymentRate
get

the rate of employees assigned from 0 to 1

Implements CityBuilderCore.IEmployment.

◆ Factor

float CityBuilderCore.EmploymentComponent.Factor
get

how efficiency is changed by this component(0-1), a buildings efficiency is calculated by multiplying all of its efficiency factors

Implements CityBuilderCore.IEfficiencyFactor.

◆ IsFullyStaffed

bool CityBuilderCore.EmploymentComponent.IsFullyStaffed
get

all needed employees are assigned

Implements CityBuilderCore.IEmployment.

◆ IsWorking

bool CityBuilderCore.EmploymentComponent.IsWorking
get

false disrupts the building

Implements CityBuilderCore.IEfficiencyFactor.

◆ Key

override string CityBuilderCore.EmploymentComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.