Closed bardt closed 2 years ago
Thanks for the issue! Will give this some thought for sure
It turns out that the plugin needs a new respawning mechanism internally due to hot reloading being broken (#108). I'm thinking of making a new Respawn
component. This component can be inserted on a Handle<LdtkAsset>
entity, a Handle<LdtkLevel>
entity, or an EntityInstance
entity, and when it is, the plugin will respawn those entities/their children.
When inserted on the world/level, the appropriate systems will respawn them by:
Respawn
component.The plugin can insert this on the world on AssetEvent::Modified
for hot reloading.
The approach for EntityInstance
will have to be slightly different, and I haven't completely thought through the implementation yet. This use case may be worth putting off until a future release, but I think it would be a reasonable feature eventually.
I miss a way to restart the level (or all levels in the set). What I looking for is a convenient way to:
LevelEvent::Despawned
so I could run my cleanup logicLevelEvent::Spawned
so I could run my initialization logicProposed solution
I would imagine an Event consumer of the library can send, which is handled by a couple of systems in an order:
despawn_system
, removing current or requested level fromLevelSet
. Run beforeLdtkSystemLabel::PreSpawn
.respawn_system
, inserting current or requested level toLevelSet
. Run afterLdtkSystemLabel::PreSpawn
but beforeCoreStage::Update
.This way
apply_level_set
system can react to the removal of the level and triggerDespawned
event; there will be 1 frame gap until respawn though.I implemented roughly this idea in this branch