-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ghost life cycle edge cases #29
base: main
Are you sure you want to change the base?
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. |
@@ -908,6 +881,22 @@ public CelesteNetMainComponent(CelesteNetClientContext context, Game game) | |||
|
|||
#endregion | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.