Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
add respawn keybind setting
Browse files Browse the repository at this point in the history
  • Loading branch information
cgytrus committed Sep 21, 2022
1 parent fa76850 commit 878aefa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ThreeDashTools/src/Patches/Keybinds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ namespace ThreeDashTools.Patches;
public class Keybinds : IPatch {
private ConfigEntry<KeyboardShortcut> _placeCheckpoint;
private ConfigEntry<KeyboardShortcut> _removeCheckpoint;
private ConfigEntry<KeyboardShortcut> _respawn;

public Keybinds() {
ConfigFile config = Plugin.instance!.Config;
_placeCheckpoint = config.Bind("Keybinds", "PlaceCheckpoint", new KeyboardShortcut(KeyCode.Z), "");
_removeCheckpoint = config.Bind("Keybinds", "RemoveCheckpoint", new KeyboardShortcut(KeyCode.X), "");
_respawn = config.Bind("Keybinds", "Respawn", new KeyboardShortcut(KeyCode.Backspace), "");
}

public void Apply() {
Expand All @@ -38,6 +40,13 @@ public void Apply() {
cursor.RemoveRange(2);
EmitIsDown(cursor, nameof(_removeCheckpoint));
};

IL.PlayerScript.Update += il => {
ILCursor cursor = new(il);
cursor.GotoNext(code => code.MatchLdcI4((sbyte)KeyCode.Backspace));
cursor.RemoveRange(2);
EmitIsDown(cursor, nameof(_respawn));
};
}

private void EmitIsDown(ILCursor cursor, string entry) {
Expand Down

0 comments on commit 878aefa

Please sign in to comment.