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

Detailed Description

straightforward IStructureManager implementation
holds collections, decorators and tiles in seperate lists similar to underlying structures

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

Inheritance diagram for CityBuilderCore.DefaultStructureManager:
CityBuilderCore.IStructureManager CityBuilderCore.ISaveData

Classes

class  StructuresData
 

Public Member Functions

IEnumerable< IStructureGetStructures (int mask)
 retrieves all the structures on the map that have any of the levels in the mask
 
IEnumerable< IStructureGetStructures (Vector2Int point, int mask, bool? isWalkable=null, bool? isUnderlying=null, bool? isDecorator=null)
 retrieves all the structures at a point on the map that fit some criteria
 
IStructure GetStructure (string key)
 retrieves a structure by its unique key
 
StructureCollection GetStructureCollection (string key)
 
StructureDecorators GetStructureDecorators (string key)
 
StructureTiles GetStructureTiles (string key)
 
int Remove (IEnumerable< Vector2Int > points, int mask, bool decoratorsOnly, Action< IStructure > removing=null)
 removes points from any structure that occupies that point
for some structures that will remove the entire thing(buildings)
 
void RegisterStructure (IStructure structure, bool isUnderlying=false)
 adds a structure into the managers care, others will now be able to retrieve it from the manager
structures on the map should always be registered with the manager,
 
void DeregisterStructure (IStructure structure, bool isUnderlying=false)
 removes a previously registered structure from the manager
 
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
 

Public Attributes

bool AllowInvalidPath = true
 
WalkerAreaMask DefaultAreaMask
 
GridPathfindingSettings PathfindingSettings
 
StructurePathOption[] PathOptions
 

Static Public Attributes

const int LEVEL_COUNT = 8
 

Protected Member Functions

virtual void Awake ()
 
virtual void Start ()
 
virtual void Update ()
 
virtual void OnDestroy ()
 

Events

Action Changed
 
- Events inherited from CityBuilderCore.IStructureManager
Action Changed
 fired whenever the points occupied by structures change
 

Member Function Documentation

◆ DeregisterStructure()

void CityBuilderCore.DefaultStructureManager.DeregisterStructure ( IStructure structure,
bool isUnderlying = false )
inline

removes a previously registered structure from the manager

Parameters
structurethe structure that will be added to the manager
isUnderlyingshould be the same as when RegisterStructure(IStructure, bool) was called

Implements CityBuilderCore.IStructureManager.

◆ GetStructure()

IStructure CityBuilderCore.DefaultStructureManager.GetStructure ( string key)
inline

retrieves a structure by its unique key

Parameters
keykey of the structure, often set in the inspector
Returns
the structure if any was found

Implements CityBuilderCore.IStructureManager.

◆ GetStructures() [1/2]

IEnumerable< IStructure > CityBuilderCore.DefaultStructureManager.GetStructures ( int mask)
inline

retrieves all the structures on the map that have any of the levels in the mask

Parameters
maskthe structure level to check, 0 for all
Returns
all the structures on the map that collide with the mask

Implements CityBuilderCore.IStructureManager.

◆ GetStructures() [2/2]

IEnumerable< IStructure > CityBuilderCore.DefaultStructureManager.GetStructures ( Vector2Int point,
int mask,
bool? isWalkable = null,
bool? isUnderlying = null,
bool? isDecorator = null )
inline

retrieves all the structures at a point on the map that fit some criteria

Parameters
pointa point on the map
maskstructure level to check, o for all
isWalkableif you only want to check for structures that are walkable or non walkable
isUnderlyingwhether to check for underlying structures
isDecoratorif you only want to check for decorators or non decorators
Returns

Implements CityBuilderCore.IStructureManager.

◆ LoadData()

void CityBuilderCore.DefaultStructureManager.LoadData ( string json)
inline

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

Parameters
json

Implements CityBuilderCore.ISaveData.

◆ RegisterStructure()

void CityBuilderCore.DefaultStructureManager.RegisterStructure ( IStructure structure,
bool isUnderlying = false )
inline

adds a structure into the managers care, others will now be able to retrieve it from the manager
structures on the map should always be registered with the manager,

Parameters
structurethe structure that will be added to the manager
isUnderlyingwhether the structure shold be stored in a special collection instead of a point dictionary, recommended for structures with low number but many points like road networks

Implements CityBuilderCore.IStructureManager.

◆ Remove()

int CityBuilderCore.DefaultStructureManager.Remove ( IEnumerable< Vector2Int > points,
int mask,
bool decoratorsOnly,
Action< IStructure > removing = null )
inline

removes points from any structure that occupies that point
for some structures that will remove the entire thing(buildings)

Parameters
pointsthe points on the map from which to remove structures
maskstructure levels to remove, 0 for all
decoratorsOnlywhether to only remove decorators, for example when building on top of them
removingaction invoked for any structure that will have points removed, can be used to create dust or place demolishing animations instead of the structure
Returns
how many structures were affected

Implements CityBuilderCore.IStructureManager.

◆ SaveData()

string CityBuilderCore.DefaultStructureManager.SaveData ( )
inline

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

Returns
serialized save data

Implements CityBuilderCore.ISaveData.