Skip to content

Commit ac11502

Browse files
authored
Merge pull request #113 from EverestAPI/bubble_field_flag_control
Add flag activation options to Bubble Push Fields
2 parents 53b4bd1 + c7c1d5b commit ac11502

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Ahorn/entities/bubblePushField.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
using ..Ahorn, Maple
44

5-
@mapdef Entity "SpringCollab2020/bubblePushField" BubblePushField(x::Integer, y::Integer, width::Integer=Maple.defaultBlockWidth, height::Integer=Maple.defaultBlockHeight, strength::Number=1, upwardStrength::Number=1, direction::String="Right", water::Bool=true)
5+
@mapdef Entity "SpringCollab2020/bubblePushField" BubblePushField(x::Integer, y::Integer, width::Integer=Maple.defaultBlockWidth, height::Integer=Maple.defaultBlockHeight,
6+
strength::Number=1, upwardStrength::Number=1, direction::String="Right", water::Bool=true, flag::String="bubble_push_field", activationMode::String="Always")
67

78
const placements = Ahorn.PlacementDict(
89
"Bubble Column (Spring Collab 2020)" => Ahorn.EntityPlacement(
@@ -12,7 +13,8 @@ const placements = Ahorn.PlacementDict(
1213
)
1314

1415
Ahorn.editingOptions(entity::BubblePushField) = Dict{String,Any}(
15-
"direction" => ["Up", "Down", "Left", "Right"]
16+
"direction" => ["Up", "Down", "Left", "Right"],
17+
"activationMode" => ["Always", "OnlyWhenFlagActive", "OnlyWhenFlagInactive"]
1618
)
1719

1820
Ahorn.minimumSize(entity::BubblePushField) = 8, 8

Ahorn/lang/en_gb.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ placements.entities.SpringCollab2020/bubblePushField.tooltips.strength=The stren
4747
placements.entities.SpringCollab2020/bubblePushField.tooltips.upwardStrength=How much the bubbles push the player up to compensate for gravity.
4848
placements.entities.SpringCollab2020/bubblePushField.tooltips.direction=The direction the bubbles push the player.
4949
placements.entities.SpringCollab2020/bubblePushField.tooltips.water=If the bubble field will create a Water entity to make its presence visible.
50+
placements.entities.SpringCollab2020/bubblePushField.tooltips.activationMode=Determines on which condition the bubble column activates.
51+
placements.entities.SpringCollab2020/bubblePushField.tooltips.flag=The session flag this bubble push field reacts to (when Activation Mode is "only if flag (in)active").
5052

5153
# Upside Down Jump Thru
5254
placements.entities.SpringCollab2020/UpsideDownJumpThru.tooltips.texture=Changes the appearance of the platform.

Entities/BubblePushField.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
namespace Celeste.Mod.SpringCollab2020.Entities {
88
[CustomEntity("SpringCollab2020/bubblePushField")]
99
class BubblePushField : Entity {
10+
public enum ActivationMode {
11+
Always, OnlyWhenFlagActive, OnlyWhenFlagInactive
12+
}
13+
1014
public float Strength;
1115

1216
public float UpwardStrength;
@@ -26,21 +30,28 @@ class BubblePushField : Entity {
2630

2731
public PushDirection Direction;
2832

33+
private ActivationMode activationMode;
34+
private string flag;
35+
2936
public BubblePushField(EntityData data, Vector2 offset) : this(
3037
data.Position + offset,
3138
data.Width,
3239
data.Height,
3340
data.Float("strength", 1f),
3441
data.Float("upwardStrength", 1f),
3542
data.Attr("direction", "right"),
36-
data.Bool("water", true)
43+
data.Bool("water", true),
44+
data.Enum("activationMode", ActivationMode.Always),
45+
data.Attr("flag", "bubble_push_field")
3746
) { }
3847

39-
public BubblePushField(Vector2 position, int width, int height, float strength, float upwardStrength, string direction, bool water) {
48+
public BubblePushField(Vector2 position, int width, int height, float strength, float upwardStrength, string direction, bool water, ActivationMode activationMode, string flag) {
4049
Position = position;
4150
Strength = strength;
4251
UpwardStrength = upwardStrength;
4352
_water = water;
53+
this.activationMode = activationMode;
54+
this.flag = flag;
4455

4556
Rand = new Random();
4657

@@ -70,6 +81,14 @@ public override void Render() {
7081
public override void Update() {
7182
base.Update();
7283

84+
Session session = SceneAs<Level>().Session;
85+
if ((activationMode == ActivationMode.OnlyWhenFlagActive && !session.GetFlag(flag))
86+
|| (activationMode == ActivationMode.OnlyWhenFlagInactive && session.GetFlag(flag))) {
87+
88+
// the bubble push field is currently turned off by a session flag.
89+
return;
90+
}
91+
7392
FramesSinceSpawn++;
7493
if (FramesSinceSpawn == SpawnFrame) {
7594
FramesSinceSpawn = 0;

0 commit comments

Comments
 (0)