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

Detailed Description

building component using workers for a set duration to influence building efficiency(to drive production, layervalues, ...)

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

Inheritance diagram for CityBuilderCore.WorkerUserComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IWorkerUser CityBuilderCore.IEfficiencyFactor CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingTrait< IWorkerUser > CityBuilderCore.ISaveData

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
 
float GetWorkerNeed (Worker worker)
 how much the user needs a worker, makes sure users who already have a worker on site have lower priority
 
ItemQuantity GetItemsNeeded (Worker walker)
 gets the items a worker has to bring if any
 
void ReportAssigned (WorkerWalker walker)
 worker has been assigned to the user and will start walking there
 
Vector3[] ReportArrived (WorkerWalker walker)
 worker has arrived at the user and receives his path into the user(optional)
 
void ReportInside (WorkerWalker walker)
 if a path inside was returned on arrival the worker will report inside after following that path
 
IEnumerable< WorkerGetAssigned ()
 gets which workers are assigned but have not arrived at the user
does not contain empty entries like queued and working
 
IEnumerable< WorkerGetWorking ()
 gets the worker slots in its entire length, null for unfilled slots
 
IEnumerable< WorkerGetQueued ()
 gets the queue slots in its entire length, null for unfilled slots
 
- 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 SuspendComponent ()
 temporarily stops the component from working
 
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
 
virtual string GetDescription ()
 gets displayed in dialogs to show the component status to players
 
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

Worker Worker
 
int Quantity
 
int Queue
 
float Duration
 
BoolEvent IsWorkingChanged
 

Properties

override string Key [get]
 unique key used to identify the component in save/load
 
BuildingComponentReference< IWorkerUserReference [get, set]
 
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.IBuildingTrait< IWorkerUser >
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

◆ GetAssigned()

IEnumerable< Worker > CityBuilderCore.WorkerUserComponent.GetAssigned ( )
inline

gets which workers are assigned but have not arrived at the user
does not contain empty entries like queued and working

Returns

Implements CityBuilderCore.IWorkerUser.

◆ GetItemsNeeded()

ItemQuantity CityBuilderCore.WorkerUserComponent.GetItemsNeeded ( Worker worker)

gets the items a worker has to bring if any

Parameters
worker
Returns

Implements CityBuilderCore.IWorkerUser.

◆ GetQueued()

IEnumerable< Worker > CityBuilderCore.WorkerUserComponent.GetQueued ( )
inline

gets the queue slots in its entire length, null for unfilled slots

Returns

Implements CityBuilderCore.IWorkerUser.

◆ GetWorkerNeed()

float CityBuilderCore.WorkerUserComponent.GetWorkerNeed ( Worker worker)
inline

how much the user needs a worker, makes sure users who already have a worker on site have lower priority

Parameters
worker
Returns

Implements CityBuilderCore.IWorkerUser.

◆ GetWorking()

IEnumerable< Worker > CityBuilderCore.WorkerUserComponent.GetWorking ( )
inline

gets the worker slots in its entire length, null for unfilled slots

Returns

Implements CityBuilderCore.IWorkerUser.

◆ InitializeComponent()

override void CityBuilderCore.WorkerUserComponent.InitializeComponent ( )
inlinevirtual

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

Reimplemented from CityBuilderCore.BuildingComponent.

◆ OnReplacing()

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

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

Parameters
replacement

Reimplemented from CityBuilderCore.BuildingComponent.

◆ ReportArrived()

Vector3[] CityBuilderCore.WorkerUserComponent.ReportArrived ( WorkerWalker walker)
inline

worker has arrived at the user and receives his path into the user(optional)

Parameters
walker
Returns

Implements CityBuilderCore.IWorkerUser.

◆ ReportAssigned()

void CityBuilderCore.WorkerUserComponent.ReportAssigned ( WorkerWalker walker)
inline

worker has been assigned to the user and will start walking there

Parameters
walker

Implements CityBuilderCore.IWorkerUser.

◆ ReportInside()

void CityBuilderCore.WorkerUserComponent.ReportInside ( WorkerWalker walker)
inline

if a path inside was returned on arrival the worker will report inside after following that path

Parameters
walker

Implements CityBuilderCore.IWorkerUser.

◆ TerminateComponent()

override void CityBuilderCore.WorkerUserComponent.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.WorkerUserComponent.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.WorkerUserComponent.IsWorking
get

false disrupts the building

Implements CityBuilderCore.IEfficiencyFactor.

◆ Key

override string CityBuilderCore.WorkerUserComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.