Loading...
Searching...
No Matches
CityBuilderCore.BuildingAddon Class Referenceabstract

Detailed Description

temporary building parts that are added(Building.AddAddon<T>(T)) and removed(Building.RemoveAddon(BuildingAddon)) at runtime and carry over when a building is replaced
can be used for effects, statuses, animations, ...

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

Inheritance diagram for CityBuilderCore.BuildingAddon:
CityBuilderCore.KeyedBehaviour CityBuilderCore.ISaveData CityBuilderCore.IKeyed CityBuilderCore.BuildingAddonEffect CityBuilderCore.BuildingAddonMaterial CityBuilderCore.BuildingAddonSpawn CityBuilderCore.BuildingAddonTransformer CityBuilderCore.DiseaseAddon CityBuilderCore.FireAddon

Public Types

enum  AddonAccumulationMode { Stack , Queue , Replace , Single }
 specifies how the addon behaves when there is more than one at the same time More...
 

Public Member Functions

virtual void Awake ()
 
virtual void Start ()
 
virtual void Update ()
 
void Remove ()
 Removes the addon from the Building it is located on
this will usually result in the termination of the addon.
 
virtual void InitializeAddon ()
 called by the Building after the addon has been instantiated and Building has been set
 
virtual void TerminateAddon ()
 called by the Building when the addon gets removed
this should usually terminate the addon(mark as terminated and Destroy)
 
virtual void OnReplacing (Transform parent, IBuilding replacement)
 called be the addons building when the building gets replaced
this has to move the addon over to the new building
otherwise it will be destroyed with the old one
 
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

AddonAccumulationMode Accumulation
 
bool Save
 
bool Center
 
bool Scale
 
- Public Attributes inherited from CityBuilderCore.KeyedBehaviour
string Key
 

Protected Attributes

bool _isTerminated
 

Properties

IBuilding Building [get, set]
 
- Properties inherited from CityBuilderCore.IKeyed

Member Enumeration Documentation

◆ AddonAccumulationMode

specifies how the addon behaves when there is more than one at the same time

Enumerator
Stack 

every addon is instantiated, walker can have any number of addons at the same time

Queue 

additional addons are stored in a queue, when the addon is removed the queue is reduced instead

Replace 

when a second addon is added the first one gets removed

Single 

when a second addin is added nothing happens

Member Function Documentation

◆ InitializeAddon()

virtual void CityBuilderCore.BuildingAddon.InitializeAddon ( )
inlinevirtual

◆ LoadData()

virtual void CityBuilderCore.BuildingAddon.LoadData ( string json)
inlinevirtual

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

Parameters
json

Implements CityBuilderCore.ISaveData.

Reimplemented in CityBuilderCore.DiseaseAddon, and CityBuilderCore.FireAddon.

◆ OnReplacing()

virtual void CityBuilderCore.BuildingAddon.OnReplacing ( Transform parent,
IBuilding replacement )
inlinevirtual

called be the addons building when the building gets replaced
this has to move the addon over to the new building
otherwise it will be destroyed with the old one

Parameters
parent
replacement

Reimplemented in CityBuilderCore.BuildingAddonEffect, and CityBuilderCore.DiseaseAddon.

◆ SaveData()

virtual string CityBuilderCore.BuildingAddon.SaveData ( )
virtual

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

Returns
serialized save data

Implements CityBuilderCore.ISaveData.

Reimplemented in CityBuilderCore.DiseaseAddon, and CityBuilderCore.FireAddon.

◆ TerminateAddon()

virtual void CityBuilderCore.BuildingAddon.TerminateAddon ( )
inlinevirtual

called by the Building when the addon gets removed
this should usually terminate the addon(mark as terminated and Destroy)

Reimplemented in CityBuilderCore.BuildingAddonMaterial, CityBuilderCore.BuildingAddonSpawn, CityBuilderCore.BuildingAddonTransformer, and CityBuilderCore.DiseaseAddon.