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

Detailed Description

passes a connection and influences building efficiency from its connection value

Inheritance diagram for CityBuilderCore.ConnectionPasserComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IConnectionPasser CityBuilderCore.IEfficiencyFactor CityBuilderCore.IBuildingComponent CityBuilderCore.ISaveData

Public Member Functions

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
 
override void TerminateComponent ()
 termination is performed when the building is destroyed
use to deregister traits, remove references from other systems
 
IEnumerable< Vector2Int > GetPoints ()
 the points of the passer
 
void ValueChanged (Vector2Int point, int value)
 this is where the passer gets notified about changes to the values of its points
 
- 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 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
 

Public Attributes

Connection Connection
 
bool IsConsumer
 
float MinValue = 0
 
int MaxConnectionValue = 10
 
PointValueEvent PointValueChanged
 
BoolEvent IsWorkingChanged
 

Protected Member Functions

virtual void buildingPointsChanged (PointsChanged< IStructure > e)
 
- 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

override string Key [get]
 unique key used to identify the component in save/load
 
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.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.IConnectionPasser
- Properties inherited from CityBuilderCore.IEfficiencyFactor

Events

Action< PointsChanged< IConnectionPasser > > PointsChanged
 
- Events inherited from CityBuilderCore.IConnectionPasser
Action< PointsChanged< IConnectionPasser > > PointsChanged
 fired by the passer when points are removed or added to it
 

Member Function Documentation

◆ GetPoints()

IEnumerable< Vector2Int > CityBuilderCore.ConnectionPasserComponent.GetPoints ( )

the points of the passer

Returns

Implements CityBuilderCore.IConnectionPasser.

◆ InitializeComponent()

override void CityBuilderCore.ConnectionPasserComponent.InitializeComponent ( )
inlinevirtual

initialization is performed when the building is placed or loaded
use to create references, register traits, ...

Reimplemented from CityBuilderCore.BuildingComponent.

◆ OnReplacing()

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

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

Parameters
replacement

Reimplemented from CityBuilderCore.BuildingComponent.

◆ TerminateComponent()

override void CityBuilderCore.ConnectionPasserComponent.TerminateComponent ( )
inlinevirtual

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

Reimplemented from CityBuilderCore.BuildingComponent.

◆ ValueChanged()

void CityBuilderCore.ConnectionPasserComponent.ValueChanged ( Vector2Int point,
int value )
inline

this is where the passer gets notified about changes to the values of its points

Parameters
pointthe point at which the value changed
valuethe new value at the point

Implements CityBuilderCore.IConnectionPasser.

Property Documentation

◆ Factor

float CityBuilderCore.ConnectionPasserComponent.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 CityBuilderCore.ConnectionPasserComponent.IsWorking
get

false disrupts the building

Implements CityBuilderCore.IEfficiencyFactor.

◆ Key

override string CityBuilderCore.ConnectionPasserComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.