mirror of
https://github.com/bloeys/nmage.git
synced 2025-12-29 05:18:21 +00:00
Improve assert+imporve error messages when adding comps
This commit is contained in:
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user