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

Detailed Description

default implementation for the resource systems

manages global items as well as finding the right givers, receivers and dispensers for items

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

Inheritance diagram for CityBuilderCore.DefaultItemManager:
CityBuilderCore.IGlobalStorage CityBuilderCore.IGiverPathfinder CityBuilderCore.IReceiverPathfinder CityBuilderCore.IItemsDispenserManager

Public Member Functions

void Add (IItemsDispenser dispenser)
 adds a dispenser to the manager so it can be found by retrievers
 
void Remove (IItemsDispenser dispenser)
 removes a previously added retriever so it can no longer be found be retrievers
 
IItemsDispenser GetDispenser (string key, Vector3 position, float maxDistance)
 looks for the closest dispenser that has the right key
 
bool HasDispenser (string key, Vector3 position, float maxDistance)
 checks if there is a dispenser with the right key in the vicinity
 
BuildingComponentPath< IItemGiverGetGiverPath (IBuilding building, Vector2Int? currentPoint, ItemQuantity items, float maxDistance, PathType pathType, object pathTag=null)
 attempts to find an IItemGiver and a path to it for a needed item
 
BuildingComponentPathQuery< IItemGiverGetGiverPathQuery (IBuilding building, Vector2Int? currentPoint, ItemQuantity items, float maxDistance, PathType pathType, object pathTag=null)
 
BuildingComponentPath< IItemReceiverGetReceiverPath (IBuilding building, Vector2Int? currentPoint, ItemQuantity items, float maxDistance, PathType pathType, object pathTag=null, int currentPriority=0)
 attempts to find a receiver and a path to it for an item a walker wants to deliver
 
BuildingComponentPathQuery< IItemReceiverGetReceiverPathQuery (IBuilding building, Vector2Int? currentPoint, ItemQuantity items, float maxDistance, PathType pathType, object pathTag=null, int currentPriority=0)
 

Public Attributes

ItemStorage ItemStorage
 
ItemQuantity[] StartItems
 
bool PrioritizeEmptyReceivers
 

Protected Member Functions

virtual void Awake ()
 
virtual void Start ()
 
virtual bool isValid (IBuilding building, ItemQuantity items, IItemGiver giver)
 
virtual bool isValid (IBuilding building, ItemQuantity items, IItemReceiver receiver, int currentPriority=0)
 
virtual bool isDiscarded (ItemQuantity items, IItemGiver currentGiver, float currentPathDistance, IItemGiver potentialGiver, float potentialBuildingDistance)
 
virtual bool isDiscarded (ItemQuantity items, IItemReceiver currentReceiver, float currentPathDistance, IItemReceiver potentialReceiver, float potentialBuildingDistance)
 
virtual bool isMoreImportant (ItemQuantity items, IItemGiver currentGiver, float currentPathDistance, IItemGiver potentialGiver, float potentialPathDistance)
 
virtual bool isMoreImportant (ItemQuantity items, IItemReceiver currentReceiver, float currentPathDistance, IItemReceiver potentialReceiver, float potentialPathDistance)
 

Properties

ItemStorage Items [get]
 storage that holds the items of the global storage
 
- Properties inherited from CityBuilderCore.IGlobalStorage

Member Function Documentation

◆ Add()

void CityBuilderCore.DefaultItemManager.Add ( IItemsDispenser dispenser)
inline

adds a dispenser to the manager so it can be found by retrievers

Parameters
dispenserthe retrievers to add

Implements CityBuilderCore.IItemsDispenserManager.

◆ GetDispenser()

IItemsDispenser CityBuilderCore.DefaultItemManager.GetDispenser ( string key,
Vector3 position,
float maxDistance )
inline

looks for the closest dispenser that has the right key

Parameters
keykey used to discern different types of dispensers(rock, tree, gold, ...)
positionabsolute world position of the retriever
maxDistancemaximum distance between dispenser and retriever
Returns
the closest dispenser if one was found

Implements CityBuilderCore.IItemsDispenserManager.

◆ GetGiverPath()

BuildingComponentPath< IItemGiver > CityBuilderCore.DefaultItemManager.GetGiverPath ( IBuilding building,
Vector2Int? currentPoint,
ItemQuantity items,
float maxDistance,
PathType pathType,
object pathTag = null )
inline

attempts to find an IItemGiver and a path to it for a needed item

Parameters
buildinghome building of the walker if any
currentPointcurrent position of the walker(if not home)
itemsitems that are needed
maxDistancemaximum distance from walker to giver
pathTypedefines the type of pathing to use
pathTagadditional pathing parameter
Returns

Implements CityBuilderCore.IGiverPathfinder.

◆ GetGiverPathQuery()

BuildingComponentPathQuery< IItemGiver > CityBuilderCore.DefaultItemManager.GetGiverPathQuery ( IBuilding building,
Vector2Int? currentPoint,
ItemQuantity items,
float maxDistance,
PathType pathType,
object pathTag = null )
inline

◆ GetReceiverPath()

BuildingComponentPath< IItemReceiver > CityBuilderCore.DefaultItemManager.GetReceiverPath ( IBuilding building,
Vector2Int? currentPoint,
ItemQuantity items,
float maxDistance,
PathType pathType,
object pathTag = null,
int currentPriority = 0 )
inline

attempts to find a receiver and a path to it for an item a walker wants to deliver

Parameters
buildinghome building of the walker
currentPointcurrent point of the walker(if not home)
itemsitems the walker is trying to get rid of
maxDistancemaximum distance a receiver can be from the walker
pathTypepathing type to use for the walking path
pathTagadditional pathing paramater
currentPriorityIItemReceiver.Priority of the building the walker is coming from, used to make sure an item is not delivered from one storage to another for example
Returns
a reference and path to a receiver if one was found

Implements CityBuilderCore.IReceiverPathfinder.

◆ GetReceiverPathQuery()

BuildingComponentPathQuery< IItemReceiver > CityBuilderCore.DefaultItemManager.GetReceiverPathQuery ( IBuilding building,
Vector2Int? currentPoint,
ItemQuantity items,
float maxDistance,
PathType pathType,
object pathTag = null,
int currentPriority = 0 )
inline

◆ HasDispenser()

bool CityBuilderCore.DefaultItemManager.HasDispenser ( string key,
Vector3 position,
float maxDistance )
inline

checks if there is a dispenser with the right key in the vicinity

Parameters
keykey used to discern different types of dispensers(rock, tree, gold, ...)
positionabsolute world position of the retriever
maxDistancemaximum distance between dispenser and retriever
Returns
true if a dispenser is available

Implements CityBuilderCore.IItemsDispenserManager.

◆ Remove()

void CityBuilderCore.DefaultItemManager.Remove ( IItemsDispenser dispenser)
inline

removes a previously added retriever so it can no longer be found be retrievers

Parameters
dispenserthe dispenser to remove

Implements CityBuilderCore.IItemsDispenserManager.

Property Documentation

◆ Items

ItemStorage CityBuilderCore.DefaultItemManager.Items
get

storage that holds the items of the global storage

Implements CityBuilderCore.IGlobalStorage.