How to check if a type object is dead?

BlitzMax Forums/BlitzMax Programming/How to check if a type object is dead?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Create a list for your hunters. A field in the hunter type Global HunterList:TList.

When you create a hunter, add it to this list.

Have a method in the prey type you call for the prey when it is killed.

In that method, loop through all hunters in the hunter list with eachin, and check to see if Hunter.Prey = Self. If so set Hunter.Prey to Null.

Now assuming that you have no other pointers in your program pointing to the prey, the prey will be removed as soon as the method ends.

If you have a list of prey, then you will need to remove the prey from that list in that method.

Also, now that the hunters are in a list you will need to remove them from the list when you want them to be deleted.