Loading...
Searching...
No Matches
CityBuilderTown.TownWorkComponent Class Reference

Detailed Description

building component that uses TownWorkTasks to drive the buildings efficiency
the work tasks are only active when the buildings IsWorking is true
this is used in TownProductionComponent to only activate work when raw materials are present

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

Inheritance diagram for CityBuilderTown.TownWorkComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IEfficiencyFactor CityBuilderCore.IBuildingComponent CityBuilderCore.ISaveData

Classes

class  TownWorkData
 

Public Member Functions

override void InitializeComponent ()
 initialization is performed when the building is placed or loaded
use to create references, register traits, ...
 
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
 
override void ResumeComponent ()
 resumes work in the component after SuspendComponent has been called
 
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 OnReplacing (IBuilding replacement)
 called when a component gets replaced
use to transfer resources, replace references
 
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 string GetDebugText ()
 returns text that gets displayed for debugging in the scene editor
 
virtual string GetDescription ()
 gets displayed in dialogs to show the component status to players
 

Public Attributes

TownWorkTask[] WorkTasks
 

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
 
- 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.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

◆ InitializeComponent()

override void CityBuilderTown.TownWorkComponent.InitializeComponent ( )
inlinevirtual

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

Reimplemented from CityBuilderCore.BuildingComponent.

◆ LoadData()

override void CityBuilderTown.TownWorkComponent.LoadData ( string json)
inlinevirtual

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

Parameters
json

Reimplemented from CityBuilderCore.BuildingComponent.

◆ ResumeComponent()

override void CityBuilderTown.TownWorkComponent.ResumeComponent ( )
inlinevirtual

resumes work in the component after SuspendComponent has been called

Reimplemented from CityBuilderCore.BuildingComponent.

◆ SaveData()

override string CityBuilderTown.TownWorkComponent.SaveData ( )
inlinevirtual

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

Returns
serialized save data

Reimplemented from CityBuilderCore.BuildingComponent.

◆ SuspendComponent()

override void CityBuilderTown.TownWorkComponent.SuspendComponent ( )
inlinevirtual

temporarily stops the component from working

Reimplemented from CityBuilderCore.BuildingComponent.

◆ TerminateComponent()

override void CityBuilderTown.TownWorkComponent.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 CityBuilderTown.TownWorkComponent.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 CityBuilderTown.TownWorkComponent.IsWorking
get

false disrupts the building

Implements CityBuilderCore.IEfficiencyFactor.

◆ Key

override string CityBuilderTown.TownWorkComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.