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

Detailed Description

base class for building components implementing IBuildingComponent

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

Inheritance diagram for CityBuilderCore.BuildingComponent:
CityBuilderCore.IBuildingComponent CityBuilderCore.ISaveData CityBuilderCore.AttackableComponent CityBuilderCore.CollectionComponent CityBuilderCore.ConnectionFeederComponent CityBuilderCore.ConnectionPasserComponent CityBuilderCore.CyclicWorkerProviderComponent CityBuilderCore.DefenderAreaComponent CityBuilderCore.DefenderComponent CityBuilderCore.DistributionComponent CityBuilderCore.EmploymentComponent CityBuilderCore.EvolutionComponent CityBuilderCore.HousingComponent CityBuilderCore.HousingPlaceholderComponent CityBuilderCore.ItemEfficiencyComponent CityBuilderCore.ItemsRetrieverComponent CityBuilderCore.LayerEfficiencyComponent CityBuilderCore.MonumentSiteComponent CityBuilderCore.PooledWorkerProviderComponent CityBuilderCore.ProgressComponent CityBuilderCore.RiskWalkerComponent CityBuilderCore.RiskerComponent CityBuilderCore.RoadBlockerComponent CityBuilderCore.RoadSwitcherComponent CityBuilderCore.ScoreEfficiencyComponent CityBuilderCore.ServiceEfficiencyComponent CityBuilderCore.ServiceWalkerComponent CityBuilderCore.SpriteRandomizerComponent CityBuilderCore.StorageComponent CityBuilderCore.Tests.DebugNoEfficiencyComponent CityBuilderCore.TimedReplacementComponent CityBuilderCore.VariantProductionComponent CityBuilderCore.WalkerComponent CityBuilderCore.WorkerUserComponent CityBuilderManual.Custom.CustomBuildingComponent CityBuilderManual.Custom.CustomBuildingTrait CityBuilderTown.ItemConstructionComponent CityBuilderTown.TownConstructionComponent CityBuilderTown.TownFarmingComponent CityBuilderTown.TownForestingComponent CityBuilderTown.TownGatheringComponent CityBuilderTown.TownHomeComponent CityBuilderTown.TownMarketComponent CityBuilderTown.TownWorkComponent CityBuilderUrban.HouseComponent CityBuilderUrban.RailwayComponent CityBuilderUrban.ShopComponent

Public Member Functions

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 OnReplacing (IBuilding replacement)
 called when a component gets replaced
use to transfer resources, replace references
 
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
 
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
 

Protected Member Functions

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

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

Member Function Documentation

◆ deregisterTrait< T >()

void CityBuilderCore.BuildingComponent.deregisterTrait< T > ( T trait)
inlineprotected

removes a previously registered trait
usually when a building is removed which calls TerminateComponent

Template Parameters
T
Parameters
trait
Type Constraints
T :IBuildingTrait<T> 

◆ GetDebugText()

◆ GetDescription()

virtual string CityBuilderCore.BuildingComponent.GetDescription ( )
virtual

gets displayed in dialogs to show the component status to players

Returns
a descriptive string or an empty one

Implements CityBuilderCore.IBuildingComponent.

Reimplemented in CityBuilderCore.EmploymentComponent, CityBuilderCore.EvolutionComponent, and CityBuilderCore.HousingComponent.

◆ getOther< T >()

T CityBuilderCore.BuildingComponent.getOther< T > ( )
protected

gets the first building component of the specified type on the same building

Template Parameters
Ttype of the building component to return
Returns
a building component if one is found
Type Constraints
T :class 
T :IBuildingComponent 

◆ getOthers< T >()

IEnumerable< T > CityBuilderCore.BuildingComponent.getOthers< T > ( )
protected

gets all building components of the specified type on the same building

Template Parameters
Ttype of the building components to return
Returns
any building components on the same building that match the type
Type Constraints
T :class 
T :IBuildingComponent 

◆ InitializeComponent()

◆ LoadData()

virtual void CityBuilderCore.BuildingComponent.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.AttackableComponent, CityBuilderCore.CollectionComponent, CityBuilderCore.CyclicWorkerProviderComponent, CityBuilderCore.DefenderAreaComponent, CityBuilderCore.DefenderComponent, CityBuilderCore.DistributionComponent, CityBuilderCore.EmploymentWalkerComponent, CityBuilderCore.EvolutionComponent, CityBuilderCore.GenerationComponent, CityBuilderCore.HousingComponent, CityBuilderCore.HousingPlaceholderComponent, CityBuilderCore.ItemEfficiencyComponent, CityBuilderCore.ItemsRetrieverComponent, CityBuilderCore.MonumentSiteComponent, CityBuilderCore.PooledWorkerProviderComponent, CityBuilderCore.ProductionComponent, CityBuilderCore.ProductionWalkerComponent, CityBuilderCore.RiskerComponent, CityBuilderCore.RiskWalkerComponent, CityBuilderCore.RoadBlockerComponent, CityBuilderCore.ServiceEfficiencyComponent, CityBuilderCore.ServiceWalkerComponent, CityBuilderCore.SpriteRandomizerComponent, CityBuilderCore.StorageComponent, CityBuilderCore.StorageWalkerComponent, CityBuilderCore.TimedReplacementComponent, CityBuilderCore.VariantProductionComponent, CityBuilderCore.VariantProductionWalkerComponent, CityBuilderCore.WalkerComponent, CityBuilderManual.Custom.CustomBuildingComponent, CityBuilderManual.Custom.CustomBuildingTrait, CityBuilderTown.ItemConstructionComponent, CityBuilderTown.TownConstructionComponent, CityBuilderTown.TownFarmingComponent, CityBuilderTown.TownForestingComponent, CityBuilderTown.TownGatheringComponent, CityBuilderTown.TownHomeComponent, CityBuilderTown.TownMarketComponent, CityBuilderTown.TownProductionComponent, CityBuilderTown.TownWorkComponent, CityBuilderUrban.HouseComponent, CityBuilderUrban.RailwayComponent, and CityBuilderUrban.ShopComponent.

◆ OnMoved()

virtual void CityBuilderCore.BuildingComponent.OnMoved ( Vector2Int oldPoint,
BuildingRotation oldRotation )
inlinevirtual

called after a building has been moved
can be used to register things at the new position

Parameters
oldPointpoint of the building before moving
oldRotationrotation of the building before moving

Implements CityBuilderCore.IBuildingComponent.

◆ OnMoving()

virtual void CityBuilderCore.BuildingComponent.OnMoving ( )
inlinevirtual

called when the building is about to be moved
can be used to remove/deregister stuff from the old position

Implements CityBuilderCore.IBuildingComponent.

◆ OnReplacing()

◆ registerTrait< T >()

BuildingComponentReference< T > CityBuilderCore.BuildingComponent.registerTrait< T > ( T trait)
inlineprotected

registers the building component as a trait so it is globally accessible
usually done in InitializeComponent

Template Parameters
Ttrait type to register, the building component or an interface it implements
Parameters
traitobject that will be registered, almost always this building component
Returns
Type Constraints
T :IBuildingTrait<T> 

◆ replaceTrait< T >()

void CityBuilderCore.BuildingComponent.replaceTrait< T > ( T trait,
T replacement )
inlineprotected

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

Template Parameters
T
Parameters
trait
replacement
Type Constraints
T :IBuildingTrait<T> 

◆ ResumeComponent()

virtual void CityBuilderCore.BuildingComponent.ResumeComponent ( )
inlinevirtual

◆ SaveData()

virtual string CityBuilderCore.BuildingComponent.SaveData ( )
virtual

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

Returns
serialized save data

Implements CityBuilderCore.ISaveData.

Reimplemented in CityBuilderCore.AttackableComponent, CityBuilderCore.CollectionComponent, CityBuilderCore.CyclicWorkerProviderComponent, CityBuilderCore.DefenderAreaComponent, CityBuilderCore.DefenderComponent, CityBuilderCore.DistributionComponent, CityBuilderCore.EmploymentWalkerComponent, CityBuilderCore.EvolutionComponent, CityBuilderCore.GenerationComponent, CityBuilderCore.HousingComponent, CityBuilderCore.HousingPlaceholderComponent, CityBuilderCore.ItemEfficiencyComponent, CityBuilderCore.ItemsRetrieverComponent, CityBuilderCore.MonumentSiteComponent, CityBuilderCore.PooledWorkerProviderComponent, CityBuilderCore.ProductionComponent, CityBuilderCore.ProductionWalkerComponent, CityBuilderCore.RiskerComponent, CityBuilderCore.RiskWalkerComponent, CityBuilderCore.RoadBlockerComponent, CityBuilderCore.ServiceEfficiencyComponent, CityBuilderCore.ServiceWalkerComponent, CityBuilderCore.SpriteRandomizerComponent, CityBuilderCore.StorageComponent, CityBuilderCore.StorageWalkerComponent, CityBuilderCore.TimedReplacementComponent, CityBuilderCore.VariantProductionComponent, CityBuilderCore.VariantProductionWalkerComponent, CityBuilderCore.WalkerComponent, CityBuilderManual.Custom.CustomBuildingComponent, CityBuilderManual.Custom.CustomBuildingTrait, CityBuilderTown.ItemConstructionComponent, CityBuilderTown.TownConstructionComponent, CityBuilderTown.TownFarmingComponent, CityBuilderTown.TownForestingComponent, CityBuilderTown.TownGatheringComponent, CityBuilderTown.TownHomeComponent, CityBuilderTown.TownMarketComponent, CityBuilderTown.TownProductionComponent, CityBuilderTown.TownWorkComponent, CityBuilderUrban.HouseComponent, CityBuilderUrban.RailwayComponent, and CityBuilderUrban.ShopComponent.

◆ SetupComponent()

virtual void CityBuilderCore.BuildingComponent.SetupComponent ( )
inlinevirtual

only called when the building is originally placed, before Initialize

Implements CityBuilderCore.IBuildingComponent.

Reimplemented in CityBuilderTown.TownConstructionComponent.

◆ SuspendComponent()

◆ TerminateComponent()

Property Documentation

◆ Building

IBuilding CityBuilderCore.BuildingComponent.Building
getset

the building the component is attached to
is set by the building in awake

Implements CityBuilderCore.IBuildingComponent.

◆ Key

string CityBuilderCore.BuildingComponent.Key
getabstract

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.