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

Detailed Description

buildings are special structures that occupy points starting from an origin extending by a size which can be accessed at ceratin points
the behaviour of a building is achieved by adding different components and addons

default implementation is Building which is sometimes used due to Unity restrictions on interfaces
always consider overriding Building before reimplementing IBuilding

Inheritance diagram for CityBuilderCore.IBuilding:
CityBuilderCore.IStructure CityBuilderCore.ISaveData CityBuilderCore.IKeyed CityBuilderCore.Building CityBuilderCore.ExpandableBuilding CityBuilderCore.Tests.DebugBuilding

Public Member Functions

string GetDescription ()
 display description
 
void Initialize ()
 initialization for buildings when placing and loading
is not called when a building is replaced
 
void Setup ()
 only called when the building is first placed
 
Replace< T > (T prefab)
 replaces the building and all of its parts with another one
runtime values are transferred and references are reset to the new instances
 
void Move (Vector3 position, Quaternion rotation)
 moves the building to a different position
 
void Terminate ()
 de-initializes the buildings and destroys it
 
void Suspend ()
 temporarily stops the building from working
 
void Resume ()
 resumes work in the building after Suspend has been called
 
bool HasBuildingPart< T > ()
 checks if a type of part(components, addons) exists
 
IEnumerable< T > GetBuildingParts< T > ()
 returns all parts composing the building(components, addons)
 
bool HasBuildingComponent< T > ()
 checks if a type of component exists
 
GetBuildingComponent< T > ()
 get first component of a certain type or null
 
IEnumerable< T > GetBuildingComponents< T > ()
 get all components of a certain type
 
bool HasBuildingAddon< T > ()
 checks if a type of addon exists
 
GetBuildingAddon< T > ()
 get first addon of a type or null
 
IEnumerable< T > GetBuildingAddons< T > ()
 get all addons of a certain type
 
AddAddon< T > (T prefab)
 adds and initializes an addon onto the building from a prefab
 
GetAddon< T > (string key)
 get the first addon with the specified key
 
void RemoveAddon (BuildingAddon addon)
 terminates and removes the addon from the building
 
bool RemoveAddon (string key)
 terminates and removes an addon from the building with the given key or returns false if none were found
 
IEnumerable< Vector2Int > GetAccessPoints (PathType type, object tag=null)
 returns any access points that is accessible with the given pathtype
 
Vector2Int? GetAccessPoint (PathType type, object tag=null)
 returns the first access point that is accessible with the given pathtype
 
bool HasAccessPoint (PathType type, object tag=null)
 checks if the building can currently be accessed using the given pathtype
 
- Public Member Functions inherited from CityBuilderCore.IStructure
string GetName ()
 retrieves the name of the structure for display in the UI
 
IEnumerable< Vector2Int > GetPoints ()
 retrieves all the points the structure occupies
 
bool HasPoint (Vector2Int point)
 checks if the structure occupies a certain point
 
void Add (IEnumerable< Vector2Int > points)
 adds points to a structure, for example a tree to a tree structure collection
this may not be possible for structures with fixed points like buildings
typically called in a structures Start method
 
void Remove (IEnumerable< Vector2Int > points)
 removes points from the structure, for some structures like buildings removing any point will remove the whole thing
typically called in a structures OnDestroy method
 
- 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

BuildingReference BuildingReference [get, set]
 reference to the building that keeps working even if the building is replaced
 
Guid Id [get, set]
 unique id for the building, used for saving is not carried over when replacing
 
bool IsSuspended [get]
 building is temporarly disabled, can be used to stop work in a building without having to destroy and rebuild
 
int Index [get, set]
 index of the prefab used, only relevant if the building has BuildingInfo.PrefabAlternatives
 
BuildingInfo Info [get]
 meta info for data that does not change between instances of a building
can be used to compare types of buildings
 
Transform Root [get]
 root transform used as a parent for things that belong to the building but should not be rotated in the pivot(walkers, bars)
 
Transform Pivot [get]
 base transform for building visuals, used in animation
 
Vector2Int Point [get]
 origin(bottomLeft) point on the grid, stays constant when rotated
 
Vector2Int RawSize [get]
 size of the building without rotation
 
Vector2Int Size [get]
 size on the grid, always positive
 
Vector3 WorldCenter [get]
 center position of the building in world space
 
BuildingRotation Rotation [get]
 rotation of the building on the grid, just a int from 0 to 3
 
float Efficiency [get]
 how efficient the building currently is, influenced by all parts implementing IEfficiencyFactor
ranges from 0-1, a building with half its employees would have 0.5 efficiency
 
bool IsWorking [get]
 whether a buildings efficiency is indisturbed
