Skip to content

Commit 58ac13f

Browse files
committed
Merge branch 'master' into custom_speed_move_block
2 parents df62d1d + f4fb8f7 commit 58ac13f

File tree

9 files changed

+549
-20
lines changed

9 files changed

+549
-20
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

Ahorn/lang/en_gb.lang

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,18 @@ placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.activeColor=The gat
9191
placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.finishColor=The gate icon colour when the group is complete.
9292
placements.entities.SpringCollab2020/FlagSwitchGate.tooltips.sprite=The texture for the gate block.
9393

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+
94105
# Move Block with Customizable Speed
95106
placements.entities.SpringCollab2020/MoveBlockCustomSpeed.tooltips.canSteer=Determines whether the move block can be moved by the player.
96107
placements.entities.SpringCollab2020/MoveBlockCustomSpeed.tooltips.direction=Determines the direction the move block moves in upon activation.
97-
placements.entities.SpringCollab2020/MoveBlockCustomSpeed.tooltips.moveSpeed=The block speed, in pixels per second. Vanilla speeds are 60 for "slow", 75 for "fast".
108+
placements.entities.SpringCollab2020/MoveBlockCustomSpeed.tooltips.moveSpeed=The block speed, in pixels per second. Vanilla speeds are 60 for "slow", 75 for "fast".

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
}

Entities/FlagTouchSwitch.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
using Microsoft.Xna.Framework;
33
using Monocle;
44
using System;
5+
using System.Collections;
56
using System.Collections.Generic;
67
using System.Linq;
8+
using System.Reflection;
79
using System.Text;
810
using System.Threading.Tasks;
911

@@ -20,6 +22,32 @@ namespace Celeste.Mod.SpringCollab2020.Entities {
2022
[CustomEntity("SpringCollab2020/FlagTouchSwitch")]
2123
[Tracked]
2224
class FlagTouchSwitch : Entity {
25+
private static FieldInfo seekerPushRadius = typeof(Seeker).GetField("pushRadius", BindingFlags.NonPublic | BindingFlags.Instance);
26+
private static FieldInfo seekerPhysicsHitbox = typeof(Seeker).GetField("physicsHitbox", BindingFlags.NonPublic | BindingFlags.Instance);
27+
28+
public static void Load() {
29+
On.Celeste.Seeker.RegenerateCoroutine += onSeekerRegenerateCoroutine;
30+
}
31+
32+
public static void Unload() {
33+
On.Celeste.Seeker.RegenerateCoroutine -= onSeekerRegenerateCoroutine;
34+
}
35+
36+
private static IEnumerator onSeekerRegenerateCoroutine(On.Celeste.Seeker.orig_RegenerateCoroutine orig, Seeker self) {
37+
IEnumerator origEnum = orig(self);
38+
while (origEnum.MoveNext()) {
39+
yield return origEnum.Current;
40+
}
41+
42+
// make the seeker check for flag touch switches as well.
43+
self.Collider = (Collider) seekerPushRadius.GetValue(self);
44+
foreach (FlagTouchSwitch touchSwitch in self.Scene.Tracker.GetEntities<FlagTouchSwitch>()) {
45+
if (self.CollideCheck(touchSwitch)) {
46+
touchSwitch.turnOn();
47+
}
48+
}
49+
self.Collider = (Collider) seekerPhysicsHitbox.GetValue(self);
50+
}
2351

2452
private ParticleType P_RecoloredFire;
2553

0 commit comments

Comments
 (0)