Skip to content

Commit 47bfddc

Browse files
committed
Merge branch 'master' into no_dash_refill_spring
2 parents f9f2952 + 2e7122d commit 47bfddc

14 files changed

+813
-21
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
module SpringCollab2020GroupedTriggerSpikes
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Entity "SpringCollab2020/GroupedTriggerSpikesUp" GroupedTriggerSpikesUp(x::Integer, y::Integer, width::Integer=Maple.defaultSpikeWidth, type::String="default")
6+
@mapdef Entity "SpringCollab2020/GroupedTriggerSpikesDown" GroupedTriggerSpikesDown(x::Integer, y::Integer, width::Integer=Maple.defaultSpikeWidth, type::String="default")
7+
@mapdef Entity "SpringCollab2020/GroupedTriggerSpikesLeft" GroupedTriggerSpikesLeft(x::Integer, y::Integer, height::Integer=Maple.defaultSpikeHeight, type::String="default")
8+
@mapdef Entity "SpringCollab2020/GroupedTriggerSpikesRight" GroupedTriggerSpikesRight(x::Integer, y::Integer, height::Integer=Maple.defaultSpikeHeight, type::String="default")
9+
10+
const placements = Ahorn.PlacementDict()
11+
12+
groupedTriggerSpikes = Dict{String, Type}(
13+
"up" => GroupedTriggerSpikesUp,
14+
"down" => GroupedTriggerSpikesDown,
15+
"left" => GroupedTriggerSpikesLeft,
16+
"right" => GroupedTriggerSpikesRight
17+
)
18+
19+
groupedTriggerSpikesUnion = Union{GroupedTriggerSpikesUp, GroupedTriggerSpikesDown, GroupedTriggerSpikesLeft, GroupedTriggerSpikesRight}
20+
21+
for variant in Maple.spike_types
22+
if variant != "tentacles"
23+
for (dir, entity) in groupedTriggerSpikes
24+
key = "Grouped Trigger Spikes ($(uppercasefirst(dir)), $(uppercasefirst(variant))) (Spring Collab 2020)"
25+
placements[key] = Ahorn.EntityPlacement(
26+
entity,
27+
"rectangle",
28+
Dict{String, Any}(
29+
"type" => variant
30+
)
31+
)
32+
end
33+
end
34+
end
35+
36+
Ahorn.editingOptions(entity::groupedTriggerSpikesUnion) = Dict{String, Any}(
37+
"type" => String[variant for variant in Maple.spike_types if variant != "tentacles"]
38+
)
39+
40+
directions = Dict{String, String}(
41+
"SpringCollab2020/GroupedTriggerSpikesUp" => "up",
42+
"SpringCollab2020/GroupedTriggerSpikesDown" => "down",
43+
"SpringCollab2020/GroupedTriggerSpikesLeft" => "left",
44+
"SpringCollab2020/GroupedTriggerSpikesRight" => "right",
45+
)
46+
47+
offsets = Dict{String, Tuple{Integer, Integer}}(
48+
"up" => (4, -4),
49+
"down" => (4, 4),
50+
"left" => (-4, 4),
51+
"right" => (4, 4),
52+
)
53+
54+
groupedTriggerSpikesOffsets = Dict{String, Tuple{Integer, Integer}}(
55+
"up" => (0, 5),
56+
"down" => (0, -4),
57+
"left" => (5, 0),
58+
"right" => (-4, 0),
59+
)
60+
61+
rotations = Dict{String, Number}(
62+
"up" => 0,
63+
"right" => pi / 2,
64+
"down" => pi,
65+
"left" => pi * 3 / 2
66+
)
67+
68+
resizeDirections = Dict{String, Tuple{Bool, Bool}}(
69+
"up" => (true, false),
70+
"down" => (true, false),
71+
"left" => (false, true),
72+
"right" => (false, true),
73+
)
74+
75+
function Ahorn.renderSelectedAbs(ctx::Ahorn.Cairo.CairoContext, entity::groupedTriggerSpikesUnion)
76+
direction = get(directions, entity.name, "up")
77+
theta = rotations[direction] - pi / 2
78+
79+
width = Int(get(entity.data, "width", 0))
80+
height = Int(get(entity.data, "height", 0))
81+
82+
x, y = Ahorn.position(entity)
83+
cx, cy = x + floor(Int, width / 2) - 8 * (direction == "left"), y + floor(Int, height / 2) - 8 * (direction == "up")
84+
85+
Ahorn.drawArrow(ctx, cx, cy, cx + cos(theta) * 24, cy + sin(theta) * 24, Ahorn.colors.selection_selected_fc, headLength=6)
86+
end
87+
88+
function Ahorn.selection(entity::groupedTriggerSpikesUnion)
89+
if haskey(directions, entity.name)
90+
x, y = Ahorn.position(entity)
91+
92+
width = Int(get(entity.data, "width", 8))
93+
height = Int(get(entity.data, "height", 8))
94+
95+
direction = get(directions, entity.name, "up")
96+
97+
ox, oy = offsets[direction]
98+
99+
return Ahorn.Rectangle(x + ox - 4, y + oy - 4, width, height)
100+
end
101+
end
102+
103+
Ahorn.minimumSize(entity::groupedTriggerSpikesUnion) = 8, 8
104+
105+
function Ahorn.resizable(entity::groupedTriggerSpikesUnion)
106+
if haskey(directions, entity.name)
107+
direction = get(directions, entity.name, "up")
108+
109+
return resizeDirections[direction]
110+
end
111+
end
112+
113+
function Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::groupedTriggerSpikesUnion)
114+
if haskey(directions, entity.name)
115+
variant = get(entity.data, "type", "default")
116+
direction = get(directions, entity.name, "up")
117+
groupedTriggerSpikesOffset = groupedTriggerSpikesOffsets[direction]
118+
119+
width = get(entity.data, "width", 8)
120+
height = get(entity.data, "height", 8)
121+
122+
for ox in 0:8:width - 8, oy in 0:8:height - 8
123+
drawX, drawY = (ox, oy) .+ offsets[direction] .+ groupedTriggerSpikesOffset
124+
Ahorn.drawSprite(ctx, "danger/spikes/$(variant)_$(direction)00", drawX, drawY)
125+
end
126+
end
127+
end
128+
129+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module SpringCollab2020InstantFallingBlock
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Entity "SpringCollab2020/InstantFallingBlock" InstantFallingBlock(x::Integer, y::Integer, width::Integer=Maple.defaultBlockWidth, height::Integer=Maple.defaultBlockHeight,
6+
tiletype::String="3", climbFall::Bool=true, behind::Bool=false)
7+
8+
const placements = Ahorn.PlacementDict(
9+
"Instant Falling Block (Spring Collab 2020)" => Ahorn.EntityPlacement(
10+
InstantFallingBlock,
11+
"rectangle",
12+
Dict{String, Any}(),
13+
Ahorn.tileEntityFinalizer
14+
),
15+
)
16+
17+
Ahorn.editingOptions(entity::InstantFallingBlock) = Dict{String, Any}(
18+
"tiletype" => Ahorn.tiletypeEditingOptions()
19+
)
20+
21+
Ahorn.minimumSize(entity::InstantFallingBlock) = 8, 8
22+
Ahorn.resizable(entity::InstantFallingBlock) = true, true
23+
24+
Ahorn.selection(entity::InstantFallingBlock) = Ahorn.getEntityRectangle(entity)
25+
26+
Ahorn.renderAbs(ctx::Ahorn.Cairo.CairoContext, entity::InstantFallingBlock, room::Maple.Room) = Ahorn.drawTileEntity(ctx, room, entity)
27+
28+
end
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
module SpringCollab2020MoveBlockCustomSpeed
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Entity "SpringCollab2020/MoveBlockCustomSpeed" MoveBlockCustomSpeed(x::Integer, y::Integer, width::Integer=Maple.defaultBlockWidth, height::Integer=Maple.defaultBlockHeight,
6+
direction::String="Up", canSteer::Bool=false, moveSpeed::Number=60)
7+
8+
const placements = Ahorn.PlacementDict()
9+
10+
buttonColor = (71, 64, 112, 255) ./ 255
11+
12+
directions = Maple.move_block_directions
13+
for direction in directions, steerable in false:true
14+
key = "Move Block ($(uppercasefirst(direction)), Custom Speed$(steerable ? ", Steerable" : "")) (Spring Collab 2020)"
15+
placements[key] = Ahorn.EntityPlacement(
16+
MoveBlockCustomSpeed,
17+
"rectangle",
18+
Dict{String, Any}(
19+
"canSteer" => steerable,
20+
"direction" => direction
21+
)
22+
)
23+
end
24+
25+
Ahorn.editingOptions(entity::MoveBlockCustomSpeed) = Dict{String, Any}(
26+
"direction" => Maple.move_block_directions
27+
)
28+
Ahorn.minimumSize(entity::MoveBlockCustomSpeed) = 16, 16
29+
Ahorn.resizable(entity::MoveBlockCustomSpeed) = true, true
30+
31+
Ahorn.selection(entity::MoveBlockCustomSpeed) = Ahorn.getEntityRectangle(entity)
32+
33+
midColor = (4, 3, 23) ./ 255
34+
highlightColor = (59, 50, 101) ./ 255
35+
36+
arrows = Dict{String, String}(
37+
"up" => "objects/moveBlock/arrow02",
38+
"left" => "objects/moveBlock/arrow04",
39+
"right" => "objects/moveBlock/arrow00",
40+
"down" => "objects/moveBlock/arrow06",
41+
)
42+
43+
button = "objects/moveBlock/button"
44+
45+
function Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::MoveBlockCustomSpeed, room::Maple.Room)
46+
x = Int(get(entity.data, "x", 0))
47+
y = Int(get(entity.data, "y", 0))
48+
49+
50+
width = Int(get(entity.data, "width", 32))
51+
height = Int(get(entity.data, "height", 32))
52+
53+
tilesWidth = div(width, 8)
54+
tilesHeight = div(height, 8)
55+
56+
canSteer = get(entity.data, "canSteer", false)
57+
direction = lowercase(get(entity.data, "direction", "up"))
58+
arrowSprite = Ahorn.getSprite(arrows[lowercase(direction)], "Gameplay")
59+
60+
frame = "objects/moveBlock/base"
61+
if canSteer
62+
if direction == "up" || direction == "down"
63+
frame = "objects/moveBlock/base_v"
64+
65+
else
66+
frame = "objects/moveBlock/base_h"
67+
end
68+
end
69+
70+
Ahorn.drawRectangle(ctx, 2, 2, width - 4, height - 4, highlightColor, highlightColor)
71+
Ahorn.drawRectangle(ctx, 8, 8, width - 16, height - 16, midColor)
72+
73+
for i in 2:tilesWidth - 1
74+
Ahorn.drawImage(ctx, frame, (i - 1) * 8, 0, 8, 0, 8, 8)
75+
Ahorn.drawImage(ctx, frame, (i - 1) * 8, height - 8, 8, 16, 8, 8)
76+
77+
if canSteer && (direction != "up" && direction != "down")
78+
Ahorn.drawImage(ctx, button, (i - 1) * 8, -2, 6, 0, 8, 6, tint=buttonColor)
79+
end
80+
end
81+
82+
for i in 2:tilesHeight - 1
83+
Ahorn.drawImage(ctx, frame, 0, (i - 1) * 8, 0, 8, 8, 8)
84+
Ahorn.drawImage(ctx, frame, width - 8, (i - 1) * 8, 16, 8, 8, 8)
85+
86+
if canSteer && (direction == "up" || direction == "down")
87+
Ahorn.Cairo.save(ctx)
88+
89+
Ahorn.rotate(ctx, -pi / 2)
90+
Ahorn.drawImage(ctx, button, i * 8 - height - 8, -2, 6, 0, 8, 6, tint=buttonColor)
91+
Ahorn.scale(ctx, 1, -1)
92+
Ahorn.drawImage(ctx, button, i * 8 - height - 8, -2 - width, 6, 0, 8, 6, tint=buttonColor)
93+
94+
Ahorn.Cairo.restore(ctx)
95+
end
96+
end
97+
98+
Ahorn.drawImage(ctx, frame, 0, 0, 0, 0, 8, 8)
99+
Ahorn.drawImage(ctx, frame, width - 8, 0, 16, 0, 8, 8)
100+
Ahorn.drawImage(ctx, frame, 0, height - 8, 0, 16, 8, 8)
101+
Ahorn.drawImage(ctx, frame, width - 8, height - 8, 16, 16, 8, 8)
102+
103+
if canSteer && (direction != "up" && direction != "down")
104+
Ahorn.Cairo.save(ctx)
105+
106+
Ahorn.drawImage(ctx, button, 2, -2, 0, 0, 6, 6, tint=buttonColor)
107+
Ahorn.scale(ctx, -1, 1)
108+
Ahorn.drawImage(ctx, button, 2 - width, -2, 0, 0, 6, 6, tint=buttonColor)
109+
110+
Ahorn.Cairo.restore(ctx)
111+
end
112+
113+
if canSteer && (direction == "up" || direction == "down")
114+
Ahorn.Cairo.save(ctx)
115+
116+
Ahorn.rotate(ctx, -pi / 2)
117+
Ahorn.drawImage(ctx, button, -height + 2, -2, 0, 0, 8, 6, tint=buttonColor)
118+
Ahorn.drawImage(ctx, button, -10, -2, 14, 0, 8, 6, tint=buttonColor)
119+
Ahorn.scale(ctx, 1, -1)
120+
Ahorn.drawImage(ctx, button, -height + 2, -2 -width, 0, 0, 8, 6, tint=buttonColor)
121+
Ahorn.drawImage(ctx, button, -10, -2 -width, 14, 0, 8, 6, tint=buttonColor)
122+
123+
Ahorn.Cairo.restore(ctx)
124+
end
125+
126+
Ahorn.drawRectangle(ctx, div(width - arrowSprite.width, 2) + 1, div(height - arrowSprite.height, 2) + 1, 8, 8, highlightColor, highlightColor)
127+
Ahorn.drawImage(ctx, arrowSprite, div(width - arrowSprite.width, 2), div(height - arrowSprite.height, 2))
128+
end
129+
130+
end

