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

Detailed Description

building componnent for risks
updates risks, executes and resolves them and tries to transfer their values when the building gets replaced

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

Inheritance diagram for CityBuilderCore.RiskerComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IRiskRecipient CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingComponent CityBuilderCore.ISaveData CityBuilderCore.ISaveData

Classes

class  RiskerData
 

Public Member Functions

override void OnReplacing (IBuilding replacement)
 called when a component gets replaced
use to transfer resources, replace references
 
bool HasRiskValue (Risk risk)
 whether the recipient handles a particular risk
 
float GetRiskValue (Risk risk)
 checks how far a risk in the recipient has progressed
 
void ModifyRisk (Risk risk, float amount)
 changes a risks value in the recipient
risks have to be reduced regularly or they will execute
 
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
 
virtual string GetDescription ()
 gets displayed in dialogs to show the component status to players
 

Public Attributes

RiskRecipient[] RiskRecipients
 

Properties

override string Key [get]
 unique key used to identify the component in save/load
 
- 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

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

◆ GetRiskValue()

float CityBuilderCore.RiskerComponent.GetRiskValue ( Risk risk)
inline

checks how far a risk in the recipient has progressed

Parameters
riskthe risk for which we want the value
Returns
value in percent of how close the risk is to executing

Implements CityBuilderCore.IRiskRecipient.

◆ HasRiskValue()

bool CityBuilderCore.RiskerComponent.HasRiskValue ( Risk risk)
inline

whether the recipient handles a particular risk

Parameters
riskthe risk to check
Returns
true if the passed risk is present in the recipient

Implements CityBuilderCore.IRiskRecipient.

◆ LoadData()

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

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

Parameters
json

Reimplemented from CityBuilderCore.BuildingComponent.

◆ ModifyRisk()

void CityBuilderCore.RiskerComponent.ModifyRisk ( Risk risk,
float amount )
inline

changes a risks value in the recipient
risks have to be reduced regularly or they will execute

Parameters
riskthe risk that will have its value changed
amountpositive value will move the risk closer to executing, negative value prevent it from happening

Implements CityBuilderCore.IRiskRecipient.

◆ OnReplacing()

override void CityBuilderCore.RiskerComponent.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.RiskerComponent.SaveData ( )
inlinevirtual

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

Returns
serialized save data

Reimplemented from CityBuilderCore.BuildingComponent.

Property Documentation

◆ Key

override string CityBuilderCore.RiskerComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.