Skip to content

Commit

Permalink
Merge pull request #28 from AdamKorinek/master
Browse files Browse the repository at this point in the history
Flag Switch Gate particles
  • Loading branch information
maddie480 authored Aug 15, 2024
2 parents ac76c05 + 1f0ef24 commit ee571bb
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 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, 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)) =
smoke::Bool=true, surfaceIndex::Int16=convert(Int16, 8), particles::Bool=true) =
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, moveEased=moveEased, allowReturn=allowReturn, moveSound=moveSound, finishedSound=finishedSound,
smoke=smoke, surfaceIndex=surfaceIndex)
smoke=smoke, surfaceIndex=surfaceIndex, particles=particles)

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 @@ -55,6 +55,7 @@ placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.moveSound=The sound p
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.finishedSound=The sound played by the gate when it is done moving.
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.smoke=Whether the switch gate should emit smoke when reaching its final position.
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.surfaceIndex=Footstep sound when walking on the switch gate.
placements.entities.MaxHelpingHand/FlagSwitchGate.tooltips.smoke=Whether the switch gate should emit particles while it is moving.

# 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
25 changes: 17 additions & 8 deletions Entities/FlagSwitchGate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class FlagSwitchGate : Solid {
private readonly string finishedSound;

private readonly bool smoke;
private readonly bool particles;

private readonly bool allowReturn;

Expand Down Expand Up @@ -82,6 +83,7 @@ public FlagSwitchGate(EntityData data, Vector2 offset)
finishedSound = data.Attr("finishedSound", "event:/game/general/touchswitch_gate_finish");

smoke = data.Bool("smoke", true);
particles = data.Bool("particles", true);

allowReturn = data.Bool("allowReturn", false);

Expand Down Expand Up @@ -266,14 +268,21 @@ private IEnumerator moveSequence(Vector2 node, bool goingBack) {
Tween tween = Tween.Create(Tween.TweenMode.Oneshot, moveEased ? Ease.CubeOut : null, moveTime + (moveEased ? 0.2f : 0f), start: true);
tween.OnUpdate = tweenArg => {
MoveTo(Vector2.Lerp(start, node, tweenArg.Eased));
if (Scene.OnInterval(0.1f)) {
particleAt++;
particleAt %= 2;
for (int tileX = 0; tileX < Width / 8f; tileX++) {
for (int tileY = 0; tileY < Height / 8f; tileY++) {
if ((tileX + tileY) % 2 == particleAt) {
SceneAs<Level>().ParticlesBG.Emit(SwitchGate.P_Behind,
Position + new Vector2(tileX * 8, tileY * 8) + Calc.Random.Range(Vector2.One * 2f, Vector2.One * 6f));
if (particles)
{
if (Scene.OnInterval(0.1f))
{
particleAt++;
particleAt %= 2;
for (int tileX = 0; tileX < Width / 8f; tileX++)
{
for (int tileY = 0; tileY < Height / 8f; tileY++)
{
if ((tileX + tileY) % 2 == particleAt)
{
SceneAs<Level>().ParticlesBG.Emit(SwitchGate.P_Behind,
Position + new Vector2(tileX * 8, tileY * 8) + Calc.Random.Range(Vector2.One * 2f, Vector2.One * 6f));
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions Loenn/entities/flagSwitchGate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ for i, texture in ipairs(textures) do
moveSound = "event:/game/general/touchswitch_gate_open",
finishedSound = "event:/game/general/touchswitch_gate_finish",
smoke = true,
surfaceIndex = 8
surfaceIndex = 8,
particles = true
}
}
end

switchGate.fieldOrder = {"x", "y", "width", "height", "flag", "inactiveColor", "activeColor", "finishColor", "hitSound", "moveSound", "finishedSound", "shakeTime", "moveTime"}
switchGate.fieldOrder = {"x", "y", "width", "height", "flag", "inactiveColor", "activeColor", "finishColor", "hitSound", "moveSound", "finishedSound", "shakeTime", "moveTime", "icon", "sprite", "surfaceIndex", "allowReturn", "moveEased", "persistent", "particles", "smoke"}

switchGate.fieldInformation = {
inactiveColor = {
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 @@ -211,6 +211,7 @@ entities.MaxHelpingHand/FlagSwitchGate.attributes.description.moveSound=The soun
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.finishedSound=The sound played by the gate when it is done moving.
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.smoke=Whether the switch gate should emit smoke when reaching its final position.
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.surfaceIndex=Footstep sound when walking on the switch gate.
entities.MaxHelpingHand/FlagSwitchGate.attributes.description.particles=Whether the switch gate should emit particles while it is moving.

# Flag Touch Switch
entities.MaxHelpingHand/FlagTouchSwitch.placements.name.touch_switch=Flag Touch Switch
Expand Down
2 changes: 1 addition & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The mod used to be known as "max480's Helping Hand", and wasn't renamed for compatibility reasons
- Name: MaxHelpingHand
Version: 1.31.0
Version: 1.31.1
DLL: bin/Release/net452/MaxHelpingHand.dll
Dependencies:
- Name: Everest
Expand Down

0 comments on commit ee571bb

Please sign in to comment.