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

Detailed Description

default building component for handling evolution

determines the current evolution stage inside its sequence based on layers, services and items
if the stage changes it waits for the delay specified in IBuildingManager before replacing the building
evolution components on lower buildings also need the recipients for higher ones in order to evolve

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

Inheritance diagram for CityBuilderCore.EvolutionComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IEvolution CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingComponent CityBuilderCore.IItemRecipient CityBuilderCore.IServiceRecipient CityBuilderCore.ILayerDependency CityBuilderCore.ISaveData CityBuilderCore.ISaveData CityBuilderCore.IBuildingComponent CityBuilderCore.IItemOwner CityBuilderCore.IBuildingComponent CityBuilderCore.ISaveData CityBuilderCore.ISaveData

Classes

class  EvolutionData
 

Public Member Functions

override void OnReplacing (IBuilding replacement)
 called when a component gets replaced
use to transfer resources, replace references
 
void CheckLayers (IEnumerable< Vector2Int > positions)
 gets called when
 
void CheckEvolution ()
 manually check if the evolution has changed in case any circumstances outside the components control have changed
 
bool HasServiceValue (Service service)
 whether the recipient handles a particular serviec
for example a bar visualization should not be created on a building that does not even have the service that is visualized
 
float GetServiceValue (Service service)
 check how much service value is left in the recipient
 
void ModifyService (Service service, float amount)
 changes a services value in the recipient
services have to be increased regularly or access will be lost
 
IEnumerable< ServiceGetAccessibleServices ()
 
IEnumerable< ItemGetAccessibleItems ()
 
IEnumerable< ItemGetRecipientItems ()
 use this to check which items the recipient needs
 
IEnumerable< ItemQuantityGetRecipientItemQuantities ()
 checks how much of every needed item the recipient currently has
 
void FillRecipient (ItemStorage itemStorage)
 passes a storage to the recipient which will take any item from it that it needs
 
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 InitializeComponent ()
 initialization is performed when the building is placed or loaded
use to create references, register traits, ...
 
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 GetDebugText ()
 returns text that gets displayed for debugging in the scene editor
 

Public Attributes

EvolutionSequence EvolutionSequence
 
ServiceRecipient[] ServiceRecipients
 
ServiceCategoryRecipient[] ServiceCategoryRecipients
 
ItemRecipient[] ItemsRecipients
 
ItemCategoryRecipient[] ItemsCategoryRecipients
 

Properties

override string Key [get]
 unique key used to identify the component in save/load
 
IItemContainer ItemContainer [get]
 holds and manages the items for the owner
 
- 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.IItemOwner

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

◆ CheckEvolution()

void CityBuilderCore.EvolutionComponent.CheckEvolution ( )
inline

manually check if the evolution has changed in case any circumstances outside the components control have changed

Implements CityBuilderCore.IEvolution.

◆ CheckLayers()

void CityBuilderCore.EvolutionComponent.CheckLayers ( IEnumerable< Vector2Int > points)

gets called when

Parameters
points

Implements CityBuilderCore.ILayerDependency.

◆ FillRecipient()

void CityBuilderCore.EvolutionComponent.FillRecipient ( ItemStorage itemStorage)
inline

passes a storage to the recipient which will take any item from it that it needs

Parameters
itemStoragethe storage the recipient will take from

Implements CityBuilderCore.IItemRecipient.

◆ GetDescription()

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

◆ GetRecipientItemQuantities()

IEnumerable< ItemQuantity > CityBuilderCore.EvolutionComponent.GetRecipientItemQuantities ( )

checks how much of every needed item the recipient currently has

Returns
current item quantities the recipient has

Implements CityBuilderCore.IItemRecipient.

◆ GetRecipientItems()

IEnumerable< Item > CityBuilderCore.EvolutionComponent.GetRecipientItems ( )
inline

use this to check which items the recipient needs

Returns
items the recipient needs

Implements CityBuilderCore.IItemRecipient.

◆ GetServiceValue()

float CityBuilderCore.EvolutionComponent.GetServiceValue ( Service service)
inline

check how much service value is left in the recipient

Parameters
servicethe service for which we want the value
Returns
value in percent of much is left before service access is lost

Implements CityBuilderCore.IServiceRecipient.

◆ HasServiceValue()

bool CityBuilderCore.EvolutionComponent.HasServiceValue ( Service service)

whether the recipient handles a particular serviec
for example a bar visualization should not be created on a building that does not even have the service that is visualized

Parameters
servicethe service to check
Returns
true if the service is present in the recipient

Implements CityBuilderCore.IServiceRecipient.

◆ LoadData()

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

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

Parameters
json

Reimplemented from CityBuilderCore.BuildingComponent.

◆ ModifyService()

void CityBuilderCore.EvolutionComponent.ModifyService ( Service service,
float amount )
inline

changes a services value in the recipient
services have to be increased regularly or access will be lost

Parameters
servicethe service that will have its value changed
amountpositive to refill the service, negative to bring down closer to losing access

Implements CityBuilderCore.IServiceRecipient.

◆ OnReplacing()

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

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

Parameters
replacement

Reimplemented from CityBuilderCore.BuildingComponent.

◆ SaveData()

override string CityBuilderCore.EvolutionComponent.SaveData ( )
inlinevirtual

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

Returns
serialized save data

Reimplemented from CityBuilderCore.BuildingComponent.

Property Documentation

◆ ItemContainer

IItemContainer CityBuilderCore.EvolutionComponent.ItemContainer
get

holds and manages the items for the owner

Implements CityBuilderCore.IItemOwner.

◆ Key

override string CityBuilderCore.EvolutionComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.