Conversation
|
There seems to be a conflict between the loop for and the fact that newly created Ghosts also do level.OnEndOfFrame += () => ghost.Active = true; with the result that a lot of spawned Ghosts are permanently disabled, presumably after being created inside this aforementioned loop.This is because you can't add to OnEndOfFrame from within itself, because Scene.AfterUpdate sets its OnEndOfFrame = null right after executing it, removing any newly added event handlers.
One fix that seems to work is to keep the new and then doing this within CelesteNetMainComponent.Update:
I don't know if this would need a flag on the Ghosts to only activate them once or if doing it unconditionally is fine. |
|
|
||
| public void ResetState(Player player = null, Session ses = null) { | ||
| // Clear ghosts if the scene changed | ||
| if (player?.Scene != Player?.Scene) { |
There was a problem hiding this comment.
Oh I can add these types of comments too, eh.
Forgot to mention this line probably needs to be changed to something like:
if (player != null && player.Scene != Player?.Scene) {
just so we don't delete all Ghosts just because Player is null, probably happens somewhere during respawning.
There was a problem hiding this comment.
Actually my suggestion would change/break Cleanup() behavior, which sets Player to null and removes all Ghosts -- with my suggestion, the Ghost removal wouldn't happen anymore...
Maybe we should seperate the Ghost removal from ResetState?
This fixes a few edge cases related to ghost life cycles, which can cause ghosts to become invisible, frozen, or not rendered.