Skip to content

Commit

Permalink
mini popup triggers now check for the flag changing instead of just t…
Browse files Browse the repository at this point in the history
…he state
  • Loading branch information
earthwise01 committed Jan 2, 2025
1 parent 89ca5d4 commit 9672992
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Source/Entities/MiniPopupTrigger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Xna.Framework;
using Celeste.Mod.SorbetHelper.Utils;
using Celeste.Mod.Entities;
using Monocle;

namespace Celeste.Mod.SorbetHelper.Entities;

Expand All @@ -24,6 +25,7 @@ public enum Modes {
private readonly string iconPath;
private readonly string texturePath;

private bool currentFlagState;
private bool triggered;

public MiniPopupTrigger(EntityData data, Vector2 offset, EntityID entityId) : base(data, offset) {
Expand All @@ -44,20 +46,31 @@ public MiniPopupTrigger(EntityData data, Vector2 offset, EntityID entityId) : ba
texturePath = data.Attr("texturePath", "");
}

public override void Awake(Scene scene) {
base.Awake(scene);
if (!string.IsNullOrEmpty(flag))
currentFlagState = (scene as Level).Session.GetFlag(flag);
}

public override void Update() {
base.Update();

if (!string.IsNullOrEmpty(flag)) {
if (!string.IsNullOrEmpty(flag) && (Scene as Level).Session.GetFlag(flag) != currentFlagState) {
currentFlagState = !currentFlagState;

switch (Mode) {
case Modes.OnPlayerEnter:
Collidable = (Scene as Level).Session.GetFlag(flag);
Collidable = currentFlagState;
break;

case Modes.OnFlagEnabled:
case Modes.OnFlagDisabled:
if ((Scene as Level).Session.GetFlag(flag, Mode switch { Modes.OnFlagDisabled => true, _ => false}))
if (currentFlagState)
Trigger();
break;

case Modes.OnFlagDisabled:
if (!currentFlagState)
Trigger();
break;
}
}
Expand Down

0 comments on commit 9672992

Please sign in to comment.