Loading...
Searching...
No Matches
CityBuilderCore.IBuildingComponent Interface Reference

Detailed Description

permanent components making up a buildings behaviour
as such they have to be added to the building transform in the building prefabs
when a building is replaced its components are destroyed with their building
onReplacing is called beforehand so the component can transfer its items and such to an equivalent component in the new building

Inheritance diagram for CityBuilderCore.IBuildingComponent:
CityBuilderCore.ISaveData CityBuilderCore.BuildingComponent CityBuilderCore.IBuildingTrait< T > CityBuilderCore.IDistributionComponent CityBuilderCore.IEmployment CityBuilderCore.IEvolution CityBuilderCore.IItemRecipient CityBuilderCore.IProgressComponent CityBuilderCore.IRiskRecipient CityBuilderCore.IServiceRecipient CityBuilderManual.Custom.ICustomBuildingComponent

Public Member Functions

void SetupComponent ()
 only called when the building is originally placed, before Initialize
 
void InitializeComponent ()
 initialization is performed when the building is placed or loaded
use to create references, register traits, ...
 
void TerminateComponent ()
 termination is performed when the building is destroyed
use to deregister traits, remove references from other systems
 
void OnReplacing (IBuilding replacement)
 called when a component gets replaced
use to transfer resources, replace references
 
void OnMoving ()
 called when the building is about to be moved
can be used to remove/deregister stuff from the old position
 
void OnMoved (Vector2Int oldPoint, BuildingRotation oldRotation)
 called after a building has been moved
can be used to register things at the new position
 
void SuspendComponent ()
 temporarily stops the component from working
 
void ResumeComponent ()
 resumes work in the component after SuspendComponent has been called
 
string GetDebugText ()
 text displayed in scene editor
 
string GetDescription ()
 text that may be displayed in dialogs
 
- Public Member Functions inherited from CityBuilderCore.ISaveData
string SaveData ()
 serializes the objects state(usually to json) and returns it
 
void LoadData (string json)
 deserializes the serialized json data and loads the data as its new state
 

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
 

Member Function Documentation

◆ GetDebugText()

◆ GetDescription()

string CityBuilderCore.IBuildingComponent.GetDescription ( )

◆ InitializeComponent()

◆ OnMoved()

void CityBuilderCore.IBuildingComponent.OnMoved ( Vector2Int oldPoint,
BuildingRotation oldRotation )

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

Implemented in CityBuilderCore.BuildingComponent.

◆ OnMoving()

void CityBuilderCore.IBuildingComponent.OnMoving ( )

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

Implemented in CityBuilderCore.BuildingComponent.

◆ OnReplacing()

◆ ResumeComponent()

◆ SetupComponent()

void CityBuilderCore.IBuildingComponent.SetupComponent ( )

only called when the building is originally placed, before Initialize

Implemented in CityBuilderCore.BuildingComponent, and CityBuilderTown.TownConstructionComponent.

◆ SuspendComponent()

◆ TerminateComponent()

Property Documentation

◆ Building

IBuilding CityBuilderCore.IBuildingComponent.Building
getset

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

Implemented in CityBuilderCore.BuildingComponent.

◆ Key

string CityBuilderCore.IBuildingComponent.Key
get

unique key used to identify the component in save/load

Implemented in CityBuilderCore.AttackableComponent, CityBuilderCore.BuildingComponent, CityBuilderCore.CollectionComponent, CityBuilderCore.ConnectionFeederComponent, CityBuilderCore.ConnectionPasserComponent, CityBuilderCore.CyclicWorkerProviderComponent, CityBuilderCore.DefenderAreaComponent, CityBuilderCore.DefenderComponent, CityBuilderCore.DistributionComponent, CityBuilderCore.EmploymentComponent, CityBuilderCore.EmploymentWalkerComponent, CityBuilderCore.EvolutionComponent, CityBuilderCore.GenerationComponent, CityBuilderCore.HousingComponent, CityBuilderCore.HousingPlaceholderComponent, CityBuilderCore.ItemEfficiencyComponent, CityBuilderCore.ItemsRetrieverComponent, CityBuilderCore.LayerEfficiencyComponent, CityBuilderCore.MonumentSiteComponent, CityBuilderCore.PooledWorkerProviderComponent, CityBuilderCore.ProductionComponent, CityBuilderCore.RiskerComponent, CityBuilderCore.RiskWalkerComponent, CityBuilderCore.RoadBlockerComponent, CityBuilderCore.RoadSwitcherComponent, CityBuilderCore.ScoreEfficiencyComponent, CityBuilderCore.ServiceEfficiencyComponent, CityBuilderCore.ServiceWalkerComponent, CityBuilderCore.SpriteRandomizerComponent, CityBuilderCore.StorageComponent, CityBuilderCore.StorageWalkerComponent, 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, and CityBuilderUrban.ShopComponent.