a
Created
March 12, 2021 17:23
-
-
Save Pandapip1/f52500da0272e6bd2acc67ac7a6debf8 to your computer and use it in GitHub Desktop.
Better RPC (with example)
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
public static class BetterRPC | |
{ | |
} |
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
using Reactor.Extensions; | |
using Reactor.Unstrip; | |
using Reactor.BetterRPC; | |
using UnityEngine; | |
using HarmonyLib; | |
namespace YourCoolMod | |
{ | |
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Start))] | |
public static class ExampleButton | |
{ | |
private static CooldownButton btn; | |
public static void Postfix(HudManager __instance) | |
{ | |
btn = new CooldownButton( | |
() => | |
{ | |
// Do cool stuff when the button is pressed | |
}, | |
5f, // The cooldown for this button is five seconds | |
Properties.Resources.yournamehere, // change yournamehere to the name you set in step 2 | |
new Vector2(0.125f, 0.125f), // The position of the button, 1 unit is 100 pixels | |
() => | |
{ | |
// Who has access to the button? This allows alive crewmates to use the new button while the game is started | |
return !PlayerControl.LocalPlayer.Data.IsDead && !PlayerControl.LocalPlayer.Data.IsImpostor && (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started || AmongUsClient.Instance.GameMode == GameModes.FreePlay); | |
}, | |
__instance | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment