idanarye / bevy-yoleck

Your Own Level Editor Creation Kit
Other
172 stars 11 forks source link

Entities that refer to other entities #21

Closed idanarye closed 11 months ago

idanarye commented 1 year ago

Some entities need to refer to other entities. For example - a key that opens a specific door. We need a way to represent this and to provide UI for editing this.

idanarye commented 1 year ago

Entities should obviously get serializable IDs - Bevy's builtin Entity won't work because we can not guarantee the relevant IDs are not in use when a level is loaded from scratch. So probably a UUID.

There is no need to give every entity a UUID, and this can be done in Vpeol - say with a struct VpeolUuid(Uuid) component. Any entity that has that component will automatically get a UUID assigned to it - this is not something the level-editor can edit (unless they manipulate the .yol files). Additionally, Vpeol will maintain a UUID->entity hashmap, so that entities that refer to other entities that refer to a VpeolUuid entity can quickly find it. This hashmap will be populated in a populate system (a bit misleading, since it does not populate the entity's components, but it still populates a resource so this kind of works) that runs before all the other populate systems - so that they can all depend on it.

idanarye commented 1 year ago

https://github.com/idanarye/bevy-yoleck/issues/22#issuecomment-1507051294

idanarye commented 1 year ago

If I want to use that for #23, it can't be in Vpeol - it has to be part of Yoleck itself. So YoleckUuid instead of VpeolUuid. And maybe YoleckUuid should not be a YoleckComponent. Actually - does it even have to be a Bevy component of its own?

idanarye commented 11 months ago

This is a dup of #3