Skip to content

Commit

Permalink
Add 'Move Immediately' parameter for Flag Switch Gates
Browse files Browse the repository at this point in the history
  • Loading branch information
maddie480 committed Sep 11, 2024
1 parent 5064305 commit 4824d08
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Ahorn/entities/maxHelpingHandFlagSwitchGate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ using ..Ahorn, Maple
@pardef FlagSwitchGate(x1::Integer, y1::Integer, x2::Integer=x1+16, y2::Integer=y1, width::Integer=Maple.defaultBlockWidth, height::Integer=Maple.defaultBlockHeight,
sprite::String="block", persistent::Bool=false, flag::String="flag_touch_switch", icon::String="vanilla", inactiveColor::String="5FCDE4", activeColor::String="FFFFFF", finishColor::String="F141DF",
shakeTime::Number=0.5, moveTime::Number=1.8, moveSpeed::Number=60.0, moveEased::Bool=true, allowReturn::Bool=false, moveSound::String="event:/game/general/touchswitch_gate_open", finishedSound::String="event:/game/general/touchswitch_gate_finish",
smoke::Bool=true, surfaceIndex::Int16=convert(Int16, 8), particles::Bool=true, speedMode::Bool=false) =
smoke::Bool=true, surfaceIndex::Int16=convert(Int16, 8), particles::Bool=true, speedMode::Bool=false, moveImmediately::Bool=false) =
Entity("MaxHelpingHand/FlagSwitchGate", x=x1, y=y1, nodes=Tuple{Int, Int}[(x2, y2)], width=width, height=height, sprite=sprite, persistent=persistent, flag=flag, icon=icon,
inactiveColor=inactiveColor, activeColor=activeColor, finishColor=finishColor, shakeTime=shakeTime, moveTime=moveTime, moveSpeed=moveSpeed, moveEased=moveEased, allowReturn=allowReturn, moveSound=moveSound, finishedSound=finishedSound,
smoke=smoke, surfaceIndex=surfaceIndex, particles=particles, speedMode=speedMode)
smoke=smoke, surfaceIndex=surfaceIndex, particles=particles, speedMode=speedMode, moveImmediately=moveImmediately)

function gateFinalizer(entity)
x, y = Ahorn.position(entity)
Expand Down
1 change: 1 addition & 0 deletions Ahorn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.surfaceIndex=Footstep
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.particles=Whether the switch gate should emit particles while it is moving.
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.speedMode=Allows defining move speed, instead of move time.\nFor this change to apply, you must reopen the edit window.
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.moveSpeed=The speed (in pixels per second) the block travels at, if Speed Mode is checked.
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.moveImmediately=Whether the block should move right when it is activated, ignoring the "Move Time" / "Move Speed" fields.

# Shatter Flag Switch Gate
placements.entities.MaxHelpingHand/ShatterFlagSwitchGate.tooltips.flag=The session flag this switch gate reacts to. Give the same to multiple touch switches and switch gates to group them.
Expand Down
8 changes: 5 additions & 3 deletions Entities/FlagSwitchGate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class FlagSwitchGate : Solid {
private readonly float moveSpeed;
private readonly bool moveEased;
private readonly bool speedMode;
private readonly bool moveImmediately;

private readonly string moveSound;
private readonly string finishedSound;
Expand Down Expand Up @@ -82,6 +83,7 @@ public FlagSwitchGate(EntityData data, Vector2 offset)
moveSpeed = data.Float("moveSpeed", 60.0f);
moveEased = data.Bool("moveEased", true);
speedMode = data.Bool("speedMode", false);
moveImmediately = data.Bool("moveImmediately", false);

moveSound = data.Attr("moveSound", "event:/game/general/touchswitch_gate_open");
finishedSound = data.Attr("finishedSound", "event:/game/general/touchswitch_gate_finish");
Expand Down Expand Up @@ -247,12 +249,12 @@ private IEnumerator moveSequence(Vector2 node, bool goingBack) {
}
}

yield return 0.1f;
if (!moveImmediately) yield return 0.1f;
if (shouldCancelMove(goingBack)) yield break;

// animate the icon
openSfx.Play(moveSound);
if (shakeTime > 0f) {
if (shakeTime > 0f && !moveImmediately) {
StartShaking(shakeTime);
while (icon.Rate < 1f) {
icon.Color = Color.Lerp(fromColor, activeColor, icon.Rate);
Expand All @@ -264,7 +266,7 @@ private IEnumerator moveSequence(Vector2 node, bool goingBack) {
icon.Rate = 1f;
}

yield return 0.1f;
if (!moveImmediately) yield return 0.1f;
if (shouldCancelMove(goingBack)) yield break;

// move the switch gate, emitting particles along the way if particles is true
Expand Down
3 changes: 2 additions & 1 deletion Loenn/entities/flagSwitchGate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ for i, texture in ipairs(textures) do
surfaceIndex = 8,
particles = true,
speedMode = false,
moveSpeed = 60
moveSpeed = 60,
moveImmediately = false
}
}
end
Expand Down
1 change: 1 addition & 0 deletions Loenn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ entities.MaxHelpingHand/FlagSwitchGate.attributes.description.surfaceIndex=Foots
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.particles=Whether the switch gate should emit particles while it is moving.
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.speedMode=Allows defining move speed, instead of move time.\nFor this change to apply, you must reopen the edit window.
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.moveSpeed=The speed (in pixels per second) the block travels at.
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.moveImmediately=Whether the block should move right when it is activated, ignoring the "Move Time" / "Move Speed" fields.

# Flag Touch Switch
entities.MaxHelpingHand/FlagTouchSwitch.placements.name.touch_switch=Flag Touch Switch
Expand Down

0 comments on commit 4824d08

Please sign in to comment.