- Home /
Storing Items in a Building Blueprint
I've been looking up crafting and inventory systems and have been struggling over how to implement those methods for my strategy/colony management game in the vein of Rimworld or Dwarf Fortress.
Placed blueprints for walls/floors/roofs etc have resources hauled to them by workers, after which they can be constructed.
I have an XML system for creating blueprints:
<?xml version="1.0" encoding="UTF-8" standalone = "yes"?>
<Walls>
<Wall ID = "stone_wall_0">
<name> Stone Wall </name>
<stats>
<HP> 10 </HP>
<workCost> 8 </workCost>
</stats>
<recipe>
<resourceItem ID = "stone_raw">
4
</resourceItem>
<resourceItem ID = "cement">
2
</resourceItem>
</recipe>
</Walls>
This can then be used by a C# blueprint script attached to a game object to determine what it will become once it's built.
I've been struggling for a while now trying to figure out how to add resource items to the blueprint, and how to implement a system where the blueprint will know when it has the required resources to construct itself. If it was one resource item type per blueprint it wouldn't be a problem, but making each blueprint have multiple different resource types each with different values has sort of complicated things beyond my comprehension.
Something like a list or a dictionary seems obvious but I'm not sure how to implement a way to compare a stored item to the blueprint type's required items and how to tell the blueprint when it's got all the items it needs.