Loading...
Searching...
No Matches
CityBuilderCore.Walker Class Referenceabstract

Detailed Description

base class for entites moving about the map
typically created by some kind of WalkerSpawner<T> on a building
some other ways to create walkers are having spawners on a global manager(urban, town)
or even instantiating and managing the walker save data yourself(TilemapSpawner used in defense)

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

Inheritance diagram for CityBuilderCore.Walker:
CityBuilderCore.MessageReceiver CityBuilderCore.ISaveData CityBuilderCore.IOverrideHeight CityBuilderCore.AttackWalker CityBuilderCore.DeliveryWalker CityBuilderCore.EmigrationWalker CityBuilderCore.HomelessWalker CityBuilderCore.ImmigrationWalker CityBuilderCore.ItemsRetrieverWalker CityBuilderCore.PurchaseWalker CityBuilderCore.RoamingWalker CityBuilderCore.StorageWalker CityBuilderCore.Tests.DebugWalker CityBuilderCore.WanderingWalker CityBuilderCore.WorkerWalker CityBuilderManual.Custom.CustomDestinationWalker CityBuilderTown.TownWalker CityBuilderUrban.PickupWalker CityBuilderUrban.TornadoWalker CityBuilderUrban.TrainWalker

Classes

class  WalkerAddonMetaData
 
class  WalkerData
 

Public Member Functions

virtual void Initialize (BuildingReference home, Vector2Int start)
 called right after instantiating or reactivating a walker
buildings have not had a chance to interact with the walker
when your logic needs something from outside first override Spawned instead
 
virtual void Spawned ()
 called after the walker is fully initialized and its spawning has been signaled to the owner
 
void StartProcess (WalkerAction[] actions, string key=null)
 starts a series of WalkerActions as a process
the actions will be executed in order until the end is reached if another process is already running it is cancelled

 
void AdvanceProcess ()
 mvoes the process to the next action or finishes it when the last action is finished
 
void CancelProcess ()
 requests for the current process to be cancelled
 
void roam (int memoryLength, int range, PathType pathType, UnityEngine.Object pathTag, Action finished=null)
 walker starts walking around semi randomly, visited points are memorized and avoided
 
void roam (int memoryLength, int range, Action finished=null)
 walker starts walking around semi randomly, visited points are memorized and avoided
 
void roam (float delay, int memoryLength, int range, Action finished=null)
 walker starts walking around semi randomly after waiting for a set duration, visited points are memorized and avoided
 
void continueRoam (int memoryLength, int range, Action finished)
 continues roaming when the game is loaded and the walker was roaming previously uses the default pathing defined in the walkers inspector to get points
 
void continueRoam (int memoryLength, int range, PathType pathType, UnityEngine.Object pathTag, Action finished)
 continues roaming when the game is loaded and the walker was roaming previously uses the pathing passed in the parameters to get points
 
void cancelRoam ()
 requests for the current roaming to be stopped, will not happen immediately but when the next point is reached
 
bool walk (IBuilding target, Action finished=null)
 tries to walk to a building using default pathing defined in the inspector
 
bool walk (Vector2Int target, Action finished=null)
 tries to walk to a specific point using default pathing defined in the inspector
 
bool walk (Vector2Int target, PathType pathType, UnityEngine.Object pathTag, Action finished=null)
 tries to walk to a specific point using the pathing passed in the parameters
 
void walk (WalkingPath path, Action finished=null)
 starts walking a set walking path
 
void walk (WalkingPath path, float delay, Action finished=null)
 starts walking a set walking path
 
void continueWalk (Action finished=null)
 when the game is loaded and the walker was previously walking it is continued here
 
void cancelWalk ()
 stops the current walking, walking may not stop immediately but rather when the walker reaches the next full point
 
void wander (Action finished)
 starts walking to a random neighbouring point if one is available
 
void continueWander (Action finished)
 when the game is loaded and the walker was previously wandering it is continued here
 
