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 ShipMedbay v0.1.0
ShipMedbay.dll
Decompiled 35 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using ModMenu; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; [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("ShipMedbay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+df33474d6b522eba7662ec23fcb0c2c7c7927dc6")] [assembly: AssemblyProduct("ShipMedbay")] [assembly: AssemblyTitle("ShipMedbay")] [assembly: AssemblyVersion("0.1.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 ShipMedbay { internal static class Art { internal const float Height = 2.86f; internal const float HalfWidth = 0.6f; internal const float ConsoleOut = 0.7f; internal const float Back = -0.5f; internal const float Front = 0.63f; internal const float InnerHalf = 0.44f; internal const float InnerBack = -0.41f; internal const float RingLow = 0.25f; internal const float RingHigh = 2.35f; internal static readonly Vector3 Console = new Vector3(-0.62f, 1.25f, 0.42f); internal static readonly Dictionary<string, Mesh> Meshes = new Dictionary<string, Mesh>(); internal static Texture2D Palette; internal static void Load() { try { ReadMeshes(Res("medbay.bin")); Palette = Tex("palette"); } catch (Exception ex) { Plugin.Log.LogError((object)("Ship Medbay: art failed to load: " + ex)); } string[] array = new string[4] { "Frame", "Glow", "Ring", "RingGlow" }; foreach (string text in array) { if (!Meshes.ContainsKey(text)) { Plugin.Log.LogError((object)("Ship Medbay: mesh " + text + " missing from medbay.bin.")); } } } private static Stream Res(string name) { return typeof(Art).Assembly.GetManifestResourceStream("ShipMedbay." + name); } private static void ReadMeshes(Stream s) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown if (s == null) { Plugin.Log.LogError((object)"Ship Medbay: medbay.bin is missing."); return; } using (s) { using GZipStream input = new GZipStream(s, CompressionMode.Decompress); using BinaryReader binaryReader = new BinaryReader(input); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "BBD1") { Plugin.Log.LogError((object)"Ship Medbay: medbay.bin isn't BBD1."); return; } int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string text = Encoding.UTF8.GetString(binaryReader.ReadBytes(binaryReader.ReadInt32())); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; for (int j = 0; j < num2; j++) { array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array4 = new int[num3]; for (int k = 0; k < num3; k++) { array4[k] = binaryReader.ReadUInt16(); } Mesh val = new Mesh { name = "ShipMedbay." + text }; val.vertices = array; val.normals = array2; val.uv = array3; val.triangles = array4; val.RecalculateBounds(); val.RecalculateTangents(); val.UploadMeshData(true); Meshes[text] = val; } } } private static Texture2D Tex(string name) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown using Stream stream = Res(name + ".png"); if (stream == null) { Plugin.Log.LogError((object)("Ship Medbay: texture " + name + " is missing.")); return null; } MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = "ShipMedbay." + name, wrapMode = (TextureWrapMode)1, anisoLevel = 4 }; ImageConversion.LoadImage(val, memoryStream.ToArray(), false); ((Texture)val).filterMode = (FilterMode)2; return val; } } internal static class Sounds { internal static AudioClip Hum; internal static AudioClip Chime; internal static AudioClip Buzz; internal static AudioClip Surge; private const int Rate = 44100; internal static void Make() { if (!((Object)(object)Hum != (Object)null)) { Hum = Clip("ShipMedbay.Hum", 2f, delegate(float t) { float num = 0.75f + 0.25f * Mathf.Sin(MathF.PI * 4f * t); float num2 = 0.55f * Mathf.Sin(MathF.PI * 360f * t) + 0.3f * Mathf.Sin(MathF.PI * 540f * t) + 0.12f * Mathf.Sin(MathF.PI * 1080f * t); float num3 = t % 0.5f; float num4 = ((num3 < 0.03f) ? (0.35f * Mathf.Sin(MathF.PI * 3600f * t) * (1f - num3 / 0.03f)) : 0f); return 0.22f * (num2 * num + num4); }); Chime = Clip("ShipMedbay.Chime", 1.1f, delegate(float t) { float num = ((t < 0.45f) ? Note(t, 784f, 0.45f) : 0f); float num2 = ((t >= 0.22f) ? Note(t - 0.22f, 1175f, 0.88f) : 0f); return 0.35f * (num + num2); }); Buzz = Clip("ShipMedbay.Buzz", 0.45f, delegate(float t) { float num = Mathf.Clamp01(t / 0.01f) * Mathf.Clamp01((0.45f - t) / 0.08f); float num2 = Mathf.Sign(Mathf.Sin(MathF.PI * 220f * t)) * 0.5f + 0.5f * Mathf.Sin(MathF.PI * 330f * t); return 0.18f * num * num2; }); Surge = Clip("ShipMedbay.Surge", 1.8f, delegate(float t) { float num = t / 1.8f; float num2 = Mathf.Clamp01(t / 0.05f) * ((num < 0.85f) ? 1f : Mathf.Clamp01((1f - num) / 0.15f)); float num3 = MathF.PI * 2f * (120f * t + 900f * t * t * t / 9.719999f); return 0.25f * num2 * (Mathf.Sin(num3) * 0.7f + 0.3f * Mathf.Sin(2f * num3)) * (0.6f + 0.4f * Mathf.Sin(MathF.PI * 18f * t)); }); } } private static float Note(float t, float f, float len) { return Mathf.Clamp01(t / 0.008f) * Mathf.Exp(-4.5f * t / len) * (Mathf.Sin(MathF.PI * 2f * f * t) + 0.3f * Mathf.Sin(MathF.PI * 4f * f * t)); } private static AudioClip Clip(string name, float seconds, Func<float, float> f) { int num = Mathf.RoundToInt(seconds * 44100f); float[] array = new float[num]; for (int i = 0; i < num; i++) { array[i] = Mathf.Clamp(f((float)i / 44100f), -1f, 1f); } AudioClip obj = AudioClip.Create(name, num, 1, 44100, false); obj.SetData(array, 0); return obj; } } internal static class Hooks { internal const string NewShipGuid = "daniel.lethalcompany.newship"; private static Func<GameObject> _hull; internal static GameObject Hull { get { try { return _hull?.Invoke(); } catch (Exception) { return null; } } } internal static void Init() { if (Chainloader.PluginInfos.TryGetValue("daniel.lethalcompany.newship", out var value)) { Type type = ((object)value.Instance).GetType().Assembly.GetType("NewShip.Applier"); MethodInfo methodInfo = ((type != null) ? AccessTools.PropertyGetter(type, "Instance") : null); if (methodInfo != null) { _hull = (Func<GameObject>)methodInfo.CreateDelegate(typeof(Func<GameObject>)); } else { Plugin.Log.LogWarning((object)"Ship Medbay: couldn't read NewShip's fitted hull; the pod only looks for its wall when it's built."); } } } } internal class MedState { public int Price; public int HealAmount; public int HealCost; public int FreeHealsPerDay; public int ReviveCost; public int ReviveHealth; public int RevivesPerDay; public bool ReviveInOrbit; public bool HasSpot; public Vector3 Pos; public Vector3 Normal; public byte Mode; public int Subject = -1; public float EndsAt; public float Duration; public int FreeLeft; public int RevivesLeft; public const byte Idle = 0; public const byte Healing = 1; public const byte Reviving = 2; } internal static class Host { internal static MedState State = new MedState(); internal static bool Dirty; private static bool _wasInOrbit = true; private static float _outsideFor; private static ulong _requester; private static Terminal _term; private static Terminal Term { get { if (!((Object)(object)_term != (Object)null)) { return _term = Object.FindObjectOfType<Terminal>(); } return _term; } } internal static void OnSessionStart() { State = new MedState(); _wasInOrbit = true; _outsideFor = 0f; Placement.OnSessionStart(); if (Net.IsHost) { FillNumbers(); NewDay(); } } internal static void Received(MedState s) { MedState state = State; State = s; Store.ApplyPrice(s.Price); Store.RefreshInfo(); Medbay.StateChanged(state, s); } private static void FillNumbers() { MedState state = State; int num = state.Price ^ (state.HealAmount * 7) ^ (state.HealCost * 31) ^ (state.FreeHealsPerDay * 131) ^ (state.ReviveCost * 521) ^ (state.ReviveHealth * 2053) ^ (state.RevivesPerDay * 8191) ^ (state.ReviveInOrbit ? 1073741824 : 0); state.Price = Plugin.Price.Value; state.HealAmount = Plugin.HealAmount.Value; state.HealCost = Plugin.HealCost.Value; state.FreeHealsPerDay = Plugin.FreeHeals.Value; state.ReviveCost = Plugin.ReviveCost.Value; state.ReviveHealth = Plugin.ReviveHealth.Value; state.RevivesPerDay = Plugin.Revives.Value; state.ReviveInOrbit = Plugin.ReviveInOrbit.Value; if ((state.Price ^ (state.HealAmount * 7) ^ (state.HealCost * 31) ^ (state.FreeHealsPerDay * 131) ^ (state.ReviveCost * 521) ^ (state.ReviveHealth * 2053) ^ (state.RevivesPerDay * 8191) ^ (state.ReviveInOrbit ? 1073741824 : 0)) != num) { Dirty = true; Store.ApplyPrice(state.Price); Store.RefreshInfo(); } } internal static void NewDay() { State.FreeLeft = Plugin.FreeHeals.Value; State.RevivesLeft = Plugin.Revives.Value; Dirty = true; Plugin.Debug($"new day: {State.FreeLeft} free heals, {State.RevivesLeft} revives"); } internal static void Second() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } FillNumbers(); if (Store.Unlocked) { if (Placement.HostCheckSpot(State)) { Dirty = true; if (State.Mode != 0 && !State.HasSpot) { Stop("the pod is being moved"); } } } else if (State.HasSpot) { State.HasSpot = false; Stop(null); Dirty = true; } bool inShipPhase = instance.inShipPhase; if (_wasInOrbit && !inShipPhase) { NewDay(); } _wasInOrbit = inShipPhase; if (Dirty) { Dirty = false; Net.Broadcast(); Medbay.StateChanged(null, State); } } internal static void Tick() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) MedState state = State; if (state.Mode == 0) { return; } StartOfRound instance = StartOfRound.Instance; PlayerControllerB val = Player(state.Subject); if ((Object)(object)val == (Object)null) { Stop("the patient left"); return; } if (state.Mode == 1) { if (val.isPlayerDead || !val.isPlayerControlled) { Stop("the patient died"); return; } _outsideFor = (Medbay.InPod(((Component)val).transform.position, 0.35f, feet: true) ? 0f : (_outsideFor + Time.deltaTime)); if (_outsideFor > 1f) { Stop("the patient stepped out"); return; } } else { if (!val.isPlayerDead) { Stop(null); return; } if (!state.ReviveInOrbit && (instance.inShipPhase || instance.shipIsLeaving)) { Stop("the ship is leaving"); return; } if ((Object)(object)Medbay.BodyInPod(val, 0.3f) == (Object)null) { Stop("the body was moved out of the pod"); return; } } if (!(Time.time < state.EndsAt)) { Finish(val); } } private static void Finish(PlayerControllerB p) { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) MedState state = State; int subject = state.Subject; byte mode = state.Mode; state.Mode = 0; state.Subject = -1; Dirty = true; if (mode == 1) { bool flag = state.FreeLeft > 0; if (!flag && !Pay(state.HealCost)) { Net.Deny(_requester, $"The heal needs ${state.HealCost} and the ship hasn't got it."); return; } if (flag) { state.FreeLeft--; } Plugin.Log.LogInfo((object)string.Format("Ship Medbay: healed {0} (+{1}{2}).", p.playerUsername, state.HealAmount, flag ? ", free" : $", ${state.HealCost}")); Net.SendHealed(subject, state.HealAmount); } else { if (state.RevivesLeft <= 0) { Net.Deny(_requester, "The pod has done its revive for today."); return; } if (!Pay(state.ReviveCost)) { Net.Deny(_requester, $"A revive needs ${state.ReviveCost} and the ship hasn't got it."); return; } state.RevivesLeft--; Vector3 val = StartOfRound.Instance.elevatorTransform.TransformDirection(state.Normal); Quaternion val2 = Quaternion.LookRotation(new Vector3(val.x, 0f, val.z)); float y = ((Quaternion)(ref val2)).eulerAngles.y; Plugin.Log.LogInfo((object)$"Ship Medbay: revived {p.playerUsername} with {state.ReviveHealth} HP (${state.ReviveCost})."); Net.SendRevived(subject, state.Pos + Vector3.up * 0.06f, y, state.ReviveHealth); } Net.Broadcast(); Dirty = false; Medbay.StateChanged(null, state); } internal static void Stop(string why) { if (State.Mode != 0) { Plugin.Debug("scan stopped: " + (why ?? "(no reason)")); State.Mode = 0; State.Subject = -1; Dirty = true; if (why != null) { Net.Deny(_requester, "Scan stopped: " + why + "."); } } } internal static void Request(ulong sender, byte cmd, int target) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) MedState state = State; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } PlayerControllerB val = PlayerOf(sender); if (cmd == 3) { if (state.Mode == 1 && (Object)(object)val != (Object)null && state.Subject == Index(val)) { Stop(null); } } else if (!Store.Unlocked || !state.HasSpot) { Net.Deny(sender, "The medbay isn't set up."); } else if (state.Mode != 0) { Net.Deny(sender, (state.Subject >= 0 && (Object)(object)Player(state.Subject) != (Object)null) ? ("The pod is busy with " + Player(state.Subject).playerUsername + ".") : "The pod is busy."); } else { if ((Object)(object)val == (Object)null) { return; } switch (cmd) { case 1: if (!val.isPlayerDead && val.isPlayerControlled) { if (!Medbay.InPod(((Component)val).transform.position, 0.35f, feet: true)) { Net.Deny(sender, "Step right into the pod to be healed."); } else if (val.health >= 100 && !val.criticallyInjured) { Net.Deny(sender, "You're already in full health."); } else if (state.FreeLeft <= 0 && Credits() < state.HealCost) { Net.Deny(sender, $"Today's free heal is used and a heal costs ${state.HealCost}. The ship has ${Credits()}."); } else { Begin(sender, 1, Index(val), Plugin.HealSeconds.Value); } } break; case 2: { PlayerControllerB val2 = Player(target); if ((Object)(object)val2 == (Object)null || !val2.isPlayerDead) { Net.Deny(sender, "There's no one to revive."); } else if (!state.ReviveInOrbit && instance.inShipPhase) { Net.Deny(sender, "Revives only work landed on a moon."); } else if (instance.shipIsLeaving) { Net.Deny(sender, "The ship is leaving."); } else if (state.RevivesLeft <= 0) { Net.Deny(sender, (state.RevivesPerDay > 0) ? "The pod has done its revive for today." : "Revives are switched off on this ship."); } else if (Credits() < state.ReviveCost) { Net.Deny(sender, $"A revive costs ${state.ReviveCost}. The ship has ${Credits()}."); } else if ((Object)(object)Medbay.BodyInPod(val2, 0.3f) == (Object)null) { Net.Deny(sender, "Lay " + val2.playerUsername + "'s body in the pod first."); } else { Begin(sender, 2, target, Plugin.ReviveSeconds.Value); } break; } } } } private static void Begin(ulong sender, byte mode, int subject, float seconds) { MedState state = State; _requester = sender; _outsideFor = 0f; state.Mode = mode; state.Subject = subject; state.Duration = seconds; state.EndsAt = Time.time + seconds; Plugin.Debug(string.Format("{0} scan for player {1}, {2:0.0} s", (mode == 1) ? "heal" : "revive", subject, seconds)); Dirty = false; Net.Broadcast(); Medbay.StateChanged(null, state); } internal static string CheatHealMe() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || val.isPlayerDead) { return "you need to be alive"; } Net.SendHealed(Index(val), State.HealAmount); return $"healed +{State.HealAmount}"; } internal static string CheatReviveFirstDead() { //IL_0065: 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) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || !State.HasSpot) { return "the medbay isn't set up"; } for (int i = 0; i < instance.allPlayerScripts.Length; i++) { PlayerControllerB val = instance.allPlayerScripts[i]; if (!((Object)(object)val == (Object)null) && val.isPlayerDead) { if (State.Mode != 0) { Stop(null); } Vector3 val2 = instance.elevatorTransform.TransformDirection(State.Normal); Quaternion val3 = Quaternion.LookRotation(new Vector3(val2.x, 0f, val2.z)); float y = ((Quaternion)(ref val3)).eulerAngles.y; Net.SendRevived(i, State.Pos + Vector3.up * 0.06f, y, State.ReviveHealth); Net.Broadcast(); return "revived " + val.playerUsername; } } return "no one is dead"; } internal static string CheatResetDay() { NewDay(); return $"{State.FreeLeft} free heals, {State.RevivesLeft} revives today"; } internal static PlayerControllerB Player(int i) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || i < 0 || i >= instance.allPlayerScripts.Length) { return null; } return instance.allPlayerScripts[i]; } internal static int Index(PlayerControllerB p) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)p == (Object)null) { return -1; } return Array.IndexOf(instance.allPlayerScripts, p); } private static PlayerControllerB PlayerOf(ulong cid) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return null; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.actualClientId == cid && (val.isPlayerControlled || val.isPlayerDead)) { return val; } } return null; } internal static int Credits() { if (!((Object)(object)Term != (Object)null)) { return 0; } return Term.groupCredits; } private static bool Pay(int cost) { if (cost <= 0) { return true; } Terminal term = Term; if ((Object)(object)term == (Object)null || term.groupCredits < cost) { return false; } term.groupCredits = Mathf.Clamp(term.groupCredits - cost, 0, 10000000); term.SyncGroupCreditsClientRpc(term.groupCredits, term.numberOfItemsInDropship); return true; } } internal static class Medbay { internal static GameObject Root; private static Transform _ring; private static Material _glowMat; private static Material _ringGlowMat; private static AudioSource _hum; private static AudioSource _fx; private static InteractTrigger _console; private static Vector3 _builtPos; private static Vector3 _builtNormal; private static float _ringY = 2.35f; private static float _inPodFor; private static float _glow; private static bool _askedThisVisit; private static byte _shownMode; private static int _shownSubject = -1; private static string _tip = null; private static readonly Color GlowIdle = new Color(0.2f, 0.55f, 0.5f); private static readonly Color GlowHeal = new Color(0.4f, 1f, 0.85f); private static readonly Color GlowRevive = new Color(1f, 0.85f, 0.55f); private static PlayerControllerB _bodyHere; private static float _bodyCheckedAt = -1f; internal static bool Built => (Object)(object)Root != (Object)null; internal static void Check() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) MedState state = Host.State; if (Built && (state.Pos != _builtPos || state.Normal != _builtNormal)) { Remove(); } if (!Built) { Build(state); } } internal static void Remove() { if ((Object)(object)Root != (Object)null) { Object.Destroy((Object)(object)Root); } Root = null; _ring = null; _hum = null; _fx = null; _console = null; _shownMode = 0; _shownSubject = -1; _tip = null; } internal static bool IsOurs(Transform t) { if ((Object)(object)Root != (Object)null && (Object)(object)t != (Object)null) { return t.IsChildOf(Root.transform); } return false; } private static void Build(MedState s) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00aa: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.elevatorTransform == (Object)null) && s.HasSpot && Art.Meshes.ContainsKey("Frame")) { Sounds.Make(); Material mat = Mat(LitSource(instance), "Body", (Texture)(object)Art.Palette); _glowMat = UnlitMat("Glow", GlowIdle); _ringGlowMat = UnlitMat("RingGlow", GlowIdle); Root = new GameObject("ShipMedbay.Pod"); Root.transform.SetParent(instance.elevatorTransform, false); Root.transform.localPosition = s.Pos; Root.transform.localRotation = Quaternion.LookRotation(s.Normal, Vector3.up); _builtPos = s.Pos; _builtNormal = s.Normal; Part("Frame", Root.transform, Vector3.zero, mat, (ShadowCastingMode)1); Part("Glow", Root.transform, Vector3.zero, _glowMat, (ShadowCastingMode)0); _ringY = 2.35f; _ring = Part("Ring", Root.transform, new Vector3(0f, _ringY, 0f), mat, (ShadowCastingMode)1); Part("RingGlow", _ring, Vector3.zero, _ringGlowMat, (ShadowCastingMode)0); int num = LayerMask.NameToLayer("Colliders"); if (num < 0) { num = 0; } float num2 = 2.84f; Solid("Back", num, new Vector3(0f, num2 * 0.5f, -0.45499998f), new Vector3(1.2f, num2, 0.09f)); int[] array = new int[2] { -1, 1 }; foreach (int num3 in array) { float num4 = (float)num3 * 0.44f; float num5 = (float)num3 * 0.6f; Solid((num3 < 0) ? "WallR" : "WallL", num, new Vector3((num4 + num5) * 0.5f, num2 * 0.5f, 0.045f), new Vector3(Mathf.Abs(num5 - num4), num2, 0.90999997f)); } Solid("Canopy", num, new Vector3(0f, 2.76f, 0.065f), new Vector3(1.24f, 0.2f, 1.13f)); Solid("Console", num, new Vector3(Art.Console.x + 0.005f, Art.Console.y - 0.02f, Art.Console.z - 0.04f), new Vector3(0.15f, 0.44f, 0.16f)); _console = ConsoleTrigger(); _hum = Audio(((Component)_ring).gameObject, 1f, 12f); _hum.loop = true; _hum.clip = Sounds.Hum; _fx = Audio(((Component)Root.transform.Find("Frame")).gameObject, 2f, 25f); _shownMode = 0; _shownSubject = -1; _tip = null; _glow = 0f; Plugin.Debug($"pod built at {s.Pos} facing {s.Normal} (ship local)"); } } private static Transform Part(string mesh, Transform parent, Vector3 at, Material mat, ShadowCastingMode shadows) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(mesh); val.transform.SetParent(parent, false); val.transform.localPosition = at; if (!Art.Meshes.TryGetValue(mesh, out var value)) { return val.transform; } val.AddComponent<MeshFilter>().sharedMesh = value; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = mat; ((Renderer)obj).shadowCastingMode = shadows; return val.transform; } private static void Solid(string name, int layer, Vector3 centre, Vector3 size) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Solid" + name) { layer = layer }; val.transform.SetParent(Root.transform, false); BoxCollider obj = val.AddComponent<BoxCollider>(); obj.center = centre; obj.size = size; } private static AudioSource Audio(GameObject on, float min, float max) { AudioSource obj = on.AddComponent<AudioSource>(); obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = min; obj.maxDistance = max; obj.playOnAwake = false; obj.dopplerLevel = 0f; return obj; } private static InteractTrigger ConsoleTrigger() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //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_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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Console"); val.transform.SetParent(Root.transform, false); val.transform.localPosition = Art.Console + new Vector3(-0.02f, -0.02f, 0.02f); int num = LayerMask.NameToLayer("InteractableObject"); val.layer = ((num >= 0) ? num : 9); val.tag = "InteractTrigger"; BoxCollider obj = val.AddComponent<BoxCollider>(); ((Collider)obj).isTrigger = true; obj.size = new Vector3(0.3f, 0.5f, 0.3f); InteractTrigger val2 = val.AddComponent<InteractTrigger>(); FieldInfo[] fields = typeof(InteractTrigger).GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (typeof(UnityEventBase).IsAssignableFrom(fieldInfo.FieldType) && fieldInfo.GetValue(val2) == null) { fieldInfo.SetValue(val2, Activator.CreateInstance(fieldInfo.FieldType)); } } PlayerControllerB val3 = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); val2.hoverTip = ""; val2.disabledHoverTip = ""; val2.hoverIcon = (((Object)(object)val3 != (Object)null) ? val3.grabItemIcon : null); val2.interactable = false; val2.oneHandedItemAllowed = true; val2.twoHandedItemAllowed = true; val2.holdInteraction = false; val2.interactCooldown = true; val2.cooldownTime = 0.6f; ((UnityEvent<PlayerControllerB>)(object)val2.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate { OnConsole(); }); return val2; } internal static bool InPod(Vector3 world, float margin, bool feet = false) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0082: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) MedState state = Host.State; StartOfRound instance = StartOfRound.Instance; if (!state.HasSpot || (Object)(object)instance == (Object)null) { return false; } Transform elevatorTransform = instance.elevatorTransform; Vector3 val = elevatorTransform.TransformPoint(state.Pos); Vector3 val2 = Quaternion.Inverse(Quaternion.LookRotation(elevatorTransform.TransformDirection(state.Normal), Vector3.up)) * (world - val); if (Mathf.Abs(val2.x) > 0.44f + margin * 0.5f) { return false; } if (val2.z < -0.51f || val2.z > 0.63f + margin) { return false; } if (!feet) { if (val2.y > -0.4f) { return val2.y < 2.35f; } return false; } if (val2.y > -0.4f) { return val2.y < 1f; } return false; } internal static DeadBodyInfo BodyInPod(PlayerControllerB p, float margin) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) int num = Host.Index(p); if (num < 0) { return null; } DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>(); foreach (DeadBodyInfo val in array) { if ((Object)(object)val == (Object)null || val.playerObjectId != num || !((Component)val).gameObject.activeInHierarchy || val.bodyParts == null) { continue; } int num2 = 0; Rigidbody[] bodyParts = val.bodyParts; foreach (Rigidbody val2 in bodyParts) { if ((Object)(object)val2 != (Object)null && InPod(val2.position, margin)) { num2++; } } if (num2 * 2 >= val.bodyParts.Length) { return val; } } return null; } private static PlayerControllerB BodyHere() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return null; } if (Time.time - _bodyCheckedAt < 0.25f && ((Object)(object)_bodyHere == (Object)null || _bodyHere.isPlayerDead)) { return _bodyHere; } _bodyCheckedAt = Time.time; _bodyHere = ((IEnumerable<PlayerControllerB>)instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => (Object)(object)p != (Object)null && p.isPlayerDead && (Object)(object)BodyInPod(p, 0.3f) != (Object)null)); return _bodyHere; } internal static void StateChanged(MedState old, MedState s) { } internal static void Denied(string why) { if (!string.IsNullOrEmpty(why)) { HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Ship Medbay", why, true, false, "LC_Tip1"); } Play(Sounds.Buzz, 0.8f); } } internal static void Healed(PlayerControllerB p) { Play(Sounds.Chime, 1f); _glow = 1.5f; } internal static void Revived(PlayerControllerB p) { Play(Sounds.Surge, 1f); Play(Sounds.Chime, 0.8f); _glow = 2.5f; } private static void OnConsole() { if (Host.State.Mode == 0) { PlayerControllerB val = BodyHere(); if ((Object)(object)val != (Object)null) { Net.Request(2, Host.Index(val)); } } } internal static void Tick() { //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0205: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_027b: 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_02b4: Unknown result type (might be due to invalid IL or missing references) MedState state = Host.State; PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (state.Mode != _shownMode || state.Subject != _shownSubject) { if (state.Mode != 0) { if ((Object)(object)_hum != (Object)null && !_hum.isPlaying) { _hum.volume = Plugin.Volume.Value; _hum.Play(); } if ((Object)(object)val != (Object)null && state.Subject == Host.Index(val) && state.Mode == 1) { HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("Ship Medbay", "Scanning. Stay in the pod.", false, false, "LC_Tip1"); } } } else if ((Object)(object)_hum != (Object)null) { _hum.Stop(); } _shownMode = state.Mode; _shownSubject = state.Subject; } if ((Object)(object)_hum != (Object)null && _hum.isPlaying) { _hum.volume = Plugin.Volume.Value; } float num = 2.35f; if (state.Mode != 0) { float num2 = Mathf.PingPong(Time.time / 1.4f, 1f); num = Mathf.Lerp(2.35f, (state.Mode == 2) ? 0.25f : 0.35f, Mathf.SmoothStep(0f, 1f, num2)); } float num3 = 1f - Mathf.Exp((0f - ((state.Mode != 0) ? 20f : 4f)) * Time.deltaTime); _ringY = Mathf.Lerp(_ringY, num, num3); if ((Object)(object)_ring != (Object)null) { _ring.localPosition = new Vector3(0f, _ringY, 0f); } _glow = Mathf.Max(0f, _glow - Time.deltaTime * 1.5f); Color val2 = ((state.Mode == 1) ? GlowHeal : ((state.Mode == 2) ? GlowRevive : GlowIdle)); float num4 = ((state.Mode != 0) ? (1.1f + 0.25f * Mathf.Sin(Time.time * 9f)) : 1f); SetUnlit(_glowMat, val2 * (num4 + _glow)); SetUnlit(_ringGlowMat, val2 * ((state.Mode != 0) ? 1.6f : 0.6f) * (1f + _glow)); if ((Object)(object)val != (Object)null && !val.isPlayerDead && val.isPlayerControlled && InPod(((Component)val).transform.position, 0f, feet: true)) { _inPodFor += Time.deltaTime; bool flag = val.health < 100 || val.criticallyInjured; if (!_askedThisVisit && flag && state.Mode == 0 && _inPodFor > 0.8f) { _askedThisVisit = true; Net.Request(1); } } else { _inPodFor = 0f; _askedThisVisit = false; } UpdateConsole(state, val); } private static void UpdateConsole(MedState s, PlayerControllerB me) { if ((Object)(object)_console == (Object)null) { return; } bool flag = false; string text; if ((Object)(object)me == (Object)null || me.isPlayerDead) { text = ""; } else if (s.Mode == 1) { text = "Healing " + Name(s.Subject) + "..."; } else if (s.Mode == 2) { text = "Reviving " + Name(s.Subject) + "..."; } else { PlayerControllerB val = BodyHere(); StartOfRound instance = StartOfRound.Instance; if ((Object)(object)val == (Object)null) { text = "Medbay: " + Plural(s.FreeLeft, "free heal") + ", " + Plural(s.RevivesLeft, "revive") + " left today\nLay a body in the pod to revive"; } else if (s.RevivesLeft <= 0) { text = ((s.RevivesPerDay > 0) ? "Today's revive is used" : "Revives are switched off"); } else if (!s.ReviveInOrbit && (Object)(object)instance != (Object)null && instance.inShipPhase) { text = "Revives only work landed on a moon"; } else { flag = true; text = $"Revive {val.playerUsername} (${s.ReviveCost}) : [E]"; } } if (!(text == _tip) || _console.interactable != flag) { _tip = text; _console.hoverTip = text; _console.disabledHoverTip = text; _console.interactable = flag; } } private static string Name(int i) { PlayerControllerB val = Host.Player(i); if (!((Object)(object)val != (Object)null)) { return "a crewmate"; } return val.playerUsername; } private static string Plural(int n, string what) { if (n != 1) { return $"{n} {what}s"; } return "1 " + what; } private static void Play(AudioClip clip, float vol) { if (!((Object)(object)clip == (Object)null) && !((Object)(object)_fx == (Object)null)) { _fx.PlayOneShot(clip, vol * Plugin.Volume.Value); } } private static Material LitSource(StartOfRound sor) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown ManualCameraRenderer ms = sor.mapScreen; if ((Object)(object)ms != (Object)null && (Object)(object)ms.mesh != (Object)null) { Material val = ((Renderer)ms.mesh).sharedMaterials.Where((Material x, int i) => i != ms.materialIndex && (Object)(object)x != (Object)null && (Object)(object)x.shader != (Object)null && ((Object)x.shader).name.Contains("Lit") && !((Object)x.shader).name.Contains("Unlit")).FirstOrDefault(); if ((Object)(object)val != (Object)null) { return val; } } Material val2 = (from r in ((Component)sor.elevatorTransform).GetComponentsInChildren<MeshRenderer>(true) select ((Renderer)r).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material x) => (Object)(object)x != (Object)null && (Object)(object)x.shader != (Object)null && ((Object)x.shader).name == "HDRP/Lit")); if ((Object)(object)val2 != (Object)null) { return val2; } Shader val3 = Shader.Find("HDRP/Lit"); if (!((Object)(object)val3 != (Object)null)) { return null; } return new Material(val3); } private static Material Mat(Material src, string name, Texture tex) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_00fa: 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_0134: Unknown result type (might be due to invalid IL or missing references) Material val = (((Object)(object)src != (Object)null) ? new Material(src) : new Material(Shader.Find("Standard"))); ((Object)val).name = "ShipMedbay." + name; string[] array = new string[7] { "_NORMALMAP", "_NORMALMAP_TANGENT_SPACE", "_MASKMAP", "_DETAIL_MAP", "_EMISSIVE_COLOR_MAP", "_BENTNORMALMAP", "_HEIGHTMAP" }; foreach (string text in array) { val.DisableKeyword(text); } array = new string[6] { "_NormalMap", "_MaskMap", "_DetailMap", "_EmissiveColorMap", "_BentNormalMap", "_HeightMap" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetTexture(text2, (Texture)null); } } if (val.HasProperty("_EmissiveColor")) { val.SetColor("_EmissiveColor", Color.black); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", Color.white); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0.15f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.5f); } if (val.HasProperty("_BaseColorMap")) { val.SetTexture("_BaseColorMap", tex); } if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", tex); } return val; } private static Material UnlitMat(string name, Color c) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("HDRP/Unlit"); if ((Object)(object)val == (Object)null) { return null; } Material val2 = new Material(val) { name = "ShipMedbay." + name }; try { HDMaterial.ValidateMaterial(val2); } catch (Exception ex) { Plugin.Debug("unlit material: " + ex.Message); } SetUnlit(val2, c); return val2; } private static void SetUnlit(Material m, Color c) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0045: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m == (Object)null)) { m.SetColor("_UnlitColor", new Color(Mathf.LinearToGammaSpace(Mathf.Clamp01(c.r)), Mathf.LinearToGammaSpace(Mathf.Clamp01(c.g)), Mathf.LinearToGammaSpace(Mathf.Clamp01(c.b)), 1f)); } } } internal static class MenuHooks { internal const string ModMenuGuid = "daniel.lethalcompany.modmenu"; private const string Tab = "Ship Medbay"; [MethodImpl(MethodImplOptions.NoInlining)] internal static void Register() { MenuApi.Button("Ship Medbay", "Unlock the medbay (free)", (Func<string>)Store.HostUnlockFree, true, true, (Func<string>)(() => (Store.Index >= 0) ? ((!Store.Unlocked) ? null : "already aboard") : "join a lobby first"), (string)null); MenuApi.Button("Ship Medbay", "Heal me now", (Func<string>)Host.CheatHealMe, true, true, (Func<string>)(() => Store.Unlocked ? null : "unlock the medbay first"), "no pod, no charge"); MenuApi.Button("Ship Medbay", "Revive the first dead player", (Func<string>)Host.CheatReviveFirstDead, true, true, (Func<string>)(() => Medbay.Built ? null : "unlock the medbay first"), "in the pod, no body or charge needed"); MenuApi.Button("Ship Medbay", "Give back today's heals and revives", (Func<string>)Host.CheatResetDay, true, true, (Func<string>)(() => Store.Unlocked ? null : "unlock the medbay first"), (string)null); MenuApi.Button("Ship Medbay", "Find the pod a wall again", (Func<string>)Placement.Refit, true, false, (Func<string>)(() => Store.Unlocked ? null : "unlock the medbay first"), (string)null); try { RegisterSettings(); } catch (Exception ex) { Plugin.Log.LogInfo((object)("Ship Medbay: settings rows need Mod Menu 0.3.6 or later (" + ex.GetType().Name + ")")); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void RegisterSettings() { MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.Price, "Price", true, "the store price, sent to every player", (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.FreeHeals, "Free heals a day", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.HealCost, "Heal price", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.Revives, "Revives a day", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.ReviveCost, "Revive price", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.ReviveInOrbit, "Revive in orbit", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.Volume, "Volume", false, "0 to 1", (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.VerboseLog, "Verbose log", false, "testing: wall probe, scans and revives", (Func<string>)null); MenuApi.Tuning((Action)delegate { MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.HealAmount, "Health a heal gives", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.HealSeconds, "Heal scan (s)", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.ReviveHealth, "Health after revive", true, (string)null, (Func<string>)null); MenuApi.Setting("Ship Medbay", (ConfigEntryBase)(object)Plugin.ReviveSeconds, "Revive scan (s)", true, (string)null, (Func<string>)null); }); } } internal static class Net { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__18_0; public static HandleNamedMessageDelegate <>9__18_1; public static HandleNamedMessageDelegate <>9__18_2; public static HandleNamedMessageDelegate <>9__18_3; public static HandleNamedMessageDelegate <>9__18_4; public static HandleNamedMessageDelegate <>9__18_5; internal void <Register>b__18_0(ulong sender, FastBufferReader r) { if (IsHost) { SendState(sender); } } internal void <Register>b__18_1(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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) if (IsHost) { byte cmd = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref cmd, default(ForPrimitives)); int target = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref target, default(ForPrimitives)); Host.Request(sender, cmd, target); } } internal void <Register>b__18_2(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0091: 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_00a7: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { byte b = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); if (b != 1) { Plugin.Log.LogWarning((object)$"Ship Medbay: the host has another version of the mod (format {b}, ours {(byte)1})."); return; } MedState medState = new MedState(); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.Price, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.HealAmount, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.HealCost, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.FreeHealsPerDay, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.ReviveCost, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.ReviveHealth, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.RevivesPerDay, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref medState.ReviveInOrbit, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref medState.HasSpot, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref medState.Pos); ((FastBufferReader)(ref r)).ReadValueSafe(ref medState.Normal); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref medState.Mode, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.Subject, default(ForPrimitives)); float num = default(float); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref num, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref medState.Duration, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.FreeLeft, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.RevivesLeft, default(ForPrimitives)); medState.EndsAt = Time.time + num; Host.Received(medState); } } internal void <Register>b__18_3(ulong sender, FastBufferReader r) { if (!IsHost) { string why = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref why, false); Medbay.Denied(why); } } internal void <Register>b__18_4(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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) if (!IsHost) { int who = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref who, default(ForPrimitives)); int amount = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref amount, default(ForPrimitives)); Revive.Heal(who, amount); } } internal void <Register>b__18_5(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004b: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { int who = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref who, default(ForPrimitives)); Vector3 shipLocalPos = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref shipLocalPos); float yaw = default(float); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref yaw, default(ForPrimitives)); int hp = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref hp, default(ForPrimitives)); Revive.Apply(who, shipLocalPos, yaw, hp); } } } private const string Hello = "ShipMedbay.Hello"; private const string StateMsg = "ShipMedbay.State"; private const string ReqMsg = "ShipMedbay.Req"; private const string DenyMsg = "ShipMedbay.Deny"; private const string HealedMsg = "ShipMedbay.Healed"; private const string RevivedMsg = "ShipMedbay.Revived"; private const byte Version = 1; internal const byte ReqHeal = 1; internal const byte ReqRevive = 2; internal const byte ReqCancel = 3; private static CustomMessagingManager _registeredOn; private static bool _helloSent; internal static NetworkManager NM => NetworkManager.Singleton; internal static bool Online { get { if ((Object)(object)NM != (Object)null && NM.IsListening) { return NM.CustomMessagingManager != null; } return false; } } internal static bool IsHost { get { if (Online) { return NM.IsServer; } return false; } } internal static void Register() { //IL_0060: 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_006b: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //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_00bf: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown NetworkManager nM = NM; if ((Object)(object)nM == (Object)null || nM.CustomMessagingManager == null || _registeredOn == nM.CustomMessagingManager) { return; } _registeredOn = nM.CustomMessagingManager; _helloSent = false; Host.OnSessionStart(); Medbay.Remove(); CustomMessagingManager customMessagingManager = nM.CustomMessagingManager; object obj = <>c.<>9__18_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader r) { if (IsHost) { SendState(sender); } }; <>c.<>9__18_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("ShipMedbay.Hello", (HandleNamedMessageDelegate)obj); object obj2 = <>c.<>9__18_1; if (obj2 == null) { HandleNamedMessageDelegate val2 = delegate(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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) if (IsHost) { byte cmd = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref cmd, default(ForPrimitives)); int target = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref target, default(ForPrimitives)); Host.Request(sender, cmd, target); } }; <>c.<>9__18_1 = val2; obj2 = (object)val2; } customMessagingManager.RegisterNamedMessageHandler("ShipMedbay.Req", (HandleNamedMessageDelegate)obj2); object obj3 = <>c.<>9__18_2; if (obj3 == null) { HandleNamedMessageDelegate val3 = delegate(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0091: 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_00a7: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { byte b = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); if (b != 1) { Plugin.Log.LogWarning((object)$"Ship Medbay: the host has another version of the mod (format {b}, ours {(byte)1})."); } else { MedState medState = new MedState(); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.Price, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.HealAmount, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.HealCost, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.FreeHealsPerDay, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.ReviveCost, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.ReviveHealth, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.RevivesPerDay, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref medState.ReviveInOrbit, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref medState.HasSpot, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref medState.Pos); ((FastBufferReader)(ref r)).ReadValueSafe(ref medState.Normal); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref medState.Mode, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.Subject, default(ForPrimitives)); float num = default(float); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref num, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref medState.Duration, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.FreeLeft, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref medState.RevivesLeft, default(ForPrimitives)); medState.EndsAt = Time.time + num; Host.Received(medState); } } }; <>c.<>9__18_2 = val3; obj3 = (object)val3; } customMessagingManager.RegisterNamedMessageHandler("ShipMedbay.State", (HandleNamedMessageDelegate)obj3); object obj4 = <>c.<>9__18_3; if (obj4 == null) { HandleNamedMessageDelegate val4 = delegate(ulong sender, FastBufferReader r) { if (!IsHost) { string why = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref why, false); Medbay.Denied(why); } }; <>c.<>9__18_3 = val4; obj4 = (object)val4; } customMessagingManager.RegisterNamedMessageHandler("ShipMedbay.Deny", (HandleNamedMessageDelegate)obj4); object obj5 = <>c.<>9__18_4; if (obj5 == null) { HandleNamedMessageDelegate val5 = delegate(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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) if (!IsHost) { int who = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref who, default(ForPrimitives)); int amount = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref amount, default(ForPrimitives)); Revive.Heal(who, amount); } }; <>c.<>9__18_4 = val5; obj5 = (object)val5; } customMessagingManager.RegisterNamedMessageHandler("ShipMedbay.Healed", (HandleNamedMessageDelegate)obj5); object obj6 = <>c.<>9__18_5; if (obj6 == null) { HandleNamedMessageDelegate val6 = delegate(ulong sender, FastBufferReader r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004b: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { int who = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref who, default(ForPrimitives)); Vector3 shipLocalPos = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref shipLocalPos); float yaw = default(float); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref yaw, default(ForPrimitives)); int hp = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref hp, default(ForPrimitives)); Revive.Apply(who, shipLocalPos, yaw, hp); } }; <>c.<>9__18_5 = val6; obj6 = (object)val6; } customMessagingManager.RegisterNamedMessageHandler("ShipMedbay.Revived", (HandleNamedMessageDelegate)obj6); } internal unsafe static void SayHello() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (_helloSent || !Online || IsHost || !NM.IsConnectedClient) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { NM.CustomMessagingManager.SendNamedMessage("ShipMedbay.Hello", 0uL, val, (NetworkDelivery)3); _helloSent = true; } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal unsafe static void Request(byte cmd, int target = -1) { //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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) if (!Online) { return; } if (IsHost) { Host.Request(NM.LocalClientId, cmd, target); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref cmd, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref target, default(ForPrimitives)); NM.CustomMessagingManager.SendNamedMessage("ShipMedbay.Req", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal unsafe static void Deny(ulong cid, string why) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) Plugin.Debug($"denied client {cid}: {why}"); if (!IsHost) { return; } if (cid == NM.LocalClientId) { Medbay.Denied(why); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(why, false); NM.CustomMessagingManager.SendNamedMessage("ShipMedbay.Deny", cid, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal static void Broadcast() { if (!IsHost) { return; } foreach (ulong connectedClientsId in NM.ConnectedClientsIds) { if (connectedClientsId != 0L) { SendState(connectedClientsId); } } } private unsafe static void SendState(ulong cid) { //IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0092: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { return; } MedState state = Host.State; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1); try { byte b = 1; ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.Price, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.HealAmount, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.HealCost, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.FreeHealsPerDay, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.ReviveCost, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.ReviveHealth, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.RevivesPerDay, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref state.ReviveInOrbit, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref state.HasSpot, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref state.Pos); ((FastBufferWriter)(ref val)).WriteValueSafe(ref state.Normal); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref state.Mode, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.Subject, default(ForPrimitives)); float num = Mathf.Max(0f, state.EndsAt - Time.time); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref state.Duration, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.FreeLeft, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref state.RevivesLeft, default(ForPrimitives)); NM.CustomMessagingManager.SendNamedMessage("ShipMedbay.State", cid, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal unsafe static void SendHealed(int who, int amount) { //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) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Revive.Heal(who, amount); if (!IsHost) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref who, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref amount, default(ForPrimitives)); foreach (ulong connectedClientsId in NM.ConnectedClientsIds) { if (connectedClientsId != 0L) { NM.CustomMessagingManager.SendNamedMessage("ShipMedbay.Healed", connectedClientsId, val, (NetworkDelivery)3); } } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal unsafe static void SendRevived(int who, Vector3 shipLocalPos, float yaw, int hp) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) Revive.Apply(who, shipLocalPos, yaw, hp); if (!IsHost) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(40, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref who, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref shipLocalPos); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref yaw, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref hp, default(ForPrimitives)); foreach (ulong connectedClientsId in NM.ConnectedClientsIds) { if (connectedClientsId != 0L) { NM.CustomMessagingManager.SendNamedMessage("ShipMedbay.Revived", connectedClientsId, val, (NetworkDelivery)3); } } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } internal static class Placement { private struct Avoid { public Vector3 P; public float R; public string Name; public bool Control; } private static GameObject _hullSeen; private static bool _hullKnown; private static float _nextProbe; private static float _nextValidate; internal static string Where = ""; private static int Walls => LayerMask.GetMask(new string[3] { "Room", "Colliders", "Default" }); private static int Obstacles => Walls | LayerMask.GetMask(new string[5] { "InteractableObject", "PlaceableShipObjects", "Props", "Railing", "PlacementBlocker" }); internal static void OnSessionStart() { _hullKnown = false; _nextProbe = 0f; _nextValidate = 0f; } internal static bool HostCheckSpot(MedState s) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.elevatorTransform == (Object)null || (Object)(object)instance.shipInnerRoomBounds == (Object)null) { return false; } GameObject hull = Hooks.Hull; if (!_hullKnown) { _hullSeen = hull; _hullKnown = true; } if ((Object)(object)hull != (Object)(object)_hullSeen) { _hullSeen = hull; Plugin.Log.LogInfo((object)"Ship Medbay: the ship's hull changed; finding the pod a wall again."); _nextProbe = Time.time + 2f; if (s.HasSpot) { s.HasSpot = false; return true; } return false; } if (s.HasSpot) { if (Time.time < _nextValidate) { return false; } _nextValidate = Time.time + 5f; if (StillWall(instance, s)) { return false; } Plugin.Log.LogInfo((object)"Ship Medbay: the pod's wall is gone; finding another."); s.HasSpot = false; _nextProbe = Time.time + 2f; return true; } if (Time.time < _nextProbe) { return false; } _nextProbe = Time.time + 5f; if (!FindSpot(instance, out var pos, out var normal)) { return false; } s.HasSpot = true; s.Pos = pos; s.Normal = normal; _nextValidate = Time.time + 5f; return true; } internal static string Refit() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) StartOfRound instance = StartOfRound.Instance; if (!Net.IsHost || (Object)(object)instance == (Object)null) { return null; } Medbay.Remove(); if (!FindSpot(instance, out var pos, out var normal)) { Host.State.HasSpot = false; Host.Dirty = true; return "no clear wall found (see the log)"; } Host.Stop("the pod is being moved"); MedState state = Host.State; state.HasSpot = true; state.Pos = pos; state.Normal = normal; Host.Dirty = true; return "pod on the " + Where; } private static bool StillWall(StartOfRound sor, MedState s) { //IL_0008: 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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) Transform elevatorTransform = sor.elevatorTransform; Vector3 val = elevatorTransform.TransformDirection(s.Normal); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = elevatorTransform.TransformPoint(s.Pos) + Vector3.up * 1.2f + normalized * -0.5f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2 + normalized * 0.3f, -normalized, ref val3, 0.6f, Walls, (QueryTriggerInteraction)1) && !Medbay.IsOurs(((Component)((RaycastHit)(ref val3)).collider).transform)) { return Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val3)).point - val2, normalized)) < 0.12f; } return false; } private static List<Avoid> AvoidPoints(StartOfRound sor, out Vector3? rack) { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) List<Avoid> list = new List<Avoid>(); Add((Component)(object)Object.FindObjectOfType<HangarShipDoor>(), 2.2f, "door", control: true); Add((Component)(object)Object.FindObjectOfType<Terminal>(), 1.4f, "terminal", control: true); Add((Component)(object)Object.FindObjectOfType<StartMatchLever>(), 1.3f, "lever", control: true); Add((Component)(object)Object.FindObjectOfType<ItemCharger>(), 0.9f, "charger", control: true); ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>(); for (int i = 0; i < array.Length; i++) { Add((Component)(object)array[i], 1f, "teleporter", control: true); } PlaceableShipObject[] array2 = Object.FindObjectsOfType<PlaceableShipObject>(); foreach (PlaceableShipObject val in array2) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "GunRackMount") { Add((Component)(object)val, 1.2f, "gun rack"); } } AddGo("CrewAwards.Plaque", 1f, "plaque"); AddGo("BountyBoard.Board", 1.1f, "bounty board"); ManualCameraRenderer mapScreen = sor.mapScreen; Bounds bounds; if ((Object)(object)mapScreen != (Object)null && (Object)(object)mapScreen.mesh != (Object)null) { List<Avoid> list2 = list; Avoid item = default(Avoid); bounds = ((Renderer)mapScreen.mesh).bounds; item.P = ((Bounds)(ref bounds)).center; bounds = ((Renderer)mapScreen.mesh).bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; item.R = Mathf.Max(1.4f, ((Vector3)(ref extents)).magnitude + 0.6f); item.Name = "monitors"; item.Control = true; list2.Add(item); } ManualCameraRenderer securityCameraScreen = sor.securityCameraScreen; if ((Object)(object)securityCameraScreen != (Object)null && (Object)(object)securityCameraScreen.mesh != (Object)null) { List<Avoid> list3 = list; Avoid item = default(Avoid); bounds = ((Renderer)securityCameraScreen.mesh).bounds; item.P = ((Bounds)(ref bounds)).center; item.R = 1.1f; item.Name = "monitors"; list3.Add(item); } rack = null; UnlockableSuit[] array3 = Object.FindObjectsOfType<UnlockableSuit>(); if (array3.Length != 0) { Vector3 val2 = Vector3.zero; UnlockableSuit[] array4 = array3; foreach (UnlockableSuit val3 in array4) { val2 += ((Component)val3).transform.position; } val2 /= (float)array3.Length; rack = val2; float num = 0.5f; array4 = array3; foreach (UnlockableSuit val4 in array4) { num = Mathf.Max(num, Vector3.Distance(((Component)val4).transform.position, val2) + 0.45f); } list.Add(new Avoid { P = val2, R = num, Name = "suit rack" }); } return list; void Add(Component c, float r, string name, bool control = false) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c != (Object)null) { list.Add(new Avoid { P = c.transform.position, R = r, Name = name, Control = control }); } } void AddGo(string go, float r, string name) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) GameObject val5 = GameObject.Find(go); if ((Object)(object)val5 != (Object)null) { list.Add(new Avoid { P = val5.transform.position, R = r, Name = name }); } } } private static bool FindSpot(StartOfRound sor, out Vector3 pos, out Vector3 normal) { if (Probe(sor, strict: true, out pos, out normal)) { return true; } Plugin.Log.LogInfo((object)"Ship Medbay: no roomy wall; trying again closer to the ship's fixtures."); return Probe(sor, strict: false, out pos, out normal); } private static bool Probe(StartOfRound sor, bool strict, out Vector3 pos, out Vector3 normal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_0182: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown resul