alienbreed3d2
alienbreed3d2 copied to clipboard
Two player mode item respawn
Allow respawning of collectables in two player mode:
- When collected, remove the item from the map by specifying a magic value for the zone ID (currently -1 is used to indicate the item is free, so -2 may be a good idea) and store the original zone ID in an unused field for the entity type.
- Maintain a list of the items that currently have this temporarily removed state.
- Set one of the appropriate entity countdown timers.
- Each frame, traverse the list, counting down the timers in the items.
- Whenever an item's timer is up, set it's zone ID back to what was backed up to re-spawn the item.
Implementing this will need a mechanism to move the item to a different zone. Normally, elements are removed by setting their zone ID to -1, but that allows them to be reused for other object types. For collectables, it might be better to set their zone ID to a different value (not negative), e.g. 32767. The list of objects that have this zone id would need to be traversed each frame to have their counters decremented so that they can be respawned. It would also be necessary to back up their actual zone ID somewhere, though there tend to be numerous fields in the entity type that may be suitable.