-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Mini Heart Door Unfix Controller from FLCC
- Loading branch information
Showing
6 changed files
with
2,532 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
Ahorn/entities/maxHelpingHandMiniHeartDoorUnfixController.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module MaxHelpingHandMiniHeartDoorUnfixController | ||
|
||
using ..Ahorn, Maple | ||
|
||
@mapdef Entity "MaxHelpingHand/MiniHeartDoorUnfixController" MiniHeartDoorUnfixController(x::Integer, y::Integer) | ||
|
||
const placements = Ahorn.PlacementDict( | ||
"Mini Heart Door Unfix Controller (Maddie's Helping Hand)" => Ahorn.EntityPlacement( | ||
MiniHeartDoorUnfixController | ||
) | ||
) | ||
|
||
function Ahorn.selection(entity::MiniHeartDoorUnfixController) | ||
x, y = Ahorn.position(entity) | ||
|
||
return Ahorn.Rectangle(x - 12, y - 12, 24, 24) | ||
end | ||
|
||
Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::MiniHeartDoorUnfixController, room::Maple.Room) = Ahorn.drawImage(ctx, "ahorn/miniheartdoorunfix", -12, -12) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Celeste; | ||
using Celeste.Mod.Entities; | ||
using Microsoft.Xna.Framework; | ||
using Mono.Cecil.Cil; | ||
using Monocle; | ||
using MonoMod.Cil; | ||
using MonoMod.RuntimeDetour; | ||
|
||
namespace Celeste.Mod.MaxHelpingHand.Entities { | ||
// This controller reverts this fix, and was made to fix a map from Etpio in FLCC: https://github.com/EverestAPI/CelesteCollabUtils2/pull/60 | ||
[CustomEntity("MaxHelpingHand/MiniHeartDoorUnfixController")] | ||
[Tracked] | ||
class MiniHeartDoorUnfixController : Entity { | ||
private static ILHook miniHeartDoorHook = null; | ||
|
||
public static void Initialize() { | ||
if (miniHeartDoorHook != null) return; | ||
|
||
Type miniHeartDoorClass = Everest.Modules.FirstOrDefault(module => module.GetType().ToString() == "Celeste.Mod.CollabUtils2.CollabModule")?.GetType().Assembly | ||
Check failure on line 19 in Entities/MiniHeartDoorUnfixController.cs GitHub Actions / build
Check failure on line 19 in Entities/MiniHeartDoorUnfixController.cs GitHub Actions / build
|
||
.GetType("Celeste.Mod.CollabUtils2.Entities.MiniHeartDoor"); | ||
|
||
if (miniHeartDoorClass != null) { | ||
miniHeartDoorHook = new ILHook(miniHeartDoorClass.GetMethod("Update"), modMiniHeartDoorUpdate); | ||
} | ||
} | ||
|
||
public static void Unload() { | ||
miniHeartDoorHook?.Dispose(); | ||
miniHeartDoorHook = null; | ||
} | ||
|
||
private static void modMiniHeartDoorUpdate(ILContext il) { | ||
ILCursor cursor = new ILCursor(il); | ||
|
||
while(cursor.TryGotoNext(MoveType.After, instr => instr.MatchCall<HeartGemDoor>("get_Opened"))) { | ||
cursor.Emit(OpCodes.Ldarg_0); | ||
cursor.EmitDelegate<Func<bool, HeartGemDoor, bool>>((orig, self) => { | ||
if (self.Scene.Tracker.CountEntities<MiniHeartDoorUnfixController>() > 0) { | ||
// this condition wasn't here before the fix, so we want to make it true! | ||
return true; | ||
} | ||
return orig; | ||
}); | ||
} | ||
} | ||
|
||
public MiniHeartDoorUnfixController(EntityData data, Vector2 offset) : base(data.Position + offset) { } | ||
} | ||
} |
Oops, something went wrong.