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 UFO Size v1.0.1
UFOSize.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [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("UFOSize")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UFOSize")] [assembly: AssemblyTitle("UFOSize")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 UFOSize { internal static class HeldItems { private static readonly HashSet<GrabbableObject> Scaled = new HashSet<GrabbableObject>(); private static readonly List<GrabbableObject> ToRestore = new List<GrabbableObject>(); internal static IEnumerable<GrabbableObject> ScaledItems => Scaled; private static float HolderSize(GrabbableObject item) { if (!Plugin.ScaleHeldItems.Value || (Object)(object)item.parentObject == (Object)null || (Object)(object)item.playerHeldBy == (Object)null) { return 1f; } return SizeController.SizeOf(item.playerHeldBy); } internal static void UpdateItem(GrabbableObject item) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) float num = HolderSize(item); if (Mathf.Abs(num - 1f) < 0.001f) { Restore(item); return; } Scaled.Add(item); bool flag = ((Component)item).transform.IsChildOf(((Component)item.playerHeldBy).transform); ((Component)item).transform.localScale = (flag ? item.originalScale : (item.originalScale * num)); Transform parentObject = item.parentObject; ((Component)item).transform.position = parentObject.position + parentObject.rotation * (item.itemProperties.positionOffset * num); } internal static void Tick() { if (Scaled.Count == 0) { return; } foreach (GrabbableObject item in Scaled) { if ((Object)(object)item == (Object)null || Mathf.Abs(HolderSize(item) - 1f) < 0.001f) { ToRestore.Add(item); } } foreach (GrabbableObject item2 in ToRestore) { Restore(item2); } ToRestore.Clear(); } private static void Restore(GrabbableObject item) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Scaled.Remove(item) && (Object)(object)item != (Object)null) { ((Component)item).transform.localScale = item.originalScale; } } internal static void FixOriginalScale(GrabbableObject item, Vector3 scale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) item.originalScale = scale; ((Component)item).transform.localScale = scale; } } [HarmonyPatch] internal static class Patches { private const int WalkableSurfacesNoPlayersMask = 1342179585; [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] [HarmonyPrefix] private static void SubmitChatPrefix(HUDManager __instance, CallbackContext context) { PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (((CallbackContext)(ref context)).performed && !((Object)(object)val == (Object)null) && val.isTypingChat && !((Object)(object)__instance.chatTextField == (Object)null) && SizeCommand.TryHandle(__instance.chatTextField.text)) { __instance.chatTextField.text = ""; } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] private static void ConnectClientPostfix() { SizeNetwork.Register(); if ((Object)(object)NetworkManager.Singleton != (Object)null && !NetworkManager.Singleton.IsServer) { SizeNetwork.SendHello(); } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] [HarmonyPostfix] private static void PlayerDisconnectPostfix(StartOfRound __instance, int playerObjectNumber) { if (playerObjectNumber >= 0 && playerObjectNumber < __instance.allPlayerScripts.Length) { SizeController component = ((Component)__instance.allPlayerScripts[playerObjectNumber]).GetComponent<SizeController>(); if ((Object)(object)component != (Object)null) { component.SetTarget(1f, instant: true); } } } [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyPostfix] private static void PlayerLateUpdatePostfix(PlayerControllerB __instance) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController) { return; } float num = SizeController.SizeOf(__instance); if (!(Mathf.Abs(num - 1f) < 0.001f) && !__instance.inSpecialInteractAnimation && !((Object)(object)__instance.localArmsTransform == (Object)null)) { if (__instance.localArmsMatchCamera) { __instance.localArmsTransform.position = __instance.cameraContainerTransform.position + ((Component)__instance.gameplayCamera).transform.up * (-0.5f * num); } else { __instance.localArmsTransform.position = __instance.playerModelArmsMetarig.position + __instance.playerModelArmsMetarig.forward * (-0.445f * num); } } } [HarmonyPatch(typeof(PlayerControllerB), "RaycastSpectateCameraAroundPivot")] [HarmonyPostfix] private static void SpectateCameraPostfix(PlayerControllerB __instance) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB spectatedPlayerScript = __instance.spectatedPlayerScript; if (__instance.isInGameOverAnimation > 0f || (Object)(object)spectatedPlayerScript == (Object)null || spectatedPlayerScript.isPlayerDead) { return; } float num = SizeController.SizeOf(spectatedPlayerScript); Camera val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.spectateCamera : null); if (!(Mathf.Abs(num - 1f) < 0.01f) && !((Object)(object)val == (Object)null)) { Transform spectateCameraPivot = __instance.spectateCameraPivot; Vector3 val2 = ((Component)val).transform.position - spectateCameraPivot.position; Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val2)).normalized : (-spectateCameraPivot.forward)); float num2 = ((Vector3)(ref val2)).magnitude * num; spectateCameraPivot.position = spectatedPlayerScript.lowerSpine.position + Vector3.up * (0.7f * num); RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(spectateCameraPivot.position, val3, ref val4, num2 + 0.1f * num, 1342179585, (QueryTriggerInteraction)1)) { num2 = Mathf.Max(0.05f, ((RaycastHit)(ref val4)).distance - 0.25f * Mathf.Min(num, 1f)); } ((Component)val).transform.position = spectateCameraPivot.position + val3 * num2; ((Component)val).transform.LookAt(spectateCameraPivot); } } [HarmonyPatch(typeof(GrabbableObject), "LateUpdate")] [HarmonyPostfix] private static void ItemLateUpdatePostfix(GrabbableObject __instance) { HeldItems.UpdateItem(__instance); } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void PlayerUpdatePostfix(PlayerControllerB __instance) { if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController) { HeldItems.Tick(); } } [HarmonyPatch(typeof(SoundManager), "SetPlayerVoiceFilters")] [HarmonyPrefix] private static void VoiceFiltersPrefix(SoundManager __instance, out float[] __state) { __state = null; StartOfRound instance = StartOfRound.Instance; float[] playerVoicePitchTargets = __instance.playerVoicePitchTargets; if (!Plugin.VoicePitch.Value || (Object)(object)instance == (Object)null || playerVoicePitchTargets == null) { return; } PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val == (Object)null) { return; } if (val.isPlayerDead && (Object)(object)val.spectatedPlayerScript != (Object)null) { val = val.spectatedPlayerScript; } float num = SizeController.SizeOf(val); int num2 = Mathf.Min(playerVoicePitchTargets.Length, instance.allPlayerScripts.Length); for (int i = 0; i < num2; i++) { float num3 = Mathf.Max(SizeController.SizeOf(instance.allPlayerScripts[i]), 0.01f); float num4 = Mathf.Clamp(Mathf.Pow(num / num3, 0.25f), 0.85f, 1.25f); if (!(Mathf.Abs(num4 - 1f) < 0.001f)) { if (__state == null) { __state = new float[num2]; } __state[i] = playerVoicePitchTargets[i]; playerVoicePitchTargets[i] *= num4; } } } [HarmonyPatch(typeof(SoundManager), "SetPlayerVoiceFilters")] [HarmonyPostfix] private static void VoiceFiltersPostfix(SoundManager __instance, float[] __state) { if (__state == null) { return; } for (int i = 0; i < __state.Length; i++) { if (__state[i] != 0f) { __instance.playerVoicePitchTargets[i] = __state[i]; } } } } [BepInPlugin("UFO.Size", "UFO Size", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string Guid = "UFO.Size"; public const string Name = "UFO Size"; public const string Version = "1.0.1"; internal static ManualLogSource Log; internal static ConfigEntry<bool> AllowPlayers; internal static ConfigEntry<bool> OrbitOnly; internal static ConfigEntry<float> MinSize; internal static ConfigEntry<float> MaxSize; internal static ConfigEntry<float> TransitionSpeed; internal static ConfigEntry<bool> ScaleHeldItems; internal static ConfigEntry<bool> ScaleReach; internal static ConfigEntry<bool> VoicePitch; private void Awake() { //IL_011c: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; AllowPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Host", "AllowPlayers", true, "Allow non-host players to change their own size. Host setting."); OrbitOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Host", "OrbitOnly", true, "Size can only be changed while the ship is in orbit. Host setting."); MinSize = ((BaseUnityPlugin)this).Config.Bind<float>("Host", "MinSize", 0.3f, "Smallest allowed size (1 = normal). Host setting."); MaxSize = ((BaseUnityPlugin)this).Config.Bind<float>("Host", "MaxSize", 1.5f, "Largest allowed size (1 = normal). Host setting."); TransitionSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "TransitionSpeed", 6f, "How fast players grow/shrink (0 = instant)."); ScaleHeldItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "ScaleHeldItems", true, "Held items scale with the player."); ScaleReach = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "ScaleReach", true, "Bigger players can reach further."); VoicePitch = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects", "VoicePitch", true, "Smaller players sound higher, bigger players lower."); new Harmony("UFO.Size").PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"UFO Size 1.0.1 loaded."); } } internal static class SizeCommand { private const string Command = "/size"; private static readonly MethodInfo AddChatMessage = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); internal static bool TryHandle(string text) { if (string.IsNullOrEmpty(text)) { return false; } string text2 = text.Trim(); if (!text2.StartsWith("/size", StringComparison.OrdinalIgnoreCase) || (text2.Length > "/size".Length && !char.IsWhiteSpace(text2["/size".Length]))) { return false; } Execute(text2.Substring("/size".Length).Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); return true; } private static void Execute(string[] args) { PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val == (Object)null) { return; } bool flag = (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer; if (!flag && !SizeNetwork.HostHasMod) { Print("The host doesn't have UFO Size installed."); return; } if (args.Length == 0) { Print("Your size: " + Format(SizeController.SizeOf(val)) + ". Usage: /size 0.5, /size reset"); return; } if (!TryParseSize(args[^1], out var size)) { Print("Invalid size. Example: /size 0.5"); return; } if (args.Length == 1) { SizeNetwork.RequestSize((int)val.playerClientId, size); return; } if (!flag) { Print("Only the host can change other players' size."); return; } if (Plugin.OrbitOnly.Value && !StartOfRound.Instance.inShipPhase) { Print("You can only change size while in orbit."); return; } string text = string.Join(" ", args, 0, args.Length - 1); List<PlayerControllerB> list = FindPlayers(text); if (list.Count == 0) { Print("No player named \"" + text + "\"."); return; } if (list.Count > 1 && !IsAll(text)) { Print("Multiple players match: " + string.Join(", ", list.ConvertAll((PlayerControllerB p) => p.playerUsername))); return; } foreach (PlayerControllerB item in list) { SizeNetwork.RequestSize((int)item.playerClientId, size); } if (list.Count > 1 || (Object)(object)list[0] != (Object)(object)val) { SizeNetwork.GetLimits(out var min, out var max); Print(((list.Count > 1) ? "Everyone's" : (list[0].playerUsername + "'s")) + " size: " + Format(Mathf.Clamp(size, min, max))); } } private static bool IsAll(string name) { return name.Equals("all", StringComparison.OrdinalIgnoreCase); } private static List<PlayerControllerB> FindPlayers(string name) { List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerControlled || val.isPlayerDead) { list.Add(val); } } if (IsAll(name)) { return list; } List<PlayerControllerB> list2 = list.FindAll((PlayerControllerB p) => string.Equals(p.playerUsername, name, StringComparison.OrdinalIgnoreCase)); if (list2.Count == 0) { list2 = list.FindAll((PlayerControllerB p) => p.playerUsername != null && p.playerUsername.StartsWith(name, StringComparison.OrdinalIgnoreCase)); } if (list2.Count == 0) { list2 = list.FindAll((PlayerControllerB p) => p.playerUsername != null && p.playerUsername.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0); } return list2; } private static bool TryParseSize(string text, out float size) { size = 1f; string text2 = text.Trim().ToLowerInvariant(); if (text2 == "reset" || text2 == "normal") { return true; } bool flag = text2.EndsWith("%"); text2 = text2.TrimEnd('%', 'x').Replace(',', '.'); if (!float.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out size) || float.IsNaN(size) || float.IsInfinity(size) || size <= 0f) { return false; } if (flag) { size /= 100f; } return true; } internal static string Format(float size) { return size.ToString("0.##", CultureInfo.InvariantCulture) + "x"; } internal static void Print(string text) { HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null || AddChatMessage == null) { Plugin.Log.LogInfo((object)text); return; } AddChatMessage.Invoke(instance, new object[4] { text, "", -1, false }); } } internal class SizeController : MonoBehaviour { private const float Epsilon = 0.002f; internal PlayerControllerB Player; internal float Target = 1f; internal float Current = 1f; private bool captured; private bool wasInTerminal; private float baseStepOffset; private bool capturedLocal; private float baseNearClip; private float baseGrabDistance; private bool scaleVisor; private Vector3 baseVisorScale; private bool scaleArms; private Vector3 baseArmsScale; private bool IsLocal { get { if ((Object)(object)GameNetworkManager.Instance != (Object)null) { return (Object)(object)Player == (Object)(object)GameNetworkManager.Instance.localPlayerController; } return false; } } private bool InTerminal { get { if (Player.inTerminalMenu) { return IsLocal; } return false; } } private float Goal { get { if (!InTerminal) { return Target; } return 1f; } } internal static SizeController Get(PlayerControllerB player) { SizeController sizeController = ((Component)player).GetComponent<SizeController>(); if ((Object)(object)sizeController == (Object)null) { sizeController = ((Component)player).gameObject.AddComponent<SizeController>(); sizeController.Player = player; } return sizeController; } internal static float SizeOf(PlayerControllerB player) { if ((Object)(object)player == (Object)null) { return 1f; } SizeController component = ((Component)player).GetComponent<SizeController>(); if (!((Object)(object)component != (Object)null)) { return 1f; } return component.Current; } internal void SetTarget(float size, bool instant) { Target = size; if (instant || Plugin.TransitionSpeed.Value <= 0f) { Apply(Goal); } } private void Update() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) bool inTerminal = InTerminal; if (inTerminal != wasInTerminal) { wasInTerminal = inTerminal; Apply(Goal); return; } float goal = Goal; if (Mathf.Abs(Current - goal) > 0.002f) { float num = 1f - Mathf.Exp((0f - Plugin.TransitionSpeed.Value) * Time.deltaTime); float num2 = Mathf.Lerp(Current, goal, num); Apply((Mathf.Abs(num2 - goal) <= 0.002f) ? goal : num2); } else if (captured && ((Component)this).transform.localScale != Vector3.one * Current) { Apply(Current); } } private void Capture() { if (!captured) { captured = true; baseStepOffset = (((Object)(object)Player.thisController != (Object)null) ? Player.thisController.stepOffset : 0f); } } private void CaptureLocal() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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) if (!capturedLocal) { capturedLocal = true; baseNearClip = (((Object)(object)Player.gameplayCamera != (Object)null) ? Player.gameplayCamera.nearClipPlane : 0.01f); baseGrabDistance = Player.grabDistance; scaleVisor = (Object)(object)Player.localVisor != (Object)null && !Player.localVisor.IsChildOf(((Component)this).transform); if (scaleVisor) { baseVisorScale = Player.localVisor.localScale; } scaleArms = (Object)(object)Player.localArmsTransform != (Object)null && !Player.localArmsTransform.IsChildOf(((Component)this).transform); if (scaleArms) { baseArmsScale = Player.localArmsTransform.localScale; } } } private void Apply(float size) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) Capture(); Current = size; ((Component)this).transform.localScale = Vector3.one * size; if ((Object)(object)Player.thisController != (Object)null) { Player.thisController.stepOffset = baseStepOffset * Mathf.Clamp(size, 0.5f, 1f); } if (IsLocal) { CaptureLocal(); if (scaleArms) { Player.localArmsTransform.localScale = baseArmsScale * size; } if ((Object)(object)Player.gameplayCamera != (Object)null) { Player.gameplayCamera.nearClipPlane = baseNearClip * size; } Player.grabDistance = (Plugin.ScaleReach.Value ? (baseGrabDistance * Mathf.Max(1f, size)) : baseGrabDistance); if (scaleVisor) { Player.localVisor.localScale = baseVisorScale * size; } } } } internal static class SizeNetwork { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequest; public static HandleNamedMessageDelegate <1>__OnHello; public static HandleNamedMessageDelegate <2>__OnSizes; public static HandleNamedMessageDelegate <3>__OnNotice; } private const string RequestMessage = "UFO.Size.Request"; private const string HelloMessage = "UFO.Size.Hello"; private const string SizesMessage = "UFO.Size.Sizes"; private const string NoticeMessage = "UFO.Size.Notice"; internal static bool HostHasMod; internal static void Register() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager val = (((Object)(object)singleton != (Object)null) ? singleton.CustomMessagingManager : null); if (val != null) { object obj = <>O.<0>__OnRequest; if (obj == null) { HandleNamedMessageDelegate val2 = OnRequest; <>O.<0>__OnRequest = val2; obj = (object)val2; } val.RegisterNamedMessageHandler("UFO.Size.Request", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnHello; if (obj2 == null) { HandleNamedMessageDelegate val3 = OnHello; <>O.<1>__OnHello = val3; obj2 = (object)val3; } val.RegisterNamedMessageHandler("UFO.Size.Hello", (HandleNamedMessageDelegate)obj2); object obj3 = <>O.<2>__OnSizes; if (obj3 == null) { HandleNamedMessageDelegate val4 = OnSizes; <>O.<2>__OnSizes = val4; obj3 = (object)val4; } val.RegisterNamedMessageHandler("UFO.Size.Sizes", (HandleNamedMessageDelegate)obj3); object obj4 = <>O.<3>__OnNotice; if (obj4 == null) { HandleNamedMessageDelegate val5 = OnNotice; <>O.<3>__OnNotice = val5; obj4 = (object)val5; } val.RegisterNamedMessageHandler("UFO.Size.Notice", (HandleNamedMessageDelegate)obj4); HostHasMod = singleton.IsServer; } } internal unsafe static void RequestSize(int playerIndex, float size) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null) { return; } if (singleton.IsServer) { HandleRequest(singleton.LocalClientId, playerIndex, size); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref playerIndex, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref size, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("UFO.Size.Request", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal unsafe static void SendHello() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null || singleton.IsServer) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { singleton.CustomMessagingManager.SendNamedMessage("UFO.Size.Hello", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal static void GetLimits(out float min, out float max) { min = Mathf.Max(0.05f, Mathf.Min(Plugin.MinSize.Value, Plugin.MaxSize.Value)); max = Mathf.Max(min, Mathf.Max(Plugin.MinSize.Value, Plugin.MaxSize.Value)); } private static void HandleRequest(ulong senderClientId, int playerIndex, float size) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || playerIndex < 0 || playerIndex >= instance.allPlayerScripts.Length) { return; } PlayerControllerB val = instance.allPlayerScripts[playerIndex]; if (senderClientId != 0) { if (!Plugin.AllowPlayers.Value) { Notice(senderClientId, "The host has disabled size changes."); return; } if (!val.isPlayerControlled || val.actualClientId != senderClientId) { Notice(senderClientId, "You can only change your own size."); return; } } if (Plugin.OrbitOnly.Value && !instance.inShipPhase) { Notice(senderClientId, "You can only change size while in orbit."); } else { if (float.IsNaN(size) || float.IsInfinity(size) || size <= 0f) { return; } GetLimits(out var min, out var max); float num = Mathf.Clamp(size, min, max); if (Mathf.Abs(num - size) > 0.001f) { Notice(senderClientId, "Allowed size: " + SizeCommand.Format(min) + " - " + SizeCommand.Format(max) + "."); } ApplySize(playerIndex, num, instant: false, announce: true); NetworkManager singleton = NetworkManager.Singleton; foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId != singleton.LocalClientId) { SendSizes(connectedClientsId, instant: false, playerIndex, withItems: false); } } } } private unsafe static void SendSizes(ulong clientId, bool instant, int changedIndex, bool withItems) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_010c: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; List<GrabbableObject> list = new List<GrabbableObject>(); if (withItems) { foreach (GrabbableObject scaledItem in HeldItems.ScaledItems) { if ((Object)(object)scaledItem != (Object)null && (Object)(object)((NetworkBehaviour)scaledItem).NetworkObject != (Object)null && ((NetworkBehaviour)scaledItem).NetworkObject.IsSpawned) { list.Add(scaledItem); } } } int num = 32 + allPlayerScripts.Length * 4 + list.Count * 20; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref instant, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref changedIndex, default(ForPrimitives)); int num2 = allPlayerScripts.Length; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num2, default(ForPrimitives)); PlayerControllerB[] array = allPlayerScripts; for (num2 = 0; num2 < array.Length; num2++) { SizeController component = ((Component)array[num2]).GetComponent<SizeController>(); float num3 = (((Object)(object)component != (Object)null) ? component.Target : 1f); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref num3, default(ForPrimitives)); } num2 = list.Count; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num2, default(ForPrimitives)); foreach (GrabbableObject item in list) { ulong networkObjectId = ((NetworkBehaviour)item).NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref item.originalScale); } singleton.CustomMessagingManager.SendNamedMessage("UFO.Size.Sizes", clientId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe static void Notice(ulong clientId, string text) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (clientId == singleton.LocalClientId) { SizeCommand.Print(text); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, 1024); try { ((FastBufferWriter)(ref val)).WriteValueSafe(text, false); singleton.CustomMessagingManager.SendNamedMessage("UFO.Size.Notice", clientId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private static void ApplySize(int playerIndex, float size, bool instant, bool announce) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || playerIndex < 0 || playerIndex >= instance.allPlayerScripts.Length) { return; } PlayerControllerB val = instance.allPlayerScripts[playerIndex]; if ((Object)(object)((Component)val).GetComponent<SizeController>() == (Object)null && Mathf.Approximately(size, 1f)) { ((Component)val).transform.localScale = Vector3.one; return; } SizeController.Get(val).SetTarget(size, instant); if (announce && (Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController) { SizeCommand.Print("Your size: " + SizeCommand.Format(size)); } } private static void OnRequest(ulong senderClientId, FastBufferReader reader) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer) { int playerIndex = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref playerIndex, default(ForPrimitives)); float size = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref size, default(ForPrimitives)); HandleRequest(senderClientId, playerIndex, size); } } private static void OnHello(ulong senderClientId, FastBufferReader reader) { if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer && !((Object)(object)StartOfRound.Instance == (Object)null)) { SendSizes(senderClientId, instant: true, -1, withItems: true); } } private static void OnSizes(ulong senderClientId, FastBufferReader reader) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) if (senderClientId != 0L || (Object)(object)StartOfRound.Instance == (Object)null) { return; } HostHasMod = true; bool instant = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref instant, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); float size = default(float); for (int i = 0; i < num2; i++) { ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref size, default(ForPrimitives)); ApplySize(i, size, instant, i == num); } int num3 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); NetworkSpawnManager spawnManager = NetworkManager.Singleton.SpawnManager; ulong key = default(ulong); Vector3 scale = default(Vector3); for (int j = 0; j < num3; j++) { ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValueSafe(ref scale); if (spawnManager != null && spawnManager.SpawnedObjects.TryGetValue(key, out var value)) { GrabbableObject component = ((Component)value).GetComponent<GrabbableObject>(); if ((Object)(object)component != (Object)null) { HeldItems.FixOriginalScale(component, scale); } } } } private static void OnNotice(ulong senderClientId, FastBufferReader reader) { if (senderClientId == 0L) { string text = default(string); ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false); SizeCommand.Print(text); } } } }