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

Detailed Description

helper used by IRoadManager to manage a single road network
it holds the pathfinding for both regular and blocked road pathing
also it counts as a IStructure and can therefore be queried and checked against using IStructureManager
this basic RoadNetwork is not visualized in any way, it is only a logical helper
for a visualized network inherit this class and implement setPoint(Vector2Int, Road) and checkPoint(Vector2Int)
examples of this can be found in TilemapRoadNetwork and TerrainRoadNetwork

Inheritance diagram for CityBuilderCore.RoadNetwork:
CityBuilderCore.IStructure CityBuilderCore.ILayerDependency CityBuilderCore.IKeyed CityBuilderCore.TerrainRoadNetwork CityBuilderCore.TilemapRoadNetwork

Classes

class  RoadData
 
class  RoadsData
 

Public Member Functions

 RoadNetwork (GridPathfindingSettings pathfindingSettings, Road road, int level=0)
 
virtual void Initialize ()
 
virtual void Dispose ()
 
void Calculate (int maxCalculations=PathQuery.DEFAULT_MAX_CALCULATIONS)
 
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
 
List< Vector2Int > Add (IEnumerable< Vector2Int > points, Road road)
 
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
 
void Register (IEnumerable< Vector2Int > points)
 
void Deregister (IEnumerable< Vector2Int > points)
 
void RegisterLink (IGridLink link)
 
void DeregisterLink (IGridLink link)
 
IEnumerable< IGridLinkGetLinks (Vector2Int start)
 
IGridLink GetLink (Vector2Int start, Vector2Int end)
 
void RegisterSwitch (Vector2Int point, RoadNetwork other)
 
void RegisterSwitch (Vector2Int entry, Vector2Int point, Vector2Int exit, RoadNetwork other)
 
void Block (IEnumerable< Vector2Int > points)
 
void Unblock (IEnumerable< Vector2Int > points)
 
void BlockTags (IEnumerable< Vector2Int > points, IEnumerable< object > tags)
 
void UnblockTags (IEnumerable< Vector2Int > points, IEnumerable< object > tags)
 
virtual void CheckLayers (IEnumerable< Vector2Int > points)
 gets called when
 
virtual bool TryGetRoad (Vector2Int point, out Road road, out string stage)
 
bool CheckPoint (Vector2Int point)
 checks if a point is defined by the network itself
points registered from the outside return false
 
virtual RoadsData SaveData ()
 
virtual void LoadData (RoadsData roadsData)
 

Protected Member Functions

virtual void setPoint (Vector2Int point, Road road)
 
virtual bool checkPoint (Vector2Int point)
 
void onPointsChanged (PointsChanged< IStructure > pointsChanged)
 

Properties

Road Road [get]
 
GridPathfindingBase DefaultPathfinding [get]
 
GridPathfindingBase BlockedPathfinding [get]
 
List< Vector2Int > Blocked [get]
 
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
 
string Key [get]
 unique identifier among a type of objects(might be used in savegames, be careful when changing)
 
- Properties inherited from CityBuilderCore.IStructure
- Properties inherited from CityBuilderCore.IKeyed

Events

Action< PointsChanged< IStructure > > PointsChanged
 
- 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

◆ Add()

void CityBuilderCore.RoadNetwork.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

Parameters
pointsthe points that will be added to the structure

Implements CityBuilderCore.IStructure.

◆ CheckLayers()

virtual void CityBuilderCore.RoadNetwork.CheckLayers ( IEnumerable< Vector2Int > points)
inlinevirtual

gets called when

Parameters
points

Implements CityBuilderCore.ILayerDependency.

Reimplemented in CityBuilderCore.TerrainRoadNetwork, and CityBuilderCore.TilemapRoadNetwork.

◆ CheckPoint()

bool CityBuilderCore.RoadNetwork.CheckPoint ( Vector2Int point)

checks if a point is defined by the network itself
points registered from the outside return false

Parameters
pointa point on the map
Returns
true if the network contains the point, false if the point does not exist or has only been registered from outside

◆ GetName()

string CityBuilderCore.RoadNetwork.GetName ( )

retrieves the name of the structure for display in the UI

Returns
name of the structure for UI

Implements CityBuilderCore.IStructure.

◆ GetPoints()

IEnumerable< Vector2Int > CityBuilderCore.RoadNetwork.GetPoints ( )

retrieves all the points the structure occupies

Returns
the points the structure occupies

Implements CityBuilderCore.IStructure.

◆ HasPoint()

bool CityBuilderCore.RoadNetwork.HasPoint ( Vector2Int point)

checks if the structure occupies a certain point

Parameters
pointa point on the map
Returns
true if the structure occupies that point

Implements CityBuilderCore.IStructure.

◆ Remove()

void CityBuilderCore.RoadNetwork.Remove ( IEnumerable< Vector2Int > points)
inline

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

Parameters
pointsthe points to remove

Implements CityBuilderCore.IStructure.

Property Documentation

◆ IsDecorator

bool CityBuilderCore.RoadNetwork.IsDecorator
get

whether the structure is automatically removed when something is built on top of it

Implements CityBuilderCore.IStructure.

◆ IsDestructible

bool CityBuilderCore.RoadNetwork.IsDestructible
get

whether the structure can be removed by the player

Implements CityBuilderCore.IStructure.

◆ IsMovable

bool CityBuilderCore.RoadNetwork.IsMovable
get

whether the structure can be moved by the MoveTool

Implements CityBuilderCore.IStructure.

◆ IsWalkable

bool CityBuilderCore.RoadNetwork.IsWalkable
get

whether walkers can pass the points of this structure

Implements CityBuilderCore.IStructure.

◆ Key

string CityBuilderCore.RoadNetwork.Key
get

unique identifier among a type of objects(might be used in savegames, be careful when changing)

Implements CityBuilderCore.IKeyed.

◆ Level

int CityBuilderCore.RoadNetwork.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

Implements CityBuilderCore.IStructure.

◆ StructureReference

StructureReference CityBuilderCore.RoadNetwork.StructureReference
getset

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

Implements CityBuilderCore.IStructure.