|
- using System;
- using System.Reflection;
- using System.Text;
- using BepInEx;
- using BepInEx.Bootstrap;
- using HarmonyLib;
- using RobocraftX.FrontEnd;
- using TechbloxModdingAPI.App;
- using TechbloxModdingAPI.Commands;
-
- namespace TechbloxModdingAPI.Tests
- {
- #if DEBUG // The API should be loaded by other plugins, but it can be used by itself for testing
- [BepInPlugin("org.exmods.TechbloxModdingAPIPluginTest", PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
- [BepInProcess("Techblox.exe")]
- public class TechbloxModdingAPIPluginTest : BaseUnityPlugin
- {
- private void Awake()
- {
- Main.Init();
- Client.EnterMenu += (sender, args) => throw new Exception("Test handler always throws an exception!");
- Client.EnterMenu += (sender, args) => Console.WriteLine("EnterMenu handler after erroring handler");
- Game.Enter += (s, a) =>
- {
- Player.LocalPlayer.SeatEntered += (sender, args) =>
- Console.WriteLine($"Player {Player.LocalPlayer} entered seat {args.Seat}");
- Player.LocalPlayer.SeatExited += (sender, args) =>
- Console.WriteLine($"Player {Player.LocalPlayer} exited seat {args.Seat}");
- };
-
- CommandBuilder.Builder()
- .Name("Exit")
- .Description("Close Techblox immediately, without any prompts")
- .Action(() => { UnityEngine.Application.Quit(); })
- .Build();
-
- CommandBuilder.Builder()
- .Name("SetFOV")
- .Description("Set the player camera's field of view")
- .Action((float d) => { UnityEngine.Camera.main.fieldOfView = d; })
- .Build();
-
- Game.AddPersistentDebugInfo("InstalledMods", InstalledMods);
-
- // Plugin startup logic
- Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
-
- #if TEST
- TestRoot.RunTests();
- #endif
- }
-
- private void OnDestroy()
- {
- Main.Shutdown();
- }
-
- private string modsString;
- private string InstalledMods()
- {
- if (modsString != null) return modsString;
- StringBuilder sb = new StringBuilder("Installed mods:");
- foreach (var (_, plugin) in Chainloader.PluginInfos)
- sb.Append("\n" + plugin.Metadata.Name + " - " + plugin.Metadata.Version);
- return modsString = sb.ToString();
- }
- }
-
- [HarmonyPatch]
- public class MinimumSpecsPatch
- {
- public static bool Prefix(ref bool __result)
- {
- __result = true;
- return false;
- }
-
- public static MethodInfo TargetMethod()
- {
- return ((Func<bool>) MinimumSpecsCheck.CheckRequirementsMet).Method;
- }
- }
- #endif
- }
|