Hi,
I always use a TList to store the player, enemies and other stuff in my games. And I always remove them when needed by calling something like this:
from within the Entity types. It has worked just fine up until now.
But it won't work for me now for some unknown reason.
I added some debug output to my Remove() function in my base Entity type:
Sample output:
And the funny thing is that the Entity is not removed. It is still drawn to screen and other entities can still interact with it.
And why can't remove() and contains() find the entity, when it shows up in the debug output?
I always use a TList to store the player, enemies and other stuff in my games. And I always remove them when needed by calling something like this:
the_list.remove(self)
from within the Entity types. It has worked just fine up until now.
But it won't work for me now for some unknown reason.
I added some debug output to my Remove() function in my base Entity type:
Method Remove() Print "Before remove: List contains "+ent_list.count()+" entities" If Not ListContains( ent_list,Self ) Then Print " - List claims to not contain the entity..." Print " -- Requesting a remove: "+self.tostring() Print " -- In list:" For Local e:Entity = EachIn ent_list If e.ToString() = self.ToString() Print " --- "+e.ToString()+" <-" Else Print " --- "+e.ToString() EndIf Next EndIf ent_list.remove( Self ) ' Remove the entity Print "After remove: List contains "+ent_list.count()+" entities" EndMethod
Sample output:
Before remove: List contains 3 entities - List claims to not contain the entity... -- Requesting a remove: 00CF1640 -- In list: --- 00CF1E60 --- 00CEBD30 --- 00CF1640 <- After remove: List contains 3 entities
And the funny thing is that the Entity is not removed. It is still drawn to screen and other entities can still interact with it.
And why can't remove() and contains() find the entity, when it shows up in the debug output?