mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
Use even more new unhollower features
This commit is contained in:
5 files changed
+14
-32
No files matched your search
@@ -5,7 +5,6 @@ using BepInEx.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using InnerNet;
|
||||
using Reactor.Extensions;
|
||||
using UnhollowerBaseLib;
|
||||
using UnhollowerBaseLib.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -43,18 +42,18 @@ namespace Reactor.Debugger
|
||||
{
|
||||
TestWindow = new DragWindow(new Rect(20, 20, 0, 0), "Debugger", () =>
|
||||
{
|
||||
GUILayout.Label("Name: " + SaveManager.PlayerName, new Il2CppReferenceArray<GUILayoutOption>(0));
|
||||
DisableGameEnd = GUILayout.Toggle(DisableGameEnd, "Disable game end", new Il2CppReferenceArray<GUILayoutOption>(0));
|
||||
GUILayout.Label("Name: " + SaveManager.PlayerName);
|
||||
DisableGameEnd = GUILayout.Toggle(DisableGameEnd, "Disable game end");
|
||||
|
||||
if (ShipStatus.Instance && AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
if (GUILayout.Button("Force game end", new Il2CppReferenceArray<GUILayoutOption>(0)))
|
||||
if (GUILayout.Button("Force game end"))
|
||||
{
|
||||
ShipStatus.Instance.enabled = false;
|
||||
ShipStatus.RpcEndGame(GameOverReason.ImpostorDisconnect, false);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Call a meeting", new Il2CppReferenceArray<GUILayoutOption>(0)))
|
||||
if (GUILayout.Button("Call a meeting"))
|
||||
{
|
||||
PlayerControl.LocalPlayer.CmdReportDeadBody(null);
|
||||
}
|
||||
@@ -64,7 +63,7 @@ namespace Reactor.Debugger
|
||||
{
|
||||
var data = PlayerControl.LocalPlayer.Data;
|
||||
|
||||
var newIsImpostor = GUILayout.Toggle(data.IsImpostor, "Is Impostor", new Il2CppReferenceArray<GUILayoutOption>(0));
|
||||
var newIsImpostor = GUILayout.Toggle(data.IsImpostor, "Is Impostor");
|
||||
if (data.IsImpostor != newIsImpostor)
|
||||
{
|
||||
if (newIsImpostor)
|
||||
@@ -80,7 +79,7 @@ namespace Reactor.Debugger
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Spawn a dummy", new Il2CppReferenceArray<GUILayoutOption>(0)))
|
||||
if (GUILayout.Button("Spawn a dummy"))
|
||||
{
|
||||
var playerControl = Instantiate(TutorialManager.Instance.PlayerPrefab);
|
||||
var i = playerControl.PlayerId = (byte) GameData.Instance.GetAvailableId();
|
||||
@@ -101,8 +100,8 @@ namespace Reactor.Debugger
|
||||
if (PlayerControl.LocalPlayer)
|
||||
{
|
||||
var position = PlayerControl.LocalPlayer.transform.position;
|
||||
GUILayout.Label($"x: {position.x}", new Il2CppReferenceArray<GUILayoutOption>(0));
|
||||
GUILayout.Label($"y: {position.y}", new Il2CppReferenceArray<GUILayoutOption>(0));
|
||||
GUILayout.Label($"x: {position.x}");
|
||||
GUILayout.Label($"y: {position.y}");
|
||||
}
|
||||
})
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Reactor
|
||||
public static implicit operator StringNames(CustomStringName name) => (StringNames) name.Id;
|
||||
public static explicit operator CustomStringName(StringNames name) => List.SingleOrDefault(x => x.Id == (int) name);
|
||||
|
||||
[HarmonyPatch(typeof(LanguageUnit), nameof(LanguageUnit.GetString))]
|
||||
[HarmonyPatch(typeof(LanguageUnit), nameof(LanguageUnit.GetString), typeof(StringNames), typeof(string), typeof(Il2CppReferenceArray<Il2CppSystem.Object>))]
|
||||
private static class GetStringPatch
|
||||
{
|
||||
public static bool Prefix(StringNames stringId, Il2CppReferenceArray<Il2CppSystem.Object> parts, ref string __result)
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Reactor.Extensions
|
||||
Rect = Rect.ResetSize();
|
||||
}
|
||||
|
||||
Rect = GUILayout.Window(Id, Rect, Func, Title, new Il2CppReferenceArray<GUILayoutOption>(0));
|
||||
Rect = GUILayout.Window(Id, Rect, Func, Title);
|
||||
|
||||
if ((Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) && Rect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)))
|
||||
{
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<DebugType>embedded</DebugType>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
<VersionPrefix>1.0.0</VersionPrefix>
|
||||
|
||||
<VersionPrefix>1.1.0</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
<Description>Core mod and API for Among Us</Description>
|
||||
<Authors>NuclearPowered</Authors>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using UnhollowerBaseLib;
|
||||
using UnhollowerBaseLib.Runtime;
|
||||
using UnhollowerBaseLib.Runtime.VersionSpecific.Class;
|
||||
using UnhollowerRuntimeLib;
|
||||
|
||||
namespace Reactor
|
||||
@@ -31,11 +28,7 @@ namespace Reactor
|
||||
{
|
||||
}
|
||||
|
||||
private static readonly Func<Type, IntPtr> _readClassPointerForType = AccessTools.MethodDelegate<Func<Type, IntPtr>>(
|
||||
AccessTools.Method(typeof(ClassInjector), "ReadClassPointerForType")
|
||||
);
|
||||
|
||||
private static unsafe void Register(Type type, Type[] interfaces)
|
||||
private static void Register(Type type, Type[] interfaces)
|
||||
{
|
||||
var baseTypeAttribute = type.BaseType?.GetCustomAttribute<RegisterInIl2CppAttribute>();
|
||||
if (baseTypeAttribute != null)
|
||||
@@ -50,16 +43,7 @@ namespace Reactor
|
||||
|
||||
try
|
||||
{
|
||||
var nativeInterfaces = new INativeClassStruct[interfaces.Length];
|
||||
for (var index = 0; index < interfaces.Length; index++)
|
||||
{
|
||||
var interfaceType = interfaces[index];
|
||||
var klassPtr = _readClassPointerForType(interfaceType);
|
||||
IL2CPP.il2cpp_runtime_class_init(klassPtr);
|
||||
nativeInterfaces[index] = UnityVersionHandler.Wrap((Il2CppClass*) klassPtr);
|
||||
}
|
||||
|
||||
ClassInjector.RegisterTypeInIl2Cpp(type, nativeInterfaces);
|
||||
ClassInjector.RegisterTypeInIl2CppWithInterfaces(type, true, interfaces);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user