Ahorn/lang/en_gb.lang

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,23 @@ placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.persistent=If enabl
8989
placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.inactiveColor=The gate icon colour when not triggered yet.
9090
placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.activeColor=The gate icon colour when triggered, but the group is not complete yet.
9191
placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.finishColor=The gate icon colour when the group is complete.
92-
placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.sprite=The texture for the gate block.
92+
placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.sprite=The texture for the gate block.
93+
94+
# Instant Falling Block
95+
placements.entities.SpringCollab2020/InstantFallingBlock.tooltips.climbFall=After a delay, the block will physically fall down until it comes into contact with another block.
96+
placements.entities.SpringCollab2020/InstantFallingBlock.tooltips.tiletype=Changes the visual appearance of the falling block.
97+
placements.entities.SpringCollab2020/InstantFallingBlock.tooltips.behind=Whether the block should visually be further behind in the scene or not.
98+
99+
# Grouped Trigger Spikes
100+
placements.entities.SpringCollab2020/GroupedTriggerSpikesUp.tooltips.type=Changes the visual appearance of the spikes.
101+
placements.entities.SpringCollab2020/GroupedTriggerSpikesDown.tooltips.type=Changes the visual appearance of the spikes.
102+
placements.entities.SpringCollab2020/GroupedTriggerSpikesLeft.tooltips.type=Changes the visual appearance of the spikes.
103+
placements.entities.SpringCollab2020/GroupedTriggerSpikesRight.tooltips.type=Changes the visual appearance of the spikes.
104+
105+
# Move Block with Customizable Speed
106+
placements.entities.SpringCollab2020/MoveBlockCustomSpeed.tooltips.canSteer=Determines whether the move block can be moved by the player.
107+
placements.entities.SpringCollab2020/MoveBlockCustomSpeed.tooltips.direction=Determines the direction the move block moves in upon activation.
108+
placements.entities.SpringCollab2020/MoveBlockCustomSpeed.tooltips.moveSpeed=The block speed, in pixels per second. Vanilla speeds are 60 for "slow", 75 for "fast".
109+
110+
# Disable Ice Physics Trigger
111+
placements.triggers.SpringCollab2020/DisableIcePhysicsTrigger.tooltips.disableIcePhysics=Check to disable ice physics when entering the trigger. Uncheck to enable them again.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module SpringCollab2020DisableIcePhysicsTrigger
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Trigger "SpringCollab2020/DisableIcePhysicsTrigger" DisableIcePhysicsTrigger(x::Integer, y::Integer,
6+
width::Integer=Maple.defaultTriggerWidth, height::Integer=Maple.defaultTriggerHeight, disableIcePhysics::Bool=true)
7+
8+
const placements = Ahorn.PlacementDict(
9+
"Disable Ice Physics (Spring Collab 2020)" => Ahorn.EntityPlacement(
10+
DisableIcePhysicsTrigger,
11+
"rectangle"
12+
)
13+
)
14+
15+
end

