Skip to content

Commit

Permalink
Hijack Commands.Render to display the absolute cursor world pos
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0ade committed Dec 5, 2018
1 parent cd464b8 commit aadb72c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CelesteTAS-EverestInterop/CelesteTASModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Monocle;
using MonoMod;
using MonoMod.RuntimeDetour;
using MonoMod.RuntimeDetour.HookGen;
using MonoMod.Utils;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -196,6 +197,9 @@ public override void Load() {
// Optional: Disable achievements, stats and terminal.
On.Celeste.Achievements.Register += Achievements_Register;
On.Celeste.Stats.Increment += Stats_Increment;

// Forced: Add more positions to top-left positioning helper.
IL.Monocle.Commands.Render += Commands_Render;
}

public override void Unload() {
Expand Down Expand Up @@ -352,5 +356,22 @@ public static void Stats_Increment(On.Celeste.Stats.orig_Increment orig, Stat st
orig(stat, increment);
}

public static void Commands_Render(HookIL il) {
il.At(0).FindNext(out HookILCursor[] found,
i => i.MatchLdstr("\n level: {0}, {1}"),
i => i.MatchCall(typeof(string), "Format")
);
HookILCursor format = found[1];
format.Remove();
format.EmitDelegate<Func<string, object, object, string>>((text, xObj, yObj) => {
int x = (int) xObj;
int y = (int) yObj;
Level level = Engine.Scene as Level;
return
$"\n world: {(int) Math.Round(x + level.LevelOffset.X)}, {(int) Math.Round(y + level.LevelOffset.Y)}" +
$"\n level: {x}, {y}";
});
}

}
}

0 comments on commit aadb72c

Please sign in to comment.