Skip to content

Commit

Permalink
add toggle option to core mode trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
microlith57 committed Oct 1, 2023
1 parent cec7cf1 commit 5a08285
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions Celeste.Mod.mm/Mod/Entities/CoreModeTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,41 @@
namespace Celeste.Mod.Entities {
[CustomEntity("everest/coreModeTrigger", "cavern/coremodetrigger")]
public class CoreModeTrigger : Trigger {
private readonly Session.CoreModes mode;
private enum Modes {
None,
Hot,
Cold,
Toggle
}

private readonly Modes mode;
private readonly bool playEffects;

public CoreModeTrigger(EntityData data, Vector2 offset)
public CoreModeTrigger(EntityData data, Vector2 offset)
: base(data, offset) {
mode = data.Enum("mode", Session.CoreModes.None);
mode = data.Enum("mode", Modes.None);
playEffects = data.Bool("playEffects", true);
}

public override void OnEnter(Player player) {
Level level = Scene as Level;
if (level.CoreMode == mode)

Session.CoreModes newMode = Session.CoreModes.None;

if (mode == Modes.Toggle) {
if (level.CoreMode == Session.CoreModes.Hot)
newMode = Session.CoreModes.Cold;
else if (level.CoreMode == Session.CoreModes.Cold)
newMode = Session.CoreModes.Hot;
} else {
newMode = (Session.CoreModes) mode;
}

if (level.CoreMode == newMode)
return;
level.CoreMode = mode;

level.CoreMode = newMode;

if (playEffects) {
Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
level.Flash(Color.White * 0.15f, true);
Expand Down

0 comments on commit 5a08285

Please sign in to comment.