Entities/CaveWall.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,32 @@ private void OnTransitionOut(float percent) {
163163
}
164164

165165
private void OnTransitionInBegin() {
166-
Level level = SceneAs<Level>();
167-
if (level.PreviousBounds.HasValue && Collide.CheckRect(this, level.PreviousBounds.Value)) {
168-
transitionFade = true;
169-
tiles.Alpha = 0f;
170-
} else {
171-
transitionFade = false;
166+
Level level = SceneAs<Level>();
167+
if (MasterOfGroup) {
168+
Player player = null;
169+
foreach (CaveWall entity in Group) {
170+
if (level.PreviousBounds.HasValue && Collide.CheckRect(entity, level.PreviousBounds.Value)) {
171+
entity.transitionFade = true;
172+
entity.tiles.Alpha = 0f;
173+
} else {
174+
entity.transitionFade = false;
175+
}
176+
player = entity.CollideFirst<Player>();
177+
if (player != null) {
178+
break;
179+
}
180+
}
181+
182+
if (player != null) {
183+
foreach (CaveWall entity in Group) {
184+
entity.transitionFade = false;
185+
entity.tiles.Alpha = 0f;
186+
}
187+
}
172188
}
173189
}
174190

175-
private void OnTransitionIn(float percent) {
191+
private void OnTransitionIn(float percent) {
176192
if (transitionFade) {
177193
tiles.Alpha = percent;
178194
}

0 commit comments

Comments
 (0)