mcdonaldduncan / Freebooter

Columbia College Chicago Senior Capstone
4 stars 0 forks source link

Fix bug that prevents player from dying #275

Closed Sebp23 closed 1 year ago

Sebp23 commented 1 year ago

When the player chooses a level (after choosing the first one they play), the player is unable to die

Reproduction Steps:

  1. Run the game and choose any level
  2. Die in the level and choose "Level Select" from the death screen
  3. Choose the same level you were just on
  4. Die in the level and choose "Respawn"
  5. Die again and observe that the death screen does not display, thus preventing the player from respawning.
Sebp23 commented 1 year ago

Player dying bug has been fixed! We realized that there was a bug that had been present for a while but wasn't causing respawn issues, however, with the addition of the death screen, certain code was no longer being executed after the bug occurred. Since then, the death screen has now been fixed to be event based and the respawn bug has been fixed as well.

The respawn bug was caused by the player respawn event in the level manager not being properly destroyed since it was static, and thus not having its subscribers unsubscribe from the event. This meant that after reloading to the main menu (destroying stuff from the level the player was just in), the objects that were subscribed to the event were destroyed, but were not properly unsubscribed. This led to the invocation of the event trying to reference objects that no longer existed, and thus prevented the death screen from appearing which meant the player could not choose an option to respawn.

This has been fixed by making the event no longer static, and by cleaning up the singleton logic for our level managers.