Has there been an FFF that discusses the software architecture for the player inventory?
Posted: Thu Apr 25, 2024 3:40 pm
Hey team! I'm an experienced software engineer, and starting to learn game development as a hobby. I love how Wube is happy to share so many technical details about the Factorio engine.
The Factorio inventory seems to handle many special cases:
- some items stack
- some can be consumed to affect the player (fish)
- some can be consumed to affect the environment (cliff grenades)
- some can be consumed to affect enemies (grenades)
- some are consumed by other actions (ammo)
- some can be placed in the world (assemblers)
- some have durability (pretty much any structure, like turrets)
- some are used but not consumed (spidertron remote)
And there are probably other cases that I'm forgetting. I have reached the point in my learning where I understand how to add/read/remove items in an inventory, render then with an optional stack counter or durability, etc. But when the player wants to use the items, I'm a bit stuck. Most tutorials do one of two things:
1. The Player knows what each item does (this is not very extensible)
2. Each item knows what it does, and how to affect the player / world (more extensible)
And in some online discussions, I've seen that some people will separate the Effect from the Item, so that Items just have a list of Effects, and the Effects know how to affect the player / world.
Have there been any FFFs to discuss how this is handled in Factorio? I would be very interested to hear how the great minds at Wube have decided to solve this.
Erik
The Factorio inventory seems to handle many special cases:
- some items stack
- some can be consumed to affect the player (fish)
- some can be consumed to affect the environment (cliff grenades)
- some can be consumed to affect enemies (grenades)
- some are consumed by other actions (ammo)
- some can be placed in the world (assemblers)
- some have durability (pretty much any structure, like turrets)
- some are used but not consumed (spidertron remote)
And there are probably other cases that I'm forgetting. I have reached the point in my learning where I understand how to add/read/remove items in an inventory, render then with an optional stack counter or durability, etc. But when the player wants to use the items, I'm a bit stuck. Most tutorials do one of two things:
1. The Player knows what each item does (this is not very extensible)
2. Each item knows what it does, and how to affect the player / world (more extensible)
And in some online discussions, I've seen that some people will separate the Effect from the Item, so that Items just have a list of Effects, and the Effects know how to affect the player / world.
Have there been any FFFs to discuss how this is handled in Factorio? I would be very interested to hear how the great minds at Wube have decided to solve this.
Erik