amethyst / amethyst/legion

Game map questions (Resource vs Entity)

Aperta
#279 1 commento 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
1.7k
Fork
140
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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`, 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!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.