Loading...
Searching...
No Matches
CityBuilderCore.BuildingComponentWalker< T > Class Template Reference

Detailed Description

base class for walkers that roam and perform actions when passing a certain type of building component
override onComponentEntered(T) and onComponentRemaining(T) to react to components in the walkers area

Type Constraints
T :class 
T :IBuildingComponent 
Inheritance diagram for CityBuilderCore.BuildingComponentWalker< T >:
CityBuilderCore.BuildingWalker CityBuilderCore.RoamingWalker CityBuilderCore.Walker CityBuilderCore.MessageReceiver CityBuilderCore.ISaveData CityBuilderCore.IOverrideHeight

Protected Member Functions

override void onEntered (IBuilding building)
 called when the building first enters the walkers area
 
override void onRemaining (IBuilding building)
 called on every frame the walkers area contains the building
 
virtual void onComponentEntered (T buildingComponent)
 called when the building component first enters the walkers area
 
virtual void onComponentRemaining (T buildingComponent)
 called on every frame the walkers area contains the building component
 
- Protected Member Functions inherited from CityBuilderCore.BuildingWalker
virtual void Update ()
 
override void onMoved (Vector2Int position)
 called whenever movement reaches a point in its path
these are corner points in regular movement and every path point when roaming
 
- Protected Member Functions inherited from CityBuilderCore.RoamingWalker
virtual void onRoamFinished ()
 
override void onFinished ()
 called to remove the walker from the map when it has done its job(or died)
 
- Protected Member Functions inherited from CityBuilderCore.Walker
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)
 
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)
 

Additional Inherited Members

- Public Types inherited from CityBuilderCore.RoamingWalker
enum  RoamingWalkerState { Inactive = 0 , Roaming = 1 , Waiting = 2 , Returning = 3 }
 
- Public Member Functions inherited from CityBuilderCore.BuildingWalker
override 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
 
override void Spawned ()
 called after the walker is fully initialized and its spawning has been signaled to the owner
 
- Public Member Functions inherited from CityBuilderCore.RoamingWalker
override 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
 
override string GetDescription ()
 gets displayed in dialogs to show the walker description to players
 
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.Walker
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 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
 
- 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 inherited from CityBuilderCore.BuildingWalker
int Area = 1
 
bool IsCross
 
- Public Attributes inherited from CityBuilderCore.RoamingWalker
int Memory = 64
 
int Range = 16
 
bool ReturnHome = true
 
- Public Attributes inherited from CityBuilderCore.Walker
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 Attributes inherited from CityBuilderCore.RoamingWalker
RoamingWalkerState _state = RoamingWalkerState.Inactive
 
- Protected Attributes inherited from CityBuilderCore.Walker
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 inherited from CityBuilderCore.Walker
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 inherited from CityBuilderCore.Walker
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

◆ onComponentEntered()

virtual void CityBuilderCore.BuildingComponentWalker< T >.onComponentEntered ( T buildingComponent)
inlineprotectedvirtual

called when the building component first enters the walkers area

Parameters
buildingComponentthe building component inside the walkers area

◆ onComponentRemaining()

virtual void CityBuilderCore.BuildingComponentWalker< T >.onComponentRemaining ( T buildingComponent)
inlineprotectedvirtual

called on every frame the walkers area contains the building component

Parameters
buildingComponentthe building component inside the walkers area

◆ onEntered()

override void CityBuilderCore.BuildingComponentWalker< T >.onEntered ( IBuilding building)
inlineprotectedvirtual

called when the building first enters the walkers area

Parameters
buildingthe building inside the walkers area

Reimplemented from CityBuilderCore.BuildingWalker.

◆ onRemaining()

override void CityBuilderCore.BuildingComponentWalker< T >.onRemaining ( IBuilding building)
inlineprotectedvirtual

called on every frame the walkers area contains the building

Parameters
buildingthe building inside the walkers area

Reimplemented from CityBuilderCore.BuildingWalker.