for example a farm on semi ideal land might not have full efficiency while still working
 
- Properties inherited from CityBuilderCore.IStructure
StructureReference StructureReference [get, set]
 reference to the structure that keeps working even if the structure is replaced
 
bool IsDestructible [get]
 whether the structure can be removed by the player
 
bool IsMovable [get]
 whether the structure can be moved by the MoveTool
 
bool IsDecorator [get]
 whether the structure is automatically removed when something is built on top of it
 
bool IsWalkable [get]
 whether walkers can pass the points of this structure
 
int Level [get]
 the structure level mask of this structure
determines which levels a structure occupies
structures that have no levels in common can be placed on top of each other
 
- Properties inherited from CityBuilderCore.IKeyed
string Key [get]
 unique identifier among a type of objects(might be used in savegames, be careful when changing)
 

Additional Inherited Members

- Events inherited from CityBuilderCore.IStructure
Action< PointsChanged< IStructure > > PointsChanged
 has to be fired when a structures points changed so the manager can readjust paths
only viable for structures that are stored in list form like underlying, collections and tiles
other structures have to be reregistered
 

Member Function Documentation

◆ AddAddon< T >()

T CityBuilderCore.IBuilding.AddAddon< T > ( T prefab)

adds and initializes an addon onto the building from a prefab

Template Parameters
T
Parameters
prefab
Returns
the created addon instance

Implemented in CityBuilderCore.Building.

Type Constraints
T :BuildingAddon 

◆ GetAccessPoint()

Vector2Int? CityBuilderCore.IBuilding.GetAccessPoint ( PathType type,
object tag = null )

returns the first access point that is accessible with the given pathtype

Parameters
type
Returns

Implemented in CityBuilderCore.Building, and CityBuilderCore.Tests.DebugBuilding.

◆ GetAccessPoints()

IEnumerable< Vector2Int > CityBuilderCore.IBuilding.GetAccessPoints ( PathType type,
object tag = null )

returns any access points that is accessible with the given pathtype

Parameters
type
tag
Returns

Implemented in CityBuilderCore.Building, and CityBuilderCore.Tests.DebugBuilding.

◆ GetAddon< T >()

T CityBuilderCore.IBuilding.GetAddon< T > ( string key)

get the first addon with the specified key

Template Parameters
Ttype of addon to look for(BuildingAddon for any type)
Parameters
keykey of the addon to look for
Returns
a fitting addon or null if none were found

Implemented in CityBuilderCore.Building.

Type Constraints
T :BuildingAddon 

◆ GetBuildingAddon< T >()

T CityBuilderCore.IBuilding.GetBuildingAddon< T > ( )

get first addon of a type or null

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

Type Constraints
T :BuildingAddon 

◆ GetBuildingAddons< T >()

IEnumerable< T > CityBuilderCore.IBuilding.GetBuildingAddons< T > ( )

get all addons of a certain type

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

Type Constraints
T :BuildingAddon 

◆ GetBuildingComponent< T >()

T CityBuilderCore.IBuilding.GetBuildingComponent< T > ( )

get first component of a certain type or null

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

Type Constraints
T :class 
T :IBuildingComponent 

◆ GetBuildingComponents< T >()

IEnumerable< T > CityBuilderCore.IBuilding.GetBuildingComponents< T > ( )

get all components of a certain type

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

Type Constraints
T :IBuildingComponent 

◆ GetBuildingParts< T >()

IEnumerable< T > CityBuilderCore.IBuilding.GetBuildingParts< T > ( )

returns all parts composing the building(components, addons)

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

◆ GetDescription()

string CityBuilderCore.IBuilding.GetDescription ( )

display description

Returns

Implemented in CityBuilderCore.Building.

◆ HasAccessPoint()

bool CityBuilderCore.IBuilding.HasAccessPoint ( PathType type,
object tag = null )

checks if the building can currently be accessed using the given pathtype

Parameters
type
Returns

Implemented in CityBuilderCore.Building.

◆ HasBuildingAddon< T >()

bool CityBuilderCore.IBuilding.HasBuildingAddon< T > ( )

checks if a type of addon exists

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

Type Constraints
T :BuildingAddon 

◆ HasBuildingComponent< T >()

bool CityBuilderCore.IBuilding.HasBuildingComponent< T > ( )

checks if a type of component exists

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

Type Constraints
T :IBuildingComponent 

◆ HasBuildingPart< T >()

bool CityBuilderCore.IBuilding.HasBuildingPart< T > ( )

checks if a type of part(components, addons) exists

Template Parameters
T
Returns

Implemented in CityBuilderCore.Building.

◆ Initialize()

