Improve assert+imporve error messages when adding comps

This commit is contained in:
bloeys
2022-12-06 06:17:25 +04:00
parent b025afe1b4
commit 855cbfaba3
4 changed files with 6 additions and 12 deletions

View File

@ -15,7 +15,7 @@ type Comp interface {
func AddComp[T Comp](e *Entity, c T) {
assert.T(!HasComp[T](e), "Entity with id %v already has component with name %s", e.ID, c.Name())
assert.T(!HasComp[T](e), "Entity with id '%v' already has component of type '%T'", e.ID, c)
e.Comps = append(e.Comps, c)
c.Init(e)

View File

@ -76,6 +76,7 @@ func (r *Registry) GetEntity(id EntityHandle) *Entity {
return e
}
// FreeEntity calls Destroy on all the entities components, resets the component list, resets the entity flags, then ads this entity to the free list
func (r *Registry) FreeEntity(id EntityHandle) {
e := r.GetEntity(id)