@@ -140,7 +140,7 @@ func (m *Map[T]) NewBatchFn(count int, fn func(Entity, *T), target ...Entity) {
140140//
141141// ⚠️ Do not store the obtained pointer outside of the current context!
142142func (m * Map [T ]) Get (entity Entity ) * T {
143- if ! m .world .Alive (entity ) {
143+ if ! m .world .storage . entityPool . Alive (entity ) {
144144 panic ("can't get a component of a dead entity" )
145145 }
146146 index := & m .world .storage .entities [entity .id ]
@@ -164,7 +164,7 @@ func (m *Map[T]) GetUnchecked(entity Entity) *T {
164164// Using [Map.Get] and checking for nil pointer may be faster
165165// than calling [Map.Has] and [Map.Get] subsequently.
166166func (m * Map [T ]) Has (entity Entity ) bool {
167- if ! m .world .Alive (entity ) {
167+ if ! m .world .storage . entityPool . Alive (entity ) {
168168 panic ("can't get a component of a dead entity" )
169169 }
170170 return m .HasUnchecked (entity )
@@ -174,8 +174,7 @@ func (m *Map[T]) Has(entity Entity) bool {
174174// In contrast to [Map.Has], it does not check whether the entity is alive.
175175// Can be used as an optimization when it is certain that the entity is alive.
176176func (m * Map [T ]) HasUnchecked (entity Entity ) bool {
177- index := m .world .storage .entities [entity .id ]
178- return m .storage .columns [index .table ] != nil
177+ return m .storage .columns [m .world .storage .entities [entity .id ].table ] != nil
179178}
180179
181180// Add the mapped component to the given entity.
@@ -196,7 +195,7 @@ func (m *Map[T]) Add(entity Entity, comp *T, target ...Entity) {
196195//
197196// ⚠️ Do not store the obtained pointer outside of the current context!
198197func (m * Map [T ]) AddFn (entity Entity , fn func (* T ), target ... Entity ) {
199- if ! m .world .Alive (entity ) {
198+ if ! m .world .storage . entityPool . Alive (entity ) {
200199 panic ("can't add a component to a dead entity" )
201200 }
202201 m .relations = relationEntities (target ).ToRelation (m .world , m .id , m .relations )
@@ -220,7 +219,7 @@ func (m *Map[T]) AddFn(entity Entity, fn func(*T), target ...Entity) {
220219//
221220// This is not a component operation, so it can be performed on a locked world.
222221func (m * Map [T ]) Set (entity Entity , comp * T ) {
223- if ! m .world .Alive (entity ) {
222+ if ! m .world .storage . entityPool . Alive (entity ) {
224223 panic ("can't set component of a dead entity" )
225224 }
226225 m .world .storage .checkHasComponent (entity , m .ids [0 ])
@@ -274,7 +273,7 @@ func (m *Map[T]) AddBatchFn(batch Batch, fn func(Entity, *T), target ...Entity)
274273
275274// Remove the mapped component from the given entity.
276275func (m * Map [T ]) Remove (entity Entity ) {
277- if ! m .world .Alive (entity ) {
276+ if ! m .world .storage . entityPool . Alive (entity ) {
278277 panic ("can't remove a component from a dead entity" )
279278 }
280279 m .world .remove (entity , m .ids [:])
0 commit comments