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

Detailed Description

prodvides housing for the population, influences efficiency by its occuption(efficiency could be used for tax generation for example)

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

Inheritance diagram for CityBuilderCore.HousingComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IHousing CityBuilderCore.IEfficiencyFactor CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingTrait< IHousing > CityBuilderCore.ISaveData

Classes

class  HousingData
 

Public Member Functions

override void InitializeComponent ()
 initialization is performed when the building is placed or loaded
use to create references, register traits, ...
 
override void OnReplacing (IBuilding replacement)
 called when a component gets replaced
use to transfer resources, replace references
 
override void TerminateComponent ()
 termination is performed when the building is destroyed
use to deregister traits, remove references from other systems
 
override void SuspendComponent ()
 temporarily stops the component from working
 
int GetQuantity (Population population, bool includeReserved=false)
 checks how many people of a population are housed in the component
 
int GetCapacity (Population population)
 checks how many people of a population can be housed in the component
 
int GetRemainingCapacity (Population population)
 checks how many more people of the population would fit in the housing
 
int Reserve (Population population, int quantity)
 reserves space in the housing for inhabitants that are walking to it
this is done to make sure there is still place when they arrive
otherwise all immigrants in THREE would walk to the same housing until the first one arrives
 
int Inhabit (Population population, int quantity)
 removes reserved quantity and adds it to the housing
 
int Abandon (Population population, int quantity)
 removes a quantity of population from the housing
 
void Kill (float ratio)
 removes a portion of the housed quantities across populations
 
override string GetDescription ()
 gets displayed in dialogs to show the component status to players
 
override string SaveData ()
 serializes the objects state(usually to json) and returns it
 
override void LoadData (string json)
 deserializes the serialized json data and loads the data as its new state
 
- Public Member Functions inherited from CityBuilderCore.BuildingComponent
virtual void SetupComponent ()
 only called when the building is originally placed, before Initialize
 
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 ResumeComponent ()
 resumes work in the component after SuspendComponent has been called
 
virtual string GetDebugText ()
 returns text that gets displayed for debugging in the scene editor
 

Public Attributes

PopulationHousing[] PopulationHousings
 

Properties

override string Key [get]
 unique key used to identify the component in save/load
 
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
 
BuildingComponentReference< IHousingReference [get, set]
 
- 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.IBuildingTrait< IHousing >
BuildingComponentReference< T > Reference [get, set]
 reference to the building trait, use when the building might be replaced and when the reference has to be saved
 
- 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

◆ Abandon()

int CityBuilderCore.HousingComponent.Abandon ( Population population,
int quantity )

removes a quantity of population from the housing

Parameters
populationpopulation to remove
quantityquantity to remove
Returns
remaining quantity that was not there in the first place

Implements CityBuilderCore.IHousing.

◆ GetCapacity()

int CityBuilderCore.HousingComponent.GetCapacity ( Population population)
inline

checks how many people of a population can be housed in the component

Parameters
populationthe population to check
Returns
total quantity that will fit

Implements CityBuilderCore.IHousing.

◆ GetDescription()

override string CityBuilderCore.HousingComponent.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.

◆ GetQuantity()

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

checks how many people of a population are housed in the component

Parameters
populationthe population to check
includeReservedwhether inhabitants that have not arrived at the housing should be counted
Returns
population count in this housíng

Implements CityBuilderCore.IHousing.

◆ GetRemainingCapacity()

int CityBuilderCore.HousingComponent.GetRemainingCapacity ( Population population)
inline

checks how many more people of the population would fit in the housing

Parameters
populationthe relevant population
Returns
quantity that will still fit(capacity-quantity-reserved)

Implements CityBuilderCore.IHousing.

◆ Inhabit()

int CityBuilderCore.HousingComponent.Inhabit ( Population population,
int quantity )

removes reserved quantity and adds it to the housing

Parameters
populationpopulation to add
quantityquantity to add
Returns
remaining quantity that would have exceeded capacity

Implements CityBuilderCore.IHousing.

◆ InitializeComponent()

override void CityBuilderCore.HousingComponent.InitializeComponent ( )
inlinevirtual

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

Reimplemented from CityBuilderCore.BuildingComponent.

◆ Kill()

void CityBuilderCore.HousingComponent.Kill ( float ratio)

removes a portion of the housed quantities across populations

Parameters
ratio0-1

Implements CityBuilderCore.IHousing.

◆ LoadData()

override void CityBuilderCore.HousingComponent.LoadData ( string json)
inlinevirtual

deserializes the serialized json data and loads the data as its new state

Parameters
json

Reimplemented from CityBuilderCore.BuildingComponent.

◆ OnReplacing()

override void CityBuilderCore.HousingComponent.OnReplacing ( IBuilding replacement)
inlinevirtual

called when a component gets replaced
use to transfer resources, replace references

Parameters
replacement

Reimplemented from CityBuilderCore.BuildingComponent.

◆ Reserve()

int CityBuilderCore.HousingComponent.Reserve ( Population population,
int quantity )

reserves space in the housing for inhabitants that are walking to it
this is done to make sure there is still place when they arrive
otherwise all immigrants in THREE would walk to the same housing until the first one arrives

Parameters
populationthe population to reserve
quantityhow many to reserve
Returns
remaining quantity that would have exceeded capacity

Implements CityBuilderCore.IHousing.

◆ SaveData()

override string CityBuilderCore.HousingComponent.SaveData ( )
inlinevirtual

serializes the objects state(usually to json) and returns it

Returns
serialized save data

Reimplemented from CityBuilderCore.BuildingComponent.

◆ SuspendComponent()

override void CityBuilderCore.HousingComponent.SuspendComponent ( )
inlinevirtual

temporarily stops the component from working

Reimplemented from CityBuilderCore.BuildingComponent.

◆ TerminateComponent()

override void CityBuilderCore.HousingComponent.TerminateComponent ( )
inlinevirtual

termination is performed when the building is destroyed
use to deregister traits, remove references from other systems

Reimplemented from CityBuilderCore.BuildingComponent.

Property Documentation

◆ Factor

float CityBuilderCore.HousingComponent.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.

◆ IsWorking

bool CityBuilderCore.HousingComponent.IsWorking
get

false disrupts the building

Implements CityBuilderCore.IEfficiencyFactor.

◆ Key

override string CityBuilderCore.HousingComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.