Proper support for zero handles

This commit is contained in:
bloeys
2023-10-09 05:03:48 +04:00
parent c998fc26ce
commit 80ce6d60d2
2 changed files with 10 additions and 0 deletions

View File

@ -77,6 +77,10 @@ func (r *Registry[T]) New() (*T, Handle) {
func (r *Registry[T]) Get(id Handle) *T {
if id.IsZero() {
return nil
}
index := id.Index()
assert.T(index < uint64(len(r.Handles)), "Failed to get entity because of invalid entity handle. Handle index is %d while registry only has %d slots. Handle: %+v", index, r.ItemCount, id)