ClassicCityBuilderKit 1.8.8
|
building component used when constructing buildings
when first placed it checks if there are any trees or rocks in the way and creates harvest tasks so they are replaced
when all obstructions are cleared it creates TownClearTasks for every point of the building which removes grass details from the terrain
if there are any items specified in ItemStorage.ItemCapacities it creates a TownDeliverTask for those next
finally if there is a BuildTaskPrefab specified it creates that and waits for the building to be done
after all the work is done it terminates itself and adds the building specified in FinishedBuilding
Classes | |
class | TownConstructionData |
Public Types | |
enum | ConstructionState { ClearStructures = 0 , ClearGround = 1 , DeliverItems = 10 , Build = 20 } |
Public Member Functions | |
override void | SetupComponent () |
only called when the building is originally placed, before Initialize | |
override void | InitializeComponent () |
initialization is performed when the building is placed or loaded use to create references, register traits, ... | |
override void | TerminateComponent () |
termination is performed when the building is destroyed use to deregister traits, remove references from other systems | |
override void | SuspendComponent () |
temporarily stops the component from working | |
IEnumerable< Item > | GetReceiveItems () |
returns the kinds of items the receiver needs | |
int | GetReceiveCapacity (Item item) |
how much of the item the receiver can still fit | |
void | ReserveCapacity (Item item, int quantity) |
reserves a capacity in the receiver so it is not filled up by someone else | |
void | UnreserveCapacity (Item item, int quantity) |
releases capacity that was earlier reserved by ReserveCapacity(Item, int) call before actually moving items into the receiver or if the delivery was somehow interrupted | |
int | Receive (ItemStorage storage, Item item, int quantity) |
requests that a quantity of items is moved from the storage to the receiver if the full amount does not fit the remaining quantity is returned | |
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.BuildingComponent | |
virtual void | OnReplacing (IBuilding replacement) |
called when a component gets replaced use to transfer resources, replace references | |
virtual void | OnMoving () |
called when the building is about to be moved can be used to remove/deregister stuff from the old position | |
virtual void | OnMoved (Vector2Int oldPoint, BuildingRotation oldRotation) |
called after a building has been moved can be used to register things at the new position | |
virtual void | ResumeComponent () |
resumes work in the component after SuspendComponent has been called | |
virtual string | GetDebugText () |
returns text that gets displayed for debugging in the scene editor | |
virtual string | GetDescription () |
gets displayed in dialogs to show the component status to players | |
Public Attributes | |
ItemStorage | ItemStorage |
TownBuildTask | BuildTaskPrefab |
BuildingInfo | FinishedBuilding |
Transform | BuildVisual |
Properties | |
override string | Key [get] |
unique key used to identify the component in save/load | |
int | Priority [get] |
can be used so certain receivers are preferred over others for example construction sites or production may be more important that putting items into storage | |
BuildingComponentReference< IItemReceiver > | ReceiverReference [get, set] |
IItemContainer | ItemContainer [get] |
holds and manages the items for the owner | |
Properties inherited from CityBuilderCore.BuildingComponent | |
string | Key [get] |
unique key used to identify the component in save/load | |
IBuilding | Building [get, set] |
the building the component is attached to is set by the building in awake | |
Properties inherited from CityBuilderCore.IBuildingComponent | |
Properties inherited from CityBuilderCore.IItemReceiver | |
Properties inherited from CityBuilderCore.IBuildingTrait< IItemReceiver > | |
BuildingComponentReference< T > | Reference [get, set] |
reference to the building trait, use when the building might be replaced and when the reference has to be saved | |
Properties inherited from CityBuilderCore.IItemOwner |
Additional Inherited Members | |
Protected Member Functions inherited from CityBuilderCore.BuildingComponent | |
T | getOther< T > () |
gets the first building component of the specified type on the same building | |
IEnumerable< T > | getOthers< T > () |
gets all building components of the specified type on the same building | |
BuildingComponentReference< T > | registerTrait< T > (T trait) |
registers the building component as a trait so it is globally accessible usually done in InitializeComponent | |
void | replaceTrait< T > (T trait, T replacement) |
replaces the reference a trait points to in the global manager done when a building is replaced(OnReplacing(IBuilding)) so the trait now points to the new component instead of the one that has been removed | |
void | deregisterTrait< T > (T trait) |
removes a previously registered trait usually when a building is removed which calls TerminateComponent | |
int CityBuilderTown.TownConstructionComponent.GetReceiveCapacity | ( | Item | item | ) |
how much of the item the receiver can still fit
item |
Implements CityBuilderCore.IItemReceiver.
IEnumerable< Item > CityBuilderTown.TownConstructionComponent.GetReceiveItems | ( | ) |
returns the kinds of items the receiver needs
Implements CityBuilderCore.IItemReceiver.
|
inlinevirtual |
initialization is performed when the building is placed or loaded
use to create references, register traits, ...
Reimplemented from CityBuilderCore.BuildingComponent.
|
inlinevirtual |
deserializes the serialized json data and loads the data as its new state
json |
Reimplemented from CityBuilderCore.BuildingComponent.
|
inline |
requests that a quantity of items is moved from the storage to the receiver
if the full amount does not fit the remaining quantity is returned
storage | the storage that items will be taken from |
item | the item to receive |
quantity | the maximum quantity of items to receive |
Implements CityBuilderCore.IItemReceiver.
void CityBuilderTown.TownConstructionComponent.ReserveCapacity | ( | Item | item, |
int | quantity ) |
reserves a capacity in the receiver so it is not filled up by someone else
item | the item to be reserved |
quantity | the quantity to reserve |
Implements CityBuilderCore.IItemReceiver.
|
inlinevirtual |
serializes the objects state(usually to json) and returns it
Reimplemented from CityBuilderCore.BuildingComponent.
|
inlinevirtual |
only called when the building is originally placed, before Initialize
Reimplemented from CityBuilderCore.BuildingComponent.
|
inlinevirtual |
temporarily stops the component from working
Reimplemented from CityBuilderCore.BuildingComponent.
|
inlinevirtual |
termination is performed when the building is destroyed
use to deregister traits, remove references from other systems
Reimplemented from CityBuilderCore.BuildingComponent.
void CityBuilderTown.TownConstructionComponent.UnreserveCapacity | ( | Item | item, |
int | quantity ) |
releases capacity that was earlier reserved by ReserveCapacity(Item, int)
call before actually moving items into the receiver or if the delivery was somehow interrupted
item | item to unreserve |
quantity | quantity to unreserve |
Implements CityBuilderCore.IItemReceiver.
|
get |
holds and manages the items for the owner
Implements CityBuilderCore.IItemOwner.
|
get |
unique key used to identify the component in save/load
Implements CityBuilderCore.IBuildingComponent.
|
get |
can be used so certain receivers are preferred over others
for example construction sites or production may be more important that putting items into storage
Implements CityBuilderCore.IItemReceiver.