Skip to content

Commit

Permalink
Add new binds for Portal Maker and hunter admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed Nov 4, 2022
1 parent 43d9c03 commit 542db91
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ public static void Postfix(HudManager __instance)
Portalmaker.getUsePortalButtonSprite(),
new Vector3(0.9f, -0.06f, 0),
__instance,
KeyCode.H,
"UsePortal",
mirror: true
);

Expand Down Expand Up @@ -1752,7 +1752,7 @@ public static void Postfix(HudManager __instance)
Hacker.getAdminSprite(),
new Vector3(-2.7f, -0.06f, 0),
__instance,
KeyCode.G,
"HunterAdmin",
true,
Hunter.AdminDuration,
() => {
Expand Down
43 changes: 43 additions & 0 deletions TheOtherRoles/Patches/ControllerPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using HarmonyLib;
using Il2CppSystem.Collections;
using Rewired;
using Rewired.Data;
using UnityEngine;

namespace TheOtherRoles.Patches;

[HarmonyPatch(typeof(InputManager_Base), nameof(InputManager_Base.Awake))]
static class ControllerPatch
{
private static void Prefix(InputManager_Base __instance)
{
__instance.userData.RegisterBind("HunterAdmin", "Hunter admin button", KeyboardKeyCode.G);
__instance.userData.RegisterBind("UsePortal", "Use a portal", KeyboardKeyCode.H);
}
private static int RegisterBind(this UserData self, string name, string description, KeyboardKeyCode keycode, int elementIdentifierId = -1, int category = 0, InputActionType type = InputActionType.Button)
{
self.AddAction(category);
var action = self.GetAction(self.actions.Count - 1)!;

action.name = name;
action.descriptiveName = description;
action.categoryId = category;
action.type = type;
action.userAssignable = true;

var a = new ActionElementMap();
a._elementIdentifierId = elementIdentifierId;
a._actionId = action.id;
a._elementType = ControllerElementType.Button;
a._axisContribution = Pole.Positive;
a._keyboardKeyCode = keycode;
a._modifierKey1 = ModifierKey.None;
a._modifierKey2 = ModifierKey.None;
a._modifierKey3 = ModifierKey.None;
self.keyboardMaps[0].actionElementMaps.Add(a);
self.joystickMaps[0].actionElementMaps.Add(a);

return action.id;
}
}

0 comments on commit 542db91

Please sign in to comment.