We worked on item decay a little while ago now, but there are quite a few things I think you all will find very interesting about our approach to items. Not only items in general but the way that they can turn into other items through decaying, as well as what it means to be an item.
What is Decay?
This is a very easy question to give answer abstractly, when one item becomes another item due to external factors. External factors can include anything from time, temperature, or even proximity to other items. This starts to look a lot like another system that at already exists in the game, item production. There is very little difference between requiring time or items for decaying and an ore refinery needing perhaps the same exact things to turn ore into metal. So what is decay in Starmancer? Well its just another means of item production, it can specialize slightly and use the same exact item from the start to the end of the production as opposed to consuming an item and then creating a new one (more on that later).
Perks Of Decay as Production
The biggest perk of using production for decay is that it allows very easily allows us to add whatever components we want to an item before, after, and during decay. We can also do incredibly complex things like make an egg that hatches colonists without much effort.
This also gives us the ability to pause or even entirely stop production if any conditions change for an item as well. If the temperature drops below freezing we can change the duration until it molds to much longer, or start a separate decay that will create freezer burnt wheat.
Items: Type vs AttributeCollection
With decay being established as a form of production we then have to ask ourselves what does it mean to be "produced" from decay. Do carrots produce moldy carrots at the cost of carrots or do they become moldy? In a strictly type based item system the former would have to be true carrots are carrots they can never be moldy carrots, even if all other attributes of carrots and moldy carrots were the same like mass and bulk. This also means if carrots where used to make a food dish there would have to be a separate food dish that also used moldy carrots, this could get very irritating to implement any dish into the game. Just three decay stages and two ingredients would require nine different variations of the same dish to be added to the game.
After mulling over these problems we realized the answer was pretty simple given how we have set up the rest of the game. If any object was just an agent with a collection of components that makes them what they are, why not do the same thing with items. Items became not just a type but a collection of attributes to describe what they were. Carrots could be fresh, mold, rotten, red, poisonous, maybe even irradiated. Carrot did not describe the type of item but rather one of the many attributes used to describe an item.
AttributeCollections A Powerful Tool
In my previous example I mentioned that a recipe with two items that have three decay stages would need nine different recipes to ask for the specified items. With attributes you can have a recipe just require an item with the attribute wheat, and regardless of what state of decay it is in our system will still see the wheat as valid. This is expandable to more complicated things too, lets say we add something that makes colonists love the color red. Then if we added the attribute red to any items that are red, like a tomato and a red poster, we could make the colonist seek out things with the attribute red. We could also have building costs for objects just require metal, and anything from "generic space alloy" to copper could be tagged with metal and be valid for building.
Until Next Time
Thank you all for reading through my ramblings, if you made it this far you should check out our Discord you can listen to all of us ramble there. And point out my spelling mistakes. Until next time friends.