mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
Cleanup debugger
This commit is contained in:
3 files changed
+2
-92
No files matched your search
@@ -32,11 +32,6 @@ namespace Reactor.Debugger
|
||||
GameOptionsData.MinPlayers = Enumerable.Repeat(1, 4).ToArray();
|
||||
|
||||
Harmony.PatchAll();
|
||||
|
||||
Extensions.Extensions.once_sceneLoaded((_, _) =>
|
||||
{
|
||||
Dumping.Dump();
|
||||
});
|
||||
}
|
||||
|
||||
[RegisterInIl2Cpp]
|
||||
@@ -101,18 +96,4 @@ namespace Reactor.Debugger
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [HarmonyPatch]
|
||||
// public static class TracePatch
|
||||
// {
|
||||
// public static IEnumerable<MethodBase> TargetMethods()
|
||||
// {
|
||||
// return typeof(AmongUsClient).GetMethods(AccessTools.all).Where(x => x.ReturnType == typeof(Il2CppStructArray<byte>) && !x.GetParameters().Any());
|
||||
// }
|
||||
//
|
||||
// public static void Postfix(MethodBase __originalMethod)
|
||||
// {
|
||||
// PluginSingleton<DebuggerPlugin>.Instance.Log.LogInfo(__originalMethod.FullDescription());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BepInEx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reactor.Debugger
|
||||
{
|
||||
public static class Dumping
|
||||
{
|
||||
public static string DumpPath { get; } = Path.Combine(Paths.PluginPath, "dump");
|
||||
|
||||
public static void Dump()
|
||||
{
|
||||
Directory.CreateDirectory(DumpPath);
|
||||
|
||||
WritePalette();
|
||||
WriteEnum("Hat", HatManager.Instance.AllHats.ToArray().Select(hat => hat.name));
|
||||
WriteEnum("Pet", HatManager.Instance.AllPets.ToArray().Select(hat => hat.name));
|
||||
WriteEnum("Skin", HatManager.Instance.AllSkins.ToArray().Select(hat => hat.name));
|
||||
}
|
||||
|
||||
private static void WritePalette()
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
|
||||
builder.AppendLine("public static class Palette");
|
||||
builder.AppendLine("{");
|
||||
|
||||
foreach (var propertyInfo in typeof(Palette).GetProperties())
|
||||
{
|
||||
if (propertyInfo.GetMethod == null || !propertyInfo.GetMethod.IsStatic)
|
||||
continue;
|
||||
|
||||
var value = propertyInfo.GetValue(null);
|
||||
|
||||
if (value is Color f)
|
||||
{
|
||||
value = (Color32) f;
|
||||
}
|
||||
|
||||
if (value is Color32 color)
|
||||
{
|
||||
builder.AppendLine($" public static readonly Color {propertyInfo.Name} = Color.FromArgb({(color.a != byte.MaxValue ? $"{color.a}, " : string.Empty)}{color.r}, {color.g}, {color.b});");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine("}");
|
||||
|
||||
File.WriteAllText(Path.Combine(DumpPath, $"Palette.cs"), builder.ToString());
|
||||
}
|
||||
|
||||
private static void WriteEnum(string name, IEnumerable<string> values)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
|
||||
builder.AppendLine("public enum " + name);
|
||||
builder.AppendLine("{");
|
||||
|
||||
foreach (var value in values)
|
||||
{
|
||||
builder.AppendLine(" " + value.Replace(" ", "").Replace("'", "") + ",");
|
||||
}
|
||||
|
||||
builder.AppendLine("}");
|
||||
|
||||
File.WriteAllText(Path.Combine(DumpPath, $"{name}.cs"), builder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace Reactor.Debugger.Patches
|
||||
namespace Reactor.Debugger
|
||||
{
|
||||
public static class Test
|
||||
internal static class Patches
|
||||
{
|
||||
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
|
||||
public static class UpdatePatch
|
||||
Reference in new issue
Block a user