Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LCHostControlOnly v0.0.1
HostControlOnly.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using HostControlOnly.UI; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HostControlOnly")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HostControlOnly")] [assembly: AssemblyTitle("HostControlOnly")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HostControlOnly { public static class Constants { public const string GUID = "heiqi.arkgo.LCHostControlOnly"; public const string NAME = "LC Light Only Host Control"; public const string VERSION = "1.0.0"; } [BepInPlugin("heiqi.arkgo.LCHostControlOnly", "LC Light Only Host Control", "1.0.0")] public class HostControlOnly : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("heiqi.arkgo.LCHostControlOnly"); public static HostControlOnly Instance; private void Awake() { LogInfo("LC Light Only Host Control Mod is loading...\n=====\nHello\nHello\n=====\nLC Light Only Host Control Mod is loading..."); harmony.PatchAll(typeof(ShipLightsPatch)); harmony.PatchAll(typeof(ShipBuildControlPatch)); harmony.PatchAll(typeof(MenuPatch)); Instance = this; } internal void LogInfo(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } } [HarmonyPatch] internal class ShipBuildControlPatch { private static bool canControl = false; private static bool overrideCanControl = false; private static Vector3 fixedPosition = new Vector3(0f, 0f, 0f); public static bool _canControl { get { return canControl; } set { canControl = value; } } public static bool _overrideCanControl { get { return overrideCanControl; } set { overrideCanControl = value; } } [HarmonyPatch(typeof(ShipBuildModeManager), "PlaceShipObjectServerRpc")] [HarmonyPrefix] private static bool PrefixPlaceShipObjectServerRpc(ref Vector3 newPosition, ref Vector3 newRotation, ref NetworkObjectReference objectRef, int playerWhoMoved, ShipBuildModeManager __instance) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; HostControlOnly.Instance.LogInfo($"可控:{canControl},覆盖控制:{overrideCanControl}"); if ((Object)(object)networkManager != (Object)null && networkManager.IsServer) { HostControlOnly.Instance.LogInfo("networkManager 不为空"); NetworkObjectReference val = objectRef; if (overrideCanControl) { HostControlOnly.Instance.LogInfo("进入覆盖控制逻辑区域"); NetworkObject val2 = default(NetworkObject); if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null)) { if (!((Object)(object)val2 == (Object)null)) { PlaceableShipObject componentInChildren = ((Component)val2).GetComponentInChildren<PlaceableShipObject>(); string text = ((Object)componentInChildren.parentObject).name.ToLower(); if (text.Contains("teleporter") && !text.Contains("inverse")) { HostControlOnly.Instance.LogInfo("[ ShipBuildControlPatch ]使用手动保存并手动同步 Teleporter [test]"); newRotation = new Vector3(-90f, 0f, 0f); newPosition = ((Component)componentInChildren).transform.position; return true; } if (text.Contains("inverse") && text.Contains("teleporter")) { HostControlOnly.Instance.LogInfo("[ ShipBuildControlPatch ]使用手动保存并手动同步 Inverse Teleporter [test]"); newRotation = new Vector3(-90f, 0f, 0f); newPosition = ((Component)componentInChildren).transform.position; return true; } Quaternion rotation = ((Component)componentInChildren.mainMesh).transform.rotation; newRotation = ((Quaternion)(ref rotation)).eulerAngles; newPosition = ((Component)componentInChildren).transform.position; return true; } HostControlOnly.Instance.LogInfo($"[ ShipBuildControlPatch ] Error! Could not get network object with id: {((NetworkObjectReference)(ref objectRef)).NetworkObjectId} in placeshipobjectClientRpc"); } else { HostControlOnly.Instance.LogInfo($"无法获得对象; ID:{((NetworkObjectReference)(ref objectRef)).NetworkObjectId}"); } } else if (canControl) { return true; } HostControlOnly.Instance.LogInfo("[ ShipBuildControlPatch ] 非法操作"); return true; } if (overrideCanControl || canControl) { PlaceableShipObject componentInChildren2 = ((Component)networkManager).GetComponentInChildren<PlaceableShipObject>(); if ((Object)(object)componentInChildren2 != (Object)null && !StartOfRound.Instance.unlockablesList.unlockables[componentInChildren2.unlockableID].inStorage) { newRotation = componentInChildren2.parentObject.startingRotation; newPosition = componentInChildren2.parentObject.startingPosition; return true; } } return true; } [HarmonyPatch(typeof(ShipBuildModeManager), "PlaceShipObject")] [HarmonyPrefix] private static bool PrefixPlaceShipObject(ref Vector3 placementPosition, ref Vector3 placementRotation, PlaceableShipObject placeableObject, bool placementSFX, ShipBuildModeManager __instance) { //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; HostControlOnly.Instance.LogInfo($"可控:{canControl},覆盖控制:{overrideCanControl}"); Quaternion rotation; if ((Object)(object)networkManager != (Object)null && networkManager.IsServer) { HostControlOnly.Instance.LogInfo("networkManager 不为空"); if (overrideCanControl) { HostControlOnly.Instance.LogInfo("进入覆盖控制逻辑区域"); if (!((Object)(object)placeableObject == (Object)null)) { PlaceableShipObject componentInChildren = ((Component)placeableObject).GetComponentInChildren<PlaceableShipObject>(); string text = ((Object)componentInChildren.parentObject).name.ToLower(); if (text.Equals("teleporter") && !text.Equals("inverse")) { HostControlOnly.Instance.LogInfo("[ ShipBuildControlPatch ]使用手动保存并手动同步 Teleporter [test]"); placementRotation = new Vector3(-90f, 0f, 0f); placementPosition = ((Component)componentInChildren).transform.position; return true; } if (text.Equals("inverse") && text.Contains("teleporter")) { HostControlOnly.Instance.LogInfo("[ ShipBuildControlPatch ]使用手动保存并手动同步 Inverse Teleporter [test]"); placementRotation = new Vector3(-90f, 0f, 0f); placementPosition = ((Component)componentInChildren).transform.position; return true; } rotation = ((Component)componentInChildren.mainMesh).transform.rotation; placementRotation = ((Quaternion)(ref rotation)).eulerAngles; placementPosition = ((Component)componentInChildren).transform.position; return true; } HostControlOnly.Instance.LogInfo($"[ ShipBuildControlPatch ] Error! Could not get network object with id: {((Object)placeableObject.parentObject).name} in placeshipobjectClientRpc"); } else if (canControl) { return true; } HostControlOnly.Instance.LogInfo("[ ShipBuildControlPatch ] 非法操作"); return true; } if (overrideCanControl || canControl) { HostControlOnly.Instance.LogInfo("进入覆盖控制逻辑区域"); if (!((Object)(object)placeableObject == (Object)null)) { PlaceableShipObject componentInChildren2 = ((Component)placeableObject).GetComponentInChildren<PlaceableShipObject>(); string text2 = ((Object)componentInChildren2.parentObject).name.ToLower(); if (text2.Contains("teleporter") && !text2.Contains("inverse teleporter")) { HostControlOnly.Instance.LogInfo("[ ShipBuildControlPatch ]使用手动保存并手动同步 Teleporter [test]"); placementRotation = new Vector3(-90f, 0f, 0f); placementPosition = ((Component)componentInChildren2).transform.position; return true; } if (((Object)componentInChildren2.parentObject).name.ToLower().Contains("inverse teleporter")) { placementRotation = new Vector3(-90f, 0f, 0f); placementPosition = ((Component)componentInChildren2).transform.position; return true; } rotation = ((Component)componentInChildren2.mainMesh).transform.rotation; placementRotation = ((Quaternion)(ref rotation)).eulerAngles; placementPosition = ((Component)componentInChildren2).transform.position; return true; } HostControlOnly.Instance.LogInfo($"[ ShipBuildControlPatch ] Error! Could not get network object with id: {((Object)placeableObject.parentObject).name} in placeshipobjectClientRpc"); } return true; } public static void ResetAllBuild() { PlaceableShipObject[] array = Object.FindObjectsOfType<PlaceableShipObject>(); foreach (PlaceableShipObject val in array) { string name = ((Object)val).name; int instanceID = ((Object)val).GetInstanceID(); HostControlOnly.Instance.LogInfo($"名称:{name},ID:{instanceID}"); ShipBuildModeManager.Instance.ResetShipObjectToDefaultPosition(val); } } } [HarmonyPatch] internal class ShipLightsPatch { private static bool canControl; private static bool overrideControl; private static bool mainLightControl; public static bool _canControl { get { return canControl; } set { canControl = value; } } public static bool _overrideControl { get { return overrideControl; } set { overrideControl = value; } } public static bool _mainLightControl => mainLightControl; [HarmonyPatch(typeof(ShipLights), "SetShipLightsServerRpc")] [HarmonyPrefix] private static bool PrefixSetShipLightsServerRpc(ref bool setLightsOn, ShipLights __instance) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null) { if (__instance.areLightsOn != setLightsOn) { setLightsOn = __instance.areLightsOn; } mainLightControl = setLightsOn; return true; } if (overrideControl) { HostControlOnly.Instance.LogInfo("覆盖控制激活,强制设置灯光为开启状态"); setLightsOn = true; __instance.areLightsOn = true; mainLightControl = true; return true; } if (networkManager.IsServer) { __instance.areLightsOn = setLightsOn; mainLightControl = setLightsOn; HostControlOnly.Instance.LogInfo("主机正在控制灯光状态"); return true; } if (canControl) { HostControlOnly.Instance.LogInfo("客户端尝试修改灯光状态,但由于 canControl 为 true 而被阻止"); if (__instance.areLightsOn != setLightsOn) { setLightsOn = __instance.areLightsOn; } mainLightControl = setLightsOn; return true; } HostControlOnly.Instance.LogInfo("客户端尝试修改灯光状态"); mainLightControl = setLightsOn; return true; } [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")] [HarmonyPrefix] private static bool PrefixSyncShipUnlockablesClientRpc(int[] playerSuitIDs, ref bool shipLightsOn, Vector3[] placeableObjectPositions, Vector3[] placeableObjectRotations, int[] placeableObjects, int[] storedItems, int[] scrapValues, int[] itemSaveData, StartOfRound __instance) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((networkManager.IsServer || networkManager.IsHost) && !networkManager.IsClient) { if (overrideControl) { shipLightsOn = true; return true; } return true; } if (networkManager.IsClient && (overrideControl || canControl)) { shipLightsOn = true; return true; } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "HostControlOnly"; public const string PLUGIN_NAME = "HostControlOnly"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace HostControlOnly.UI { [HarmonyPatch(typeof(QuickMenuManager))] public class MenuPatch { [HarmonyPatch("OpenQuickMenu")] [HarmonyPostfix] public static void PostfixOpen() { if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { UI.SetMenuForAll(value: true); } } [HarmonyPatch("CloseQuickMenu")] [HarmonyPostfix] public static void PostfixClose() { if (((NetworkBehaviour)StartOfRound.Instance).IsHost) { UI.SetMenuForAll(value: false); } } } public class UI : MonoBehaviour { private static readonly List<UI> Instances = new List<UI>(); public static bool ShowButton = false; private bool _menuOpen; private bool lightControl; private bool lightControlOverride; private bool shipBuildControl; private bool shipBuildControlOverride; private Rect _windowRect; private StartOfRound startOfRound = StartOfRound.Instance; private readonly GUILayoutOption[] _options = (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(800f), GUILayout.Height(400f) }; private Rect buttonRect = new Rect(10f, 10f, 150f, 75f); private void Awake() { Instances.Add(this); } private void OnDestroy() { Instances.Remove(this); } private void OnGUI() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)startOfRound).IsServer && _menuOpen) { _windowRect = GUILayout.Window(GUIUtility.GetControlID((FocusType)2), _windowRect, new WindowFunction(DrawUI), "黑崎管理终端 V1.0.0", _options); } } public static void SetMenuForAll(bool value) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) ShowButton = value; if (Instances.Count == 0 && value) { new GameObject("黑崎管理终端").AddComponent<UI>(); Debug.Log((object)"正在创建UI"); } foreach (UI instance in Instances) { instance.SetMenu(value); } } private void SetMenu(bool value) { _menuOpen = value; } private void DrawUI(int windowID) { //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); bool flag = GUILayout.Toggle(lightControl, "锁定船灯(服务端可控)", Array.Empty<GUILayoutOption>()); if (flag != lightControl) { lightControl = flag; ShipLightsPatch._canControl = lightControl; } bool flag2 = GUILayout.Toggle(lightControlOverride, "锁定船灯(不可控制强制为开)", Array.Empty<GUILayoutOption>()); if (flag2 != lightControlOverride) { lightControlOverride = flag2; ShipLightsPatch._overrideControl = lightControlOverride; } bool flag3 = GUILayout.Toggle(shipBuildControl, "锁定船上建筑到默认位置(服务端可控)", Array.Empty<GUILayoutOption>()); if (flag3 != shipBuildControl) { shipBuildControl = flag3; ShipBuildControlPatch._canControl = shipBuildControl; } bool flag4 = GUILayout.Toggle(shipBuildControlOverride, "锁定船上建筑到默认位置(不可控制强制放到默认位置)", Array.Empty<GUILayoutOption>()); if (flag4 != shipBuildControlOverride) { shipBuildControlOverride = flag4; ShipBuildControlPatch._overrideCanControl = shipBuildControlOverride; } if (GUILayout.Button("强制将所有建筑放到默认位置", Array.Empty<GUILayoutOption>())) { PlaceableShipObject[] array = Object.FindObjectsOfType<PlaceableShipObject>(); for (int i = 0; i < array.Length && !startOfRound.unlockablesList.unlockables[array[i].unlockableID].inStorage; i++) { if (startOfRound.unlockablesList.unlockables[array[i].unlockableID].alreadyUnlocked && !startOfRound.unlockablesList.unlockables[array[i].unlockableID].spawnPrefab) { array[i].parentObject.disableObject = false; HostControlOnly.Instance.LogInfo($"[ UI ] 已经将 {((Object)array[i].parentObject).name}@{array[i].unlockableID} 的位置重置"); ShipBuildModeManager.Instance.ResetShipObjectToDefaultPosition(array[i]); continue; } PlaceableShipObject val = array[i]; string text = ((Object)val.parentObject).name.ToLower(); if (((Object)val.parentObject).name.ToLower().Contains("inverse teleporter")) { HostControlOnly.Instance.LogInfo("[ UI ]使用手动保存并手动同步 Teleporter [test]"); try { startOfRound.unlockablesList.unlockables[val.unlockableID].placedPosition = Vector3.zero; startOfRound.unlockablesList.unlockables[val.unlockableID].placedRotation = Vector3.zero; val.parentObjectSecondary.position = new Vector3(5.79f, 2.14f, -12.23f); ((Component)val.parentObjectSecondary).transform.eulerAngles = new Vector3(0f, 0f, 0f); } catch (Exception arg) { HostControlOnly.Instance.LogInfo($"[ UI ] 出现错误 {arg}"); } } else if (text.Contains("teleporter") && !text.Contains("inverse teleporter")) { HostControlOnly.Instance.LogInfo("[ UI ]使用手动保存并手动同步 Inverse Teleporter [test]"); try { startOfRound.unlockablesList.unlockables[val.unlockableID].placedPosition = Vector3.zero; startOfRound.unlockablesList.unlockables[val.unlockableID].placedRotation = Vector3.zero; val.parentObjectSecondary.position = new Vector3(0.9315f, 0.5234f, -12.9f); ((Component)val.parentObjectSecondary).transform.eulerAngles = new Vector3(0f, 64.7f, 0f); } catch (Exception arg2) { HostControlOnly.Instance.LogInfo($"[ UI ] 出现错误 {arg2}"); } } } try { startOfRound.SyncShipUnlockablesServerRpc(); HostControlOnly.Instance.LogInfo("[ UI ] 成功将强制移动到原位同步到所有人"); } catch (Exception arg3) { HostControlOnly.Instance.LogInfo($"[ UI ] 出现错误 {arg3}"); } } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("使用遥控器控制灯光 Beta", Array.Empty<GUILayoutOption>())) { try { Object.FindObjectOfType<ShipLights>().ToggleShipLightsOnLocalClientOnly(); } catch (Exception arg4) { HostControlOnly.Instance.LogInfo($"{arg4}"); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, 10000f, 500f)); } } } namespace HostControlOnly.ReflectionUntils { public class ReflectionUtils { public static void InvokeMethod(object obj, string methodName, object[] parameters) { obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Invoke(obj, parameters); } public static void InvokeMethod(object obj, Type forceType, string methodName, object[] parameters) { forceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Invoke(obj, parameters); } public static void SetPropertyValue(object obj, string propertyName, object value) { obj.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(obj, value); } public static T InvokeMethod<T>(object obj, string methodName, object[] parameters) { return (T)obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Invoke(obj, parameters); } public static T GetFieldValue<T>(object obj, string fieldName) { return (T)obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(obj); } public static void SetFieldValue(object obj, string fieldName, object value) { obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(obj, value); } } } namespace HostControlOnly.Logger { public class Log { internal readonly string Prefix; private readonly float _time = Time.realtimeSinceStartup; private readonly string _message; public Log(string message, string prefix = "Info") { _message = message; Prefix = prefix; } public string GetTimeFormattedString() { return $"[{TimeSpan.FromSeconds(_time):hh':'mm':'ss}] [{Prefix}] {_message}"; } } }