void wait (Action finished, float time)
 starts waiting for a set duration
 
void delay (Action finished)
 waits for the duration configured in WalkerInfo.Delay
 
void continueWait (Action finished)
 when the game is loaded and the walker was previously waiting it is continued here
 
void cancelWait ()
 cancels waiting, remaining time is set to 0 and finished is called
 
void Hide ()
 hides the walker by deactivating its pivot and disableing its collider
 
void Show ()
 hides the walker by activating its pivot and enableing its collider
 
void Finish ()
 Removes the walker from the map(when it has done its job or died for example)
 
virtual string GetName ()
 
virtual string GetDescription ()
 gets displayed in dialogs to show the walker description to players
 
virtual string GetDebugText ()
 returns text that gets displayed for debugging in the scene editor
 
AddAddon< T > (T prefab)
 adds and initializes an addon onto the walker from a prefab
 
GetAddon< T > (T _)
 get the first addon of the specified type
 
GetAddon< T > (string key)
 get the first addon with the specified key
 
bool HasAddon< T > ()
 checks if a certain addon type is present on the walker
 
bool HasAddon< T > (T _)
 checks if a certain addon type is present on the walker
 
bool HasAddon (string key)
 checks if an addon with a specific key is present on the walker
 
void RemoveAddon (WalkerAddon addon)
 terminates and removes an addon from the walker
 
bool RemoveAddon (string key)
 terminates and removes an addon from the building with the given key or returns false if none were found
 
virtual string SaveData ()
 serializes the objects state(usually to json) and returns it
 
virtual void LoadData (string json)
 deserializes the serialized json data and loads the data as its new state
 
- Public Member Functions inherited from CityBuilderCore.MessageReceiver
virtual void OnMessages (string e)
 use when a single string has to be split into several messages
by default the parameter is split by spaces
 
virtual void OnMessage (string e)
 puts a message into the characters messaging pipeline
 

Public Attributes

WalkerInfo Info
 
Transform Pivot
 
Animator Animator
 
NavMeshAgent Agent
 
BoolEvent IsWalkingChanged
 
Vector3Event DirectionChanged
 
- Public Attributes inherited from CityBuilderCore.MessageReceiver
MessageReceiver ForwardReceiver
 
UnityEvent< string > MessageReceived
 
MessageEvent[] MessageEvents
 

Protected Member Functions

virtual void Start ()
 
virtual void OnDestroy ()
 
virtual void onProcessFinished (ProcessState process)
 called when the current process is finished, may be overridden to look for something else to do(for example in the town demo)
 
virtual void onMoved (Vector2Int point)
 called whenever movement reaches a point in its path
these are corner points in regular movement and every path point when roaming
 
virtual void onFinished ()
 called to remove the walker from the map when it has done its job(or died)
 
void followPath (IEnumerable< Vector3 > path, Action finished)
 starts walking a set series of points
 
void followPath (IEnumerable< Vector3 > path, float delay, Action finished)
 starts walking a set walking path
 
void continueFollow (Action finished)
 continues following a path when a game is loaded and the walker was previously doing so
 