void CityBuilderCore.IBuilding.Initialize ( )

initialization for buildings when placing and loading
is not called when a building is replaced

Implemented in CityBuilderCore.Building, CityBuilderCore.ExpandableBuilding, and CityBuilderCore.Tests.DebugBuilding.

◆ Move()

void CityBuilderCore.IBuilding.Move ( Vector3 position,
Quaternion rotation )

moves the building to a different position

Implemented in CityBuilderCore.Building.

◆ RemoveAddon() [1/2]

void CityBuilderCore.IBuilding.RemoveAddon ( BuildingAddon addon)

terminates and removes the addon from the building

Parameters
addonthe addon instance to remove

Implemented in CityBuilderCore.Building.

◆ RemoveAddon() [2/2]

bool CityBuilderCore.IBuilding.RemoveAddon ( string key)

terminates and removes an addon from the building with the given key or returns false if none were found

Parameters
key
Returns
true if an addon was found and removed

Implemented in CityBuilderCore.Building.

◆ Replace< T >()

T CityBuilderCore.IBuilding.Replace< T > ( T prefab)

replaces the building and all of its parts with another one
runtime values are transferred and references are reset to the new instances

Template Parameters
T
Parameters
prefab
Returns

Implemented in CityBuilderCore.Building.

Type Constraints
T :MonoBehaviour 
T :IBuilding 

◆ Resume()

void CityBuilderCore.IBuilding.Resume ( )

resumes work in the building after Suspend has been called

Implemented in CityBuilderCore.Building.

◆ Setup()

void CityBuilderCore.IBuilding.Setup ( )

only called when the building is first placed

Implemented in CityBuilderCore.Building, and CityBuilderCore.Tests.DebugBuilding.

◆ Suspend()

void CityBuilderCore.IBuilding.Suspend ( )

temporarily stops the building from working

Implemented in CityBuilderCore.Building.

◆ Terminate()

void CityBuilderCore.IBuilding.Terminate ( )

de-initializes the buildings and destroys it

Implemented in CityBuilderCore.Building, and CityBuilderCore.Tests.DebugBuilding.

Property Documentation

◆ BuildingReference

BuildingReference CityBuilderCore.IBuilding.BuildingReference
getset

reference to the building that keeps working even if the building is replaced

Implemented in CityBuilderCore.Building.

◆ Efficiency

float CityBuilderCore.IBuilding.Efficiency
get

how efficient the building currently is, influenced by all parts implementing IEfficiencyFactor
ranges from 0-1, a building with half its employees would have 0.5 efficiency

Implemented in CityBuilderCore.Building.

◆ Id

Guid CityBuilderCore.IBuilding.Id
getset

unique id for the building, used for saving is not carried over when replacing

Implemented in CityBuilderCore.Building.

◆ Index

int CityBuilderCore.IBuilding.Index
getset

index of the prefab used, only relevant if the building has BuildingInfo.PrefabAlternatives

Implemented in CityBuilderCore.Building.

◆ IsSuspended

bool CityBuilderCore.IBuilding.IsSuspended
get

building is temporarly disabled, can be used to stop work in a building without having to destroy and rebuild

Implemented in CityBuilderCore.Building.

◆ IsWorking

bool CityBuilderCore.IBuilding.IsWorking
get

whether a buildings efficiency is indisturbed
for example a farm on semi ideal land might not have full efficiency while still working

Implemented in CityBuilderCore.Building.

◆ Point

Vector2Int CityBuilderCore.IBuilding.Point
get

origin(bottomLeft) point on the grid, stays constant when rotated

Implemented in CityBuilderCore.Building, and CityBuilderCore.Tests.DebugBuilding.

◆ RawSize

Vector2Int CityBuilderCore.IBuilding.RawSize
get

size of the building without rotation

Implemented in CityBuilderCore.Building, and CityBuilderCore.ExpandableBuilding.

◆ Root

Transform CityBuilderCore.IBuilding.Root
get

root transform used as a parent for things that belong to the building but should not be rotated in the pivot(walkers, bars)

Implemented in CityBuilderCore.Building.

◆ Rotation

BuildingRotation CityBuilderCore.IBuilding.Rotation
get

rotation of the building on the grid, just a int from 0 to 3

Implemented in CityBuilderCore.Building.

◆ Size

Vector2Int CityBuilderCore.IBuilding.Size
get

size on the grid, always positive

Implemented in CityBuilderCore.Building, and CityBuilderCore.Tests.DebugBuilding.

◆ WorldCenter

Vector3 CityBuilderCore.IBuilding.WorldCenter
get

center position of the building in world space

Implemented in CityBuilderCore.Building.