#Designing an inventory system

2 messages · Page 1 of 1 (latest)

iron aspen
#

I need some help designing / planning the inventory system for my game, I am a bit lost on how to get started, so I thought lets ask the bevy guys.

Some requirements I have for the system:
MODULAR: Must be able to use a subset of the features, so I can apply it easily to all kinds of objects (players, chests, etc)
EVENT BASED: I want to be able to listen for things like pick up events, so for example a sound can be played.
NETWORK FRIENDLY: I need to be able to send/receive incremental updates of the inventory over the network, so that the player knows what is in their inventory, but not too much bandwidth gets used.

tight loom
#

I have something like this, but my game isn't dealing with multiplayer so I can't say how well it would translate. Anyways, basically the inventory is a component called StorageContainer.

The basics is that it is a struct with a Vec<Option<StoredItem>>.

#[derive(Component, Default, Debug, Clone, Serialize, Deserialize)]
pub struct StorageContainer {
    pub items: Vec<Option<StoredItem>>,
}

Then you implement your methods on StorageContainer in order to mutate it (i.e. add, remove, etc.) If you want to use events, you'd just write another layer above the API for the StorageContainer that receives those events and calls the corresponding method plus also plays the sound.

You can then use all the same methods across the player's inventory, chests, etc.