1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-17 14:11:06 +00:00

Portals - fix gameplay monitor unloading

The gameplay monitor wasn't being unloaded correctly in between levels. This meant that exit signals were not being sent, and entered signals for the new level were being missed.

This PR sends appropriate exit signals on unloading, and clear the data.
This commit is contained in:
lawnjelly
2022-01-21 08:48:57 +00:00
parent 08cabf2a36
commit 6c1e243fa2
5 changed files with 107 additions and 0 deletions

View File

@@ -996,6 +996,7 @@ void PortalRenderer::sprawl_roaming(uint32_t p_mover_pool_id, MovingBase &r_movi
void PortalRenderer::_ensure_unloaded(String p_reason) {
if (_loaded) {
_loaded = false;
_gameplay_monitor.unload(*this);
String str;
if (p_reason != String()) {
@@ -1014,6 +1015,17 @@ void PortalRenderer::_ensure_unloaded(String p_reason) {
void PortalRenderer::rooms_and_portals_clear() {
_loaded = false;
// N.B. We want to make sure all the tick counters on movings rooms etc to zero,
// so that on loading the next level gameplay entered signals etc will be
// correctly sent and everything is fresh.
// This is mostly done by the gameplay_monitor, but rooms_and_portals_clear()
// will also clear tick counters where possible
// (there is no TrackedList for the RoomGroup pool for example).
// This could be made neater by moving everything to TrackedPooledLists, but this
// may be overkill.
_gameplay_monitor.unload(*this);
_statics.clear();
_static_ghosts.clear();