Skip to content

Commit ada657b

Browse files
committed
Merge branch 'master' into grouped_trigger_spikes
2 parents f8dd6e9 + c6a4b8d commit ada657b

File tree

7 files changed

+119
-19
lines changed

7 files changed

+119
-19
lines changed
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ 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+
9499
# Grouped Trigger Spikes
95100
placements.entities.SpringCollab2020/GroupedTriggerSpikesUp.tooltips.type=Changes the visual appearance of the spikes.
96101
placements.entities.SpringCollab2020/GroupedTriggerSpikesDown.tooltips.type=Changes the visual appearance of the spikes.

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

Entities/InstantFallingBlock.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Celeste.Mod.Entities;
2+
using Microsoft.Xna.Framework;
3+
4+
namespace Celeste.Mod.SpringCollab2020.Entities {
5+
[CustomEntity("SpringCollab2020/InstantFallingBlock")]
6+
class InstantFallingBlock : FallingBlock {
7+
public InstantFallingBlock(EntityData data, Vector2 offset) : base(data, offset) {
8+
// this block starts triggered right away. that's about it.
9+
Triggered = true;
10+
}
11+
}
12+
}

Entities/UpsideDownJumpThru.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class UpsideDownJumpThru : JumpThru {
1717

1818
private static FieldInfo actorMovementCounter = typeof(Actor).GetField("movementCounter", BindingFlags.Instance | BindingFlags.NonPublic);
1919
private static FieldInfo playerVarJumpTimer = typeof(Player).GetField("varJumpTimer", BindingFlags.Instance | BindingFlags.NonPublic);
20+
private static FieldInfo playerOnCollideV = typeof(Player).GetField("onCollideV", BindingFlags.Instance | BindingFlags.NonPublic);
2021

2122
private static ILHook playerOrigUpdateHook;
2223

@@ -28,7 +29,7 @@ public static void Load() {
2829
}
2930

3031
// fix player specific behavior allowing them to go through upside-down jumpthrus.
31-
On.Celeste.Player.OnCollideV += onPlayerOnCollideV;
32+
On.Celeste.Player.ctor += onPlayerConstructor;
3233

3334
// block player if they try to climb past an upside-down jumpthru.
3435
IL.Celeste.Player.ClimbUpdate += patchPlayerClimbUpdate;
@@ -43,7 +44,7 @@ public static void Unload() {
4344
On.Celeste.Actor.MoveVExact -= onActorMoveVExact;
4445
On.Celeste.Platform.MoveVExactCollideSolids -= onPlatformMoveVExactCollideSolids;
4546

46-
On.Celeste.Player.OnCollideV -= onPlayerOnCollideV;
47+
On.Celeste.Player.ctor -= onPlayerConstructor;
4748
IL.Celeste.Player.ClimbUpdate -= patchPlayerClimbUpdate;
4849

4950
playerOrigUpdateHook?.Dispose();
@@ -164,19 +165,27 @@ private static bool onPlatformMoveVExactCollideSolids(On.Celeste.Platform.orig_M
164165
return platform != null;
165166
}
166167

167-
private static void onPlayerOnCollideV(On.Celeste.Player.orig_OnCollideV orig, Player self, CollisionData data) {
168-
// we just want to kill a piece of code that executes in these conditions (supposed to push the player left or right when hitting a wall angle).
169-
if (self.StateMachine.State != 19 && self.StateMachine.State != 3 && self.StateMachine.State != 9 && self.Speed.Y < 0
170-
&& self.CollideCheckOutside<UpsideDownJumpThru>(self.Position - Vector2.UnitY)) {
168+
private static void onPlayerConstructor(On.Celeste.Player.orig_ctor orig, Player self, Vector2 position, PlayerSpriteMode spriteMode) {
169+
orig(self, position, spriteMode);
171170

172-
// kill the player's vertical speed.
173-
self.Speed.Y = 0;
171+
Collision originalOnCollideV = (Collision) playerOnCollideV.GetValue(self);
174172

175-
// reset varJumpTimer to prevent a weird "stuck on ceiling" effect.
176-
playerVarJumpTimer.SetValue(self, 0);
177-
}
173+
Collision patchedOnCollideV = collisionData => {
174+
// we just want to kill a piece of code that executes in these conditions (supposed to push the player left or right when hitting a wall angle).
175+
if (self.StateMachine.State != 19 && self.StateMachine.State != 3 && self.StateMachine.State != 9 && self.Speed.Y < 0
176+
&& self.CollideCheckOutside<UpsideDownJumpThru>(self.Position - Vector2.UnitY)) {
177+
178+
// kill the player's vertical speed.
179+
self.Speed.Y = 0;
180+
181+
// reset varJumpTimer to prevent a weird "stuck on ceiling" effect.
182+
playerVarJumpTimer.SetValue(self, 0);
183+
}
184+
185+
originalOnCollideV(collisionData);
186+
};
178187

179-
orig(self, data);
188+
playerOnCollideV.SetValue(self, patchedOnCollideV);
180189
}
181190

182191
private static void filterOutJumpThrusFromCollideChecks(ILContext il) {

SpringCollab2020Module.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public override void Load() {
2121
BubbleReturnBerry.Load();
2222
SidewaysJumpThru.Load();
2323
CrystalBombDetonatorRenderer.Load();
24+
FlagTouchSwitch.Load();
2425
}
2526

2627
public override void LoadContent(bool firstLoad) {
@@ -40,6 +41,7 @@ public override void Unload() {
4041
BubbleReturnBerry.Unload();
4142
SidewaysJumpThru.Unload();
4243
CrystalBombDetonatorRenderer.Unload();
44+
FlagTouchSwitch.Unload();
4345
}
4446

4547
public override void PrepareMapDataProcessors(MapDataFixup context) {

0 commit comments

Comments
 (0)