Ideally you should store all the objects that need to be updated on type-lists, and update them from those type-lists. Where it becomes necessary to check if an object has been deleted, just sequence its type-list to see if it is still on that list.
Example:- (Note that it may be better to use some sort of managed ID values to identify the objects, rather than the entity handle. It's possible that a new entity may get allocated the same handle value as a deleted entity, which could cause an intermitant bug.)
Type T_monster
Field entity
End Type
; Update all monsters.
For monster.T_monster = Each T_monster
UpdateMonster( monster\entity )
Next
Function GetMonsterByEntity.T_monster( entity )
; NOTE: Returns a pointer to the monster object if the monster entity exists, or a null pointer if it doesn't exist.
Local monster.T_monster, result.T_monster
For monster = Each T_monster
If monster\entity = entity then result = monster
Next
Return result
End Function
|