Hi,
I hope it's ok to open an issue to ask questions rather than reporting an issue. I have a couple questions on how to handle game maps.
The first question is : Should the map be an entity or a resource ?
The map is a central piece of the game and many systems need to access it, so it makes sense in my opinion to have it defined as a resource.
This has worked fairly well for me so far but i'm now implementing saving and loading in the game, and it looks like resources can't be serialized with a simple function call like the world can.
- Is it a good practice to save a custom object containing various resources in addition to the world state ?
- Should the map be defined as an entity from the start to be saved and loaded as any other entity?
- Should i create a single component map entity right before saving so i can load it as a resource and delete the entity when loading the game?
I'm curious how other people are handling that.
Second question : Is it ok to store entities in map cells ?
My map is a vector of cells, and each cell has a entities field which is a Vec<Entity>, a vector of all entities currently in that cell. This allows me to easily get the list of entities in a specific cell.
I'm not sure if that design is correct. it feels like the ECS way of doing it would be to iterate over entities that have a Position component and return the list of entities which have the position i'm looking for. But that also seems like a huge overhead when you start adding a lot of entities in the game.
Is there an agreed-upon best way to let the map object provide this basic "list what is in place X" function ?
Thanks for taking the time to read,
Peace!
Hi,
I hope it's ok to open an issue to ask questions rather than reporting an issue. I have a couple questions on how to handle game maps.
The first question is : Should the map be an entity or a resource ?
The map is a central piece of the game and many systems need to access it, so it makes sense in my opinion to have it defined as a resource.
This has worked fairly well for me so far but i'm now implementing saving and loading in the game, and it looks like resources can't be serialized with a simple function call like the world can.
I'm curious how other people are handling that.
Second question : Is it ok to store entities in map cells ?
My map is a vector of cells, and each cell has a entities field which is a
Vec<Entity>, a vector of all entities currently in that cell. This allows me to easily get the list of entities in a specific cell.I'm not sure if that design is correct. it feels like the ECS way of doing it would be to iterate over entities that have a Position component and return the list of entities which have the position i'm looking for. But that also seems like a huge overhead when you start adding a lot of entities in the game.
Is there an agreed-upon best way to let the map object provide this basic "list what is in place X" function ?
Thanks for taking the time to read,
Peace!