void tryWalk (IBuilding target, float delay, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk to a building, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk (Vector2Int target, float delay, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk to a point, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk (Func< WalkingPath > pathGetter, float delay, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk a path that is calculated externaly, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk (IBuilding target, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk to a building, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

 
void tryWalk (Vector2Int target, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk to a point, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk (Func< WalkingPath > pathGetter, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk a path that is calculated externaly, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk (Func< PathQuery > queryGetter, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk a path that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk (Func< PathQuery > queryGetter, float delay, Action planned=null, Action finished=null, Action canceled=null)
 tries to walk a path that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk< T > (Func< BuildingComponentPathQuery< T > > queryGetter, Action< BuildingComponentPath< T > > planned=null, Action finished=null, Action canceled=null)
 tries to walk a path to a component that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk< T > (Func< BuildingComponentPathQuery< T > > queryGetter, float delay, Action< BuildingComponentPath< T > > planned=null, Action finished=null, Action canceled=null)
 tries to walk a path to a component that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk< Q, P > (Func< Q > preparer, Func< Q, P > planner, Func< P, WalkingPath > planned, Action finished=null, Action canceled=null)
 tries to walk a path that created in a two step process, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
void tryWalk< Q, P > (Func< Q > preparer, Func< Q, P > planner, Func< P, WalkingPath > planned, float delay, Action finished=null, Action canceled=null)
 tries to walk a path that created in a two step process, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out
 
string getDescription (int index)
 returns a specific description that may explain the current walker status
 
string getDescription (int index, params object[] parameters)
 returns a specific description that may explain the current walker status with placeholders replaced by specified parameters
for example 'delivering {1} to {2} from {0}' where 0 is the home building name, 1 is the item name and 2 is the target building(DeliveryWalker in ThreeDemo)
 
WalkerData savewalkerData ()
 
void loadWalkerData (WalkerData data)
 

Protected Attributes

List< WalkerAddon_addonsQueue = new List<WalkerAddon>()
 addons that are queued up when an addon uses BuildingAddon.AddonAccumulationMode.Queue
in this case every addon after the first is put into the queue and when an addon is removed the queue is empties first
 
List< WalkerAddon_addons = new List<WalkerAddon>()
 currently active WalkerAddons on this walker
 
Vector2Int _start
 map point the walker was initialized on, used in roamers to return back to
 
Vector2Int _current
 last map point the walker has finished moving to, used whenever a new path needs to be found or just to check where the walker is
 
bool _isFinished
 whether the walker has finished and is no longer active on the map, can be used to make sure a walker does not perform any further actions once finished
 

Properties

Guid Id = Guid.NewGuid() [get, set]
 unique walker identifier that is also persisted, can be used to save references to walkers
 
BuildingReference Home [get, set]
 reference to the building the walker was spawned from, if any
 
ProcessState CurrentProcess [get, set]
 returns the current ProcessState if a process is currently active
 
ProcessState NextProcess [get, set]
 the process that will be started when the current one finishes
is used when a process is started when another one is still running
 
RoamingState CurrentRoaming [get, set]
 returns the current RoamingState if the walker is currently roaming
 
WalkingState CurrentWalking [get, set]
 returns the current WalkingState if the walker is currently walking
 
WalkingAgentState CurrentAgentWalking [get, set]
 returns the current WalkingState if the walker is currently walking using a navmesh agent
 
WaitingState CurrentWaiting [get, set]
 returns the current WaitingState if the walker is currently waiting
 
float? HeightOverride [get, set]
 height that the entity is forced to have, null to use the regular height(terrain or road height)
 
Vector2Int CurrentPoint [get]
 last map point the walker has finished moving to, used whenever a new path needs to be found or just to check where the walker is
 
Vector2Int GridPoint [get]
 map point the walker is currently positioned on by absolute position
 
virtual float Speed [get]
 
virtual PathType PathType [get]
 
virtual UnityEngine.Object PathTag [get]
 optional parameter for pathfinding, depends on PathType
for example a road for road pathing to only walk on that specific road
 
virtual ItemStorage ItemStorage [get]
 item storage of the walker if there is one
 
WalkerAction CurrentAction [get]
 currently active action when a process is running
 
bool IsWalking [get, set]
 whether the walker is currently moving(roaming, walking or agent walking)
 
IReadOnlyCollection< WalkerAddonAddons [get]
 currently active WalkerAddons on this walker
 
- Properties inherited from CityBuilderCore.IOverrideHeight

Events

Action< WalkerFinished
 fired when the walker is finished, used by spawners to destroy/deactivate the walker
 
Action< WalkerMoved
 fired whenever the walker has moved to a 'corner' in its path, for every point when roaming
 

Member Function Documentation

◆ AddAddon< T >()

T CityBuilderCore.Walker.AddAddon< T > ( T prefab)
inline

adds and initializes an addon onto the walker from a prefab

Template Parameters
Ttype of the addon
Parameters
prefabprefab that gets instantiated on the walker
Returns
the instantiated addon instance
Type Constraints
T :WalkerAddon 

◆ continueFollow()

void CityBuilderCore.Walker.continueFollow ( Action finished)
inlineprotected

continues following a path when a game is loaded and the walker was previously doing so

Parameters
finished

◆ continueRoam() [1/2]

void CityBuilderCore.Walker.continueRoam ( int memoryLength,
int range,
Action finished )
inline

continues roaming when the game is loaded and the walker was roaming previously uses the default pathing defined in the walkers inspector to get points

Parameters
memoryLengthhow many points the walker will memorize and try to avoid
rangehow many steps the walker roams before returning
finishedcalled when roaming is finished(regularly or canceled)

◆ continueRoam() [2/2]

void CityBuilderCore.Walker.continueRoam ( int memoryLength,
int range,
PathType pathType,
UnityEngine.Object pathTag,
Action finished )
inline

continues roaming when the game is loaded and the walker was roaming previously uses the pathing passed in the parameters to get points

Parameters
memoryLengthhow many points the walker will memorize and try to avoid
rangehow many steps the walker roams before returning
pathTypewhich kind of pathfinding will be performed to check which points are available
pathTagadditional parameter for pathfinding
finishedcalled when roaming is finished(regularly or canceled)

◆ continueWait()

void CityBuilderCore.Walker.continueWait ( Action finished)
inline

when the game is loaded and the walker was previously waiting it is continued here

Parameters
finishedcalled when the waiting time has passed

◆ continueWalk()

void CityBuilderCore.Walker.continueWalk ( Action finished = null)
inline

when the game is loaded and the walker was previously walking it is continued here

Parameters
finishedcallback for when the walking is finished

◆ continueWander()

void CityBuilderCore.Walker.continueWander ( Action finished)
inline

when the game is loaded and the walker was previously wandering it is continued here

Parameters
finishedcalled when the point is reached

◆ delay()

void CityBuilderCore.Walker.delay ( Action finished)
inline

waits for the duration configured in WalkerInfo.Delay

Parameters
finishedcalled when the delay has passed

◆ followPath() [1/2]

void CityBuilderCore.Walker.followPath ( IEnumerable< Vector3 > path,
Action finished )
inlineprotected

starts walking a set series of points

Parameters
pathseries of points the walker needs to walk to in order
finishedcallback for when the walking is finished

◆ followPath() [2/2]

void CityBuilderCore.Walker.followPath ( IEnumerable< Vector3 > path,
float delay,
Action finished )
inlineprotected

starts walking a set walking path

Parameters
pathseries of points the walker needs to walk to in order
delayduration to wait before walking is started in seconds
finishedcallback for when the walking is finished

◆ GetAddon< T >() [1/2]

T CityBuilderCore.Walker.GetAddon< T > ( string key)
inline

get the first addon with the specified key

Template Parameters
Ttype of addon to look for(WalkerAddon for any type)
Parameters
keykey of the addon to look for
Returns
a fitting addon or null if none were found
Type Constraints
T :WalkerAddon 

◆ GetAddon< T >() [2/2]

T CityBuilderCore.Walker.GetAddon< T > ( T _)
inline

get the first addon of the specified type

Template Parameters
Ttype of addon to look for
Parameters
_for example the prefab the addon was instantiated from
Returns
a fitting addon or null if none were found
Type Constraints
T :WalkerAddon 

◆ GetDebugText()

virtual string CityBuilderCore.Walker.GetDebugText ( )
virtual

returns text that gets displayed for debugging in the scene editor

Returns
a debugging string or null

Reimplemented in CityBuilderCore.AttackWalker, CityBuilderCore.DeliveryWalker, CityBuilderCore.ItemsRetrieverWalker, CityBuilderCore.PurchaseWalker, CityBuilderCore.StorageWalker, and CityBuilderTown.TownWalker.

◆ GetDescription()

virtual string CityBuilderCore.Walker.GetDescription ( )
virtual

gets displayed in dialogs to show the walker description to players

Returns
a descriptive string or an empty one

Reimplemented in CityBuilderCore.DeliveryWalker, CityBuilderCore.PurchaseWalker, CityBuilderCore.RoamingWalker, and CityBuilderCore.StorageWalker.

◆ getDescription() [1/2]

string CityBuilderCore.Walker.getDescription ( int index)
protected

returns a specific description that may explain the current walker status

Parameters
indexindex of the description within the walker info
Returns
an explanatory string meant for players

◆ getDescription() [2/2]

string CityBuilderCore.Walker.getDescription ( int index,
params object[] parameters )
inlineprotected

returns a specific description that may explain the current walker status with placeholders replaced by specified parameters
for example 'delivering {1} to {2} from {0}' where 0 is the home building name, 1 is the item name and 2 is the target building(DeliveryWalker in ThreeDemo)

Parameters
indexindex of the description within the walker info
parametersarray of parameters that replace placeholders in the description
Returns
an explanatory string meant for players

◆ HasAddon()

bool CityBuilderCore.Walker.HasAddon ( string key)
inline

checks if an addon with a specific key is present on the walker

Parameters
keykey of the addon to look for
Returns
if at least one of the desired addon is active on the walker

◆ HasAddon< T >() [1/2]

bool CityBuilderCore.Walker.HasAddon< T > ( )
inline

checks if a certain addon type is present on the walker

Template Parameters
Ttype of addon to check
Returns
if at least one of the addon type is active on the walker
Type Constraints
T :WalkerAddon 

◆ HasAddon< T >() [2/2]

bool CityBuilderCore.Walker.HasAddon< T > ( T _)
inline

checks if a certain addon type is present on the walker

Template Parameters
Ttype of addon to check
Parameters
_for example the prefab the addon was instantiated from
Returns
if at least one of the addon type is active on the walker
Type Constraints
T :WalkerAddon 

◆ Initialize()

virtual void CityBuilderCore.Walker.Initialize ( BuildingReference home,
Vector2Int start )
inlinevirtual

◆ LoadData()

◆ onFinished()

virtual void CityBuilderCore.Walker.onFinished ( )
inlineprotectedvirtual

◆ onMoved()

virtual void CityBuilderCore.Walker.onMoved ( Vector2Int point)
inlineprotectedvirtual

called whenever movement reaches a point in its path
these are corner points in regular movement and every path point when roaming

Parameters
pointthe point reached during movement

Reimplemented in CityBuilderCore.BuildingWalker.

◆ onProcessFinished()

virtual void CityBuilderCore.Walker.onProcessFinished ( ProcessState process)
inlineprotectedvirtual

called when the current process is finished, may be overridden to look for something else to do(for example in the town demo)

Parameters
process

Reimplemented in CityBuilderCore.Tests.DebugWalker, and CityBuilderTown.TownWalker.

◆ RemoveAddon() [1/2]

bool CityBuilderCore.Walker.RemoveAddon ( string key)
inline

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

◆ RemoveAddon() [2/2]

void CityBuilderCore.Walker.RemoveAddon ( WalkerAddon addon)
inline

terminates and removes an addon from the walker

Parameters
addonthe addon to remove

◆ roam() [1/3]

void CityBuilderCore.Walker.roam ( float delay,
int memoryLength,
int range,
Action finished = null )
inline

walker starts walking around semi randomly after waiting for a set duration, visited points are memorized and avoided

Parameters
delayduration in seconds the walker waits before starting to roam
memoryLengthhow many points the walker will memorize and try to avoid
rangehow many steps the walker roams before returning
finishedcalled when roaming is finished(regularly or canceled)

◆ roam() [2/3]

void CityBuilderCore.Walker.roam ( int memoryLength,
int range,
Action finished = null )
inline

walker starts walking around semi randomly, visited points are memorized and avoided

Parameters
memoryLengthhow many points the walker will memorize and try to avoid
rangehow many steps the walker roams before returning
finishedcalled when roaming is finished(regularly or canceled)

◆ roam() [3/3]

void CityBuilderCore.Walker.roam ( int memoryLength,
int range,
PathType pathType,
UnityEngine.Object pathTag,
Action finished = null )
inline

walker starts walking around semi randomly, visited points are memorized and avoided

Parameters
memoryLengthhow many points the walker will memorize and try to avoid
rangehow many steps the walker roams before returning
pathTypewhich kind of pathfinding will be performed to check which points are available
pathTagadditional parameter for pathfinding
finishedcalled when roaming is finished(regularly or canceled)

◆ SaveData()

◆ Spawned()

virtual void CityBuilderCore.Walker.Spawned ( )
inlinevirtual

called after the walker is fully initialized and its spawning has been signaled to the owner

Reimplemented in CityBuilderCore.BuildingWalker, CityBuilderCore.ItemsRetrieverWalker, CityBuilderCore.WorkerWalker, and CityBuilderTown.TownWalker.

◆ StartProcess()

void CityBuilderCore.Walker.StartProcess ( WalkerAction[] actions,
string key = null )
inline

starts a series of WalkerActions as a process
the actions will be executed in order until the end is reached if another process is already running it is cancelled

Parameters
actionsseries of actions that is executed in order as a process
keycan be used to identify the process, used to check what the walker is currently doing

◆ tryWalk() [1/8]

void CityBuilderCore.Walker.tryWalk ( Func< PathQuery > queryGetter,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
queryGetterfunction that returns the query for the path the walker should walk or null if no path could be found currently
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk() [2/8]

void CityBuilderCore.Walker.tryWalk ( Func< PathQuery > queryGetter,
float delay,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
queryGetterfunction that returns the query for the path the walker should walk or null if no path could be found currently
delayhow long the walker waits before moving, gives pathfinding some time to calculate
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk() [3/8]

void CityBuilderCore.Walker.tryWalk ( Func< WalkingPath > pathGetter,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path that is calculated externaly, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
pathGetterfunction that returns the path the walker should walk or null if no path could be found currently
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk() [4/8]

void CityBuilderCore.Walker.tryWalk ( Func< WalkingPath > pathGetter,
float delay,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path that is calculated externaly, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
pathGetterfunction that returns the path the walker should walk or null if no path could be found currently
delayduration in seconds the walker will always wait before moving(instead of the default WalkerInfo.Delay)
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk() [5/8]

void CityBuilderCore.Walker.tryWalk ( IBuilding target,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk to a building, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
targetthe building the walker will try to reach
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk() [6/8]

void CityBuilderCore.Walker.tryWalk ( IBuilding target,
float delay,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk to a building, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
targetthe building the walker will try to reach
delayduration in seconds the walker will always wait before moving(instead of the default WalkerInfo.Delay)
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk() [7/8]

void CityBuilderCore.Walker.tryWalk ( Vector2Int target,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk to a point, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
targetthe building the walker will try to reach
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk() [8/8]

void CityBuilderCore.Walker.tryWalk ( Vector2Int target,
float delay,
Action planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk to a point, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Parameters
targetthe building the walker will try to reach
delayduration in seconds the walker will always wait before moving(instead of the default WalkerInfo.Delay)
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk< Q, P >() [1/2]

void CityBuilderCore.Walker.tryWalk< Q, P > ( Func< Q > preparer,
Func< Q, P > planner,
Func< P, WalkingPath > planned,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path that created in a two step process, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Template Parameters
T
Parameters
preparerfirst step, for example to start a query
plannersecond step, result of the first step is passed, for example to complete a query that was prepared
plannedcalled when a path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk< Q, P >() [2/2]

void CityBuilderCore.Walker.tryWalk< Q, P > ( Func< Q > preparer,
Func< Q, P > planner,
Func< P, WalkingPath > planned,
float delay,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path that created in a two step process, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Template Parameters
T
Parameters
preparerfirst step, for example to start a query
plannersecond step, result of the first step is passed, for example to complete a query that was prepared
plannedcalled when a path is found
delayhow long the walker waits before moving, gives pathfinding some time to calculate between preparer and planner
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled

◆ tryWalk< T >() [1/2]

void CityBuilderCore.Walker.tryWalk< T > ( Func< BuildingComponentPathQuery< T > > queryGetter,
Action< BuildingComponentPath< T > > planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path to a component that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Template Parameters
T
Parameters
queryGetterfunction that returns the query for the component path the walker should walk or null if no path could be found currently
plannedcalled when a component path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled
Type Constraints
T :IBuildingComponent 

◆ tryWalk< T >() [2/2]

void CityBuilderCore.Walker.tryWalk< T > ( Func< BuildingComponentPathQuery< T > > queryGetter,
float delay,
Action< BuildingComponentPath< T > > planned = null,
Action finished = null,
Action canceled = null )
inlineprotected

tries to walk a path to a component that is calculated externaly using a query, if no path is found the walker waits a second and retries until WalkerInfo.MaxWait times it out

Template Parameters
T
Parameters
queryGetterfunction that returns the query for the component path the walker should walk or null if no path could be found currently
delayhow long the walker waits before moving, gives pathfinding some time to calculate
plannedcalled when a component path is found
finishedcalled when the walker reaches its target
canceledcalled if the walker finds no path and times out or waiting gets canceled
Type Constraints
T :IBuildingComponent 

◆ wait()

void CityBuilderCore.Walker.wait ( Action finished,
float time )
inline

starts waiting for a set duration

Parameters
finishedcalled when the duration has passed
timeduration in seconds

◆ walk() [1/5]

bool CityBuilderCore.Walker.walk ( IBuilding target,
Action finished = null )
inline

tries to walk to a building using default pathing defined in the inspector

Parameters
targetthe building to walk to
finishedcallback for when the walking is finished
Returns
whether walking was successfully started, false if no path was found

◆ walk() [2/5]

bool CityBuilderCore.Walker.walk ( Vector2Int target,
Action finished = null )
inline

tries to walk to a specific point using default pathing defined in the inspector

Parameters
targetthe map point to walk to
finishedcallback for when the walking is finished
Returns
whether walking was successfully started, false if no path was found

◆ walk() [3/5]

bool CityBuilderCore.Walker.walk ( Vector2Int target,
PathType pathType,
UnityEngine.Object pathTag,
Action finished = null )
inline

tries to walk to a specific point using the pathing passed in the parameters

Parameters
targetthe map point to walk to
pathTypewhich kind of pathfinding will be performed to check which points are available
pathTagadditional parameter for pathfinding
finishedcallback for when the walking is finished
Returns
whether walking was successfully started, false if no path was found

◆ walk() [4/5]

void CityBuilderCore.Walker.walk ( WalkingPath path,
Action finished = null )
inline

starts walking a set walking path

Parameters
pathfinished walking path that contains all the points the walker needs to walk to in order
finishedcallback for when the walking is finished

◆ walk() [5/5]

void CityBuilderCore.Walker.walk ( WalkingPath path,
float delay,
Action finished = null )
inline

starts walking a set walking path

Parameters
pathfinished walking path that contains all the points the walker needs to walk to in order
delayduration to wait before walking is started in seconds
finishedcallback for when the walking is finished

◆ wander()

void CityBuilderCore.Walker.wander ( Action finished)
inline

starts walking to a random neighbouring point if one is available

Parameters
finishedcalled when the point is reached or immediately if none is available

Property Documentation

◆ HeightOverride

float? CityBuilderCore.Walker.HeightOverride
getset

height that the entity is forced to have, null to use the regular height(terrain or road height)

Implements CityBuilderCore.IOverrideHeight.