mirror of
https://github.com/ApeMV/AmongUsRevamped.git
synced 2026-10-19 15:51:59 +00:00
That was not a fun surpirse
This commit is contained in:
1 parent
81c20d4706
commit
71461583b3
2 files changed
+37
-19
No files matched your search
@@ -547,4 +547,26 @@ public static class Utils
|
||||
PlayerControl.LocalPlayer.CmdReportDeadBody(null);
|
||||
MeetingHud.Instance.RpcClose();
|
||||
}
|
||||
|
||||
public static MethodBase GetStateMachineMoveNext<T>(string methodName)
|
||||
{
|
||||
var typeName = typeof(T).FullName;
|
||||
var stateMachine = typeof(T).GetNestedTypes().FirstOrDefault(x => x.Name.Contains(methodName));
|
||||
|
||||
if (stateMachine == null)
|
||||
{
|
||||
Logger.Error($"Failed to find {methodName} state machine for {typeName}", "GetStateMachineMoveNext");
|
||||
return null;
|
||||
}
|
||||
|
||||
var moveNext = AccessTools.Method(stateMachine, "MoveNext");
|
||||
if (moveNext == null)
|
||||
{
|
||||
Logger.Error($"Failed to find MoveNext method for {typeName}.{methodName}", "GetStateMachineMoveNext");
|
||||
return null;
|
||||
}
|
||||
|
||||
Logger.Info($"Found {methodName}.MoveNext", "GetStateMachineMoveNext");
|
||||
return moveNext;
|
||||
}
|
||||
}
|
||||
+15
-19
@@ -1,10 +1,16 @@
|
||||
using System.Reflection;
|
||||
using Il2CppInterop.Runtime.InteropTypes;
|
||||
|
||||
namespace AmongUsRevamped;
|
||||
|
||||
[HarmonyPatch]
|
||||
class ExileControllerWrapUpPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))]
|
||||
class ExileControllerPatch
|
||||
public static MethodBase TargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(ExileController), nameof(ExileController.WrapUp));
|
||||
}
|
||||
|
||||
public static void Postfix(ExileController __instance)
|
||||
{
|
||||
AfterExile(__instance.initData.networkedPlayer);
|
||||
@@ -13,7 +19,6 @@ class ExileControllerWrapUpPatch
|
||||
public static void AfterExile(NetworkedPlayerInfo ejectedPlayer)
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
|
||||
if (ejectedPlayer == null) return;
|
||||
|
||||
PlayerControl pc = null;
|
||||
@@ -51,28 +56,19 @@ class ExileControllerWrapUpPatch
|
||||
NormalGameEndChecker.CheckWinnerText("Jester");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
[HarmonyPatch(typeof(AirshipExileController), nameof(AirshipExileController.WrapUpAndSpawn))]
|
||||
class AirshipExileControllerPatchAndroid
|
||||
[HarmonyPatch]
|
||||
class AirshipExileControllerPatch
|
||||
{
|
||||
public static void Postfix(AirshipExileController __instance)
|
||||
public static MethodBase TargetMethod()
|
||||
{
|
||||
ExileControllerPatch.AfterExile(__instance.initData.networkedPlayer);
|
||||
return Utils.GetStateMachineMoveNext<AirshipExileController>(nameof(AirshipExileController.WrapUpAndSpawn));
|
||||
}
|
||||
}
|
||||
#else
|
||||
[HarmonyPatch(typeof(AirshipExileController._WrapUpAndSpawn_d__11), nameof(AirshipExileController._WrapUpAndSpawn_d__11.MoveNext))]
|
||||
class AirshipExileControllerPatchPC
|
||||
|
||||
public static void Postfix(AirshipExileController._WrapUpAndSpawn_d__11 __instance)
|
||||
{
|
||||
public static void Postfix(AirshipExileController._WrapUpAndSpawn_d__11 __instance, ref bool __result)
|
||||
{
|
||||
var instance = __instance.__4__this;
|
||||
ExileControllerPatch.AfterExile(instance.initData.networkedPlayer);
|
||||
ExileControllerWrapUpPatch.AfterExile(__instance.__4__this.initData.networkedPlayer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user