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

Detailed Description

produces items using specified raw materials and places them in specified points
used in combination with TownWorkComponent for the woodcutter
the production component sets IsWorking when all the raw materials have arrived
when IsWorking is true the work component activates its work tasks which drive efficiency
production is dependent on efficiency so progress is only made when walkers are working

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

Inheritance diagram for CityBuilderTown.TownProductionComponent:
CityBuilderCore.ProductionComponent CityBuilderCore.IEfficiencyFactor CityBuilderCore.ProgressComponent CityBuilderCore.IProductionComponent CityBuilderCore.BuildingComponent CityBuilderCore.IProgressComponent CityBuilderCore.IProgressComponent CityBuilderCore.IItemReceiver CityBuilderCore.IItemOwner CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingTrait< IItemReceiver > CityBuilderCore.IItemOwner CityBuilderCore.ISaveData CityBuilderCore.ISaveData CityBuilderCore.ISaveData

Classes

class  TownProductionData
 

Public Member Functions

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.ProductionComponent
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
 
IEnumerable< ItemGetReceiveItems ()
 returns the kinds of items the receiver needs
 
int GetReceiveCapacity (Item item)
 how much of the item the receiver can still fit
 
void ReserveCapacity (Item item, int amount)
 reserves a capacity in the receiver so it is not filled up by someone else
 
void UnreserveCapacity (Item item, int amount)
 releases capacity that was earlier reserved by ReserveCapacity(Item, int)
call before actually moving items into the receiver or if the delivery was somehow interrupted
 
int Receive (ItemStorage storage, Item item, int quantity)
 requests that a quantity of items is moved from the storage to the receiver
if the full amount does not fit the remaining quantity is returned
 
IEnumerable< ItemLevelGetNeededItems ()
 exposes the items the production component needs to work
 
IEnumerable< ItemLevelGetProducedItems ()
 exposes the items the component can produce
 
- Public Member Functions inherited from CityBuilderCore.ProgressComponent
override string GetDebugText ()
 returns text that gets displayed for debugging in the scene editor
 
override void InitializeComponent ()
 initialization is performed when the building is placed or loaded
use to create references, register traits, ...
 
- 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 string GetDescription ()
 gets displayed in dialogs to show the component status to players
 

Public Attributes

TownDeliverTask DeliverTask
 
Vector2Int[] ItemPoints
 
TownItemTask ItemPrefab
 
- Public Attributes inherited from CityBuilderCore.ProductionComponent
ItemConsumer[] ItemsConsumers
 
ItemProducer[] ItemsProducers
 
BoolEvent HasRawMaterialsChanged
 
BoolEvent HasProductsChanged
 
- Public Attributes inherited from CityBuilderCore.ProgressComponent
float ProgressInterval
 
BoolEvent IsProgressing
 

Protected Member Functions

override bool canWork ()
 
override bool canProduce ()
 
override void produce ()
 
- Protected Member Functions inherited from CityBuilderCore.ProductionComponent
virtual void Awake ()
 
virtual void Start ()
 
virtual void Update ()
 
virtual void updateProduction ()
 
virtual void setState (ProductionState productionState)
 
virtual void onProduced (ItemProducer itemProducer)
 
ItemConsumer getConsumer (Item item)
 
ItemProducer getProducer (Item item)
 
virtual void onItemsChanged ()
 
void saveData (ProductionData data)
 
void loadData (ProductionData data)
 
- Protected Member Functions inherited from CityBuilderCore.ProgressComponent
bool addProgress (float multiplier)
 
void resetProgress ()
 
- 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
 

Properties

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.ProductionComponent
override string Key [get]
 unique key used to identify the component in save/load
 
int Priority [get]
 can be used so certain receivers are preferred over others
for example construction sites or production may be more important that putting items into storage
 
ItemConsumer[] Consumers [get]
 
ItemProducer[] Producers [get]
 
BuildingComponentReference< IItemReceiverReference [get, set]
 
IItemContainer ItemContainer [get]
 holds and manages the items for the owner
 
virtual bool HasRawMaterials [get]
 
virtual bool HasProducts [get]
 
ProductionState CurrentProductionState [get]
 
- Properties inherited from CityBuilderCore.ProgressComponent
float Progress [get]
 progress from 0 to 1
 
- 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.IProgressComponent
- Properties inherited from CityBuilderCore.IItemReceiver
- Properties inherited from CityBuilderCore.IBuildingTrait< IItemReceiver >
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.IItemOwner
- Properties inherited from CityBuilderCore.IEfficiencyFactor

Additional Inherited Members

- Public Types inherited from CityBuilderCore.ProductionComponent
enum  ProductionState { Idle = 0 , Working = 10 , Done = 20 }
 
- Protected Attributes inherited from CityBuilderCore.ProductionComponent
bool _isProgressing
 
ProductionState _productionState
 
- Protected Attributes inherited from CityBuilderCore.ProgressComponent
float _progressTime
 
- Events inherited from CityBuilderCore.ProgressComponent
Action ProgressReset
 
Action< float > ProgressChanged
 
- Events inherited from CityBuilderCore.IProgressComponent
Action ProgressReset
 progress has finished and is reset to 0
 
Action< float > ProgressChanged
 progress has changed, carries new progress
 

Member Function Documentation

◆ canProduce()

override bool CityBuilderTown.TownProductionComponent.canProduce ( )
inlineprotectedvirtual

◆ canWork()

override bool CityBuilderTown.TownProductionComponent.canWork ( )
inlineprotectedvirtual

◆ LoadData()

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

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

Parameters
json

Reimplemented from CityBuilderCore.ProductionComponent.

◆ produce()

override void CityBuilderTown.TownProductionComponent.produce ( )
inlineprotectedvirtual

◆ ResumeComponent()

override void CityBuilderTown.TownProductionComponent.ResumeComponent ( )
inlinevirtual

resumes work in the component after SuspendComponent has been called

Reimplemented from CityBuilderCore.BuildingComponent.

◆ SaveData()

override string CityBuilderTown.TownProductionComponent.SaveData ( )
inlinevirtual

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

Returns
serialized save data

Reimplemented from CityBuilderCore.ProductionComponent.

◆ SuspendComponent()

override void CityBuilderTown.TownProductionComponent.SuspendComponent ( )
inlinevirtual

temporarily stops the component from working

Reimplemented from CityBuilderCore.BuildingComponent.

◆ TerminateComponent()

override void CityBuilderTown.TownProductionComponent.TerminateComponent ( )
inlinevirtual

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

Reimplemented from CityBuilderCore.ProductionComponent.

Property Documentation

◆ Factor

float CityBuilderTown.TownProductionComponent.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.TownProductionComponent.IsWorking
get

false disrupts the building

Implements CityBuilderCore.IEfficiencyFactor.