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

Detailed Description

building component that has health and can be attacked, terminates the building when its health runs out

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

Inheritance diagram for CityBuilderCore.AttackableComponent:
CityBuilderCore.BuildingComponent CityBuilderCore.IAttackable CityBuilderCore.IHealther CityBuilderCore.IBuildingComponent CityBuilderCore.IBuildingTrait< IAttackable > CityBuilderCore.ISaveData

Classes

class  AttackebleData
 

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
 
override string GetDebugText ()
 returns text that gets displayed for debugging in the scene editor
 
void Attack (int damage)
 deals damage to the attackable, reducing its health and potentially destroying it
 
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 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 GetDescription ()
 gets displayed in dialogs to show the component status to players
 

Public Attributes

Transform HealthTarget
 
int MaxHealth
 
DemolishVisual DemolishVisual
 

Properties

override string Key [get]
 unique key used to identify the component in save/load
 
BuildingComponentReference< IAttackableReference [get, set]
 
float TotalHealth [get]
 maximum health the entity can have
 
float CurrentHealth [get]
 current health the entity has
 
Vector3 HealthPosition [get]
 the absolute world position that the health bar should be displayed at
 
- 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.IBuildingTrait< IAttackable >
BuildingComponentReference< T > Reference [get, set]
 reference to the building trait, use when the building might be replaced and when the reference has to be saved
 
- Properties inherited from CityBuilderCore.IHealther

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

◆ Attack()

void CityBuilderCore.AttackableComponent.Attack ( int damage)
inline

deals damage to the attackable, reducing its health and potentially destroying it

Parameters
damagethe amount of damage to do

Implements CityBuilderCore.IAttackable.

◆ GetDebugText()

override string CityBuilderCore.AttackableComponent.GetDebugText ( )
virtual

returns text that gets displayed for debugging in the scene editor

Returns
a debugging string or null

Reimplemented from CityBuilderCore.BuildingComponent.

◆ InitializeComponent()

override void CityBuilderCore.AttackableComponent.InitializeComponent ( )
inlinevirtual

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

Reimplemented from CityBuilderCore.BuildingComponent.

◆ LoadData()

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

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

Parameters
json

Reimplemented from CityBuilderCore.BuildingComponent.

◆ OnReplacing()

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

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

Returns
serialized save data

Reimplemented from CityBuilderCore.BuildingComponent.

◆ TerminateComponent()

override void CityBuilderCore.AttackableComponent.TerminateComponent ( )
inlinevirtual

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

Reimplemented from CityBuilderCore.BuildingComponent.

Property Documentation

◆ CurrentHealth

float CityBuilderCore.AttackableComponent.CurrentHealth
get

current health the entity has

Implements CityBuilderCore.IHealther.

◆ HealthPosition

Vector3 CityBuilderCore.AttackableComponent.HealthPosition
get

the absolute world position that the health bar should be displayed at

Implements CityBuilderCore.IHealther.

◆ Key

override string CityBuilderCore.AttackableComponent.Key
get

unique key used to identify the component in save/load

Implements CityBuilderCore.IBuildingComponent.

◆ TotalHealth

float CityBuilderCore.AttackableComponent.TotalHealth
get

maximum health the entity can have

Implements CityBuilderCore.IHealther.