turn player into primary if only one left

This commit is contained in:
2024-02-27 16:52:20 +01:00
parent 18be0ebe38
commit ac88a74bd7
3 changed files with 22 additions and 9 deletions

View File

@@ -3,6 +3,8 @@ package observers
import (
"openquell/components"
"log/slog"
"github.com/mlange-42/arche/ecs"
"github.com/mlange-42/arche/ecs/event"
"github.com/mlange-42/arche/generic"
@@ -27,6 +29,7 @@ func (observer *GameObserver) GetListenerCallback(comp ecs.ID) listener.Callback
return listener.NewCallback(
func(world *ecs.World, event ecs.EntityEvent) {
observer.RemoveEntity(event.Entity, comp)
slog.Debug("player removed")
},
event.EntityRemoved,
comp,