using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MEDVAC Healer Drone")] [assembly: AssemblyProduct("MEDVAC.HealerDrone")] [assembly: AssemblyCopyright("MEDVAC")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: ComVisible(false)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 MEDVAC.HealerDrone { internal static class Compat { private static bool _patched; private static float _lastForce; private static float _lastKick; internal static void PatchAll(Harmony harmony) { if (harmony != null && !_patched) { _patched = true; Plugin.Log.LogInfo((object)"Compat ready (no extra Harmony on More Shop Items / other mods)."); } } private static void PatchAssembly(Harmony harmony, string asmHint, params string[] methodHints) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { string text = ""; try { text = assembly.GetName().Name ?? ""; } catch { continue; } if (text.IndexOf(asmHint, StringComparison.OrdinalIgnoreCase) < 0) { continue; } Type[] types = assembly.GetTypes(); for (int j = 0; j < types.Length; j++) { MethodInfo[] methods = types[j].GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.IsAbstract || methodInfo.ContainsGenericParameters) { continue; } bool flag = false; foreach (string value in methodHints) { if (methodInfo.Name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { flag = true; break; } } if (flag) { try { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Compat), "AfterOtherMod", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch { } } } } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Compat " + asmHint + " skipped: " + ex.Message)); } } private static void AfterOtherMod() { ShopRegistry.ClampShopCaps(); } } internal static class MedkitTable { internal static readonly int[] Packs = new int[3] { 25, 50, 100 }; internal static int WasteMax(int packHp) { if (packHp <= 25) { return 5; } if (packHp <= 50) { return 10; } return 15; } internal static bool CanSip(int tankHp, int tankMax, int packHp) { if (packHp <= 0 || tankMax <= 0) { return false; } int num = tankMax - tankHp; if (num <= 0) { return false; } return Mathf.Max(0, packHp - num) <= WasteMax(packHp); } internal static int Give(int tankHp, int tankMax, int packHp) { if (!CanSip(tankHp, tankMax, packHp)) { return 0; } return Mathf.Min(tankMax - tankHp, packHp); } internal static void LogOnce() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("MEDVAC refill table (sip if overflow <= pack limit):"); stringBuilder.AppendLine("pack 25 => max waste 5 | pack 50 => 10 | pack 100 => 15"); Tier[] tiers = Plugin.Tiers; foreach (Tier tier in tiers) { int tankHp = tier.TankHp; stringBuilder.Append(tier.Name).Append(' ').Append(tankHp) .Append("HP:"); int[] packs = Packs; foreach (int num in packs) { int num2 = num - WasteMax(num); if (num2 > tankHp) { stringBuilder.Append(" ").Append(num).Append("=never"); continue; } int value = Mathf.Max(0, tankHp - num2); stringBuilder.Append(" ").Append(num).Append("HP@0-") .Append(value); } stringBuilder.AppendLine(); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } } internal static class MedvacIcon { private static Sprite _sprite; private static Texture2D _tex; internal static Sprite Sprite { get { if ((Object)(object)_sprite == (Object)null) { Build(); } return _sprite; } } internal static Texture2D Texture { get { if ((Object)(object)_tex == (Object)null) { Build(); } return _tex; } } private static void Build() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) _tex = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)_tex).filterMode = (FilterMode)1; ((Texture)_tex).wrapMode = (TextureWrapMode)1; byte[] array = null; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MEDVAC.icon.png")) { if (stream != null) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } } if (array != null && array.Length != 0) { ImageConversion.LoadImage(_tex, array, false); } ((Object)_tex).name = "MEDVAC Icon"; _sprite = Sprite.Create(_tex, new Rect(0f, 0f, (float)((Texture)_tex).width, (float)((Texture)_tex).height), new Vector2(0.5f, 0.5f), 100f); ((Object)_sprite).name = "MEDVAC Icon"; } } internal static class MedvacNet { internal const byte ConvertEvent = 183; internal const byte TankEvent = 184; private static bool _hooked; internal static void Hook() { try { if (PhotonNetwork.NetworkingClient != null) { PhotonNetwork.NetworkingClient.EventReceived -= OnEvent; PhotonNetwork.NetworkingClient.EventReceived += OnEvent; _hooked = true; } } catch (Exception ex) { Plugin.Log.LogDebug((object)("MedvacNet hook: " + ex.Message)); } } internal static bool IsMultiplayer() { try { return SemiFunc.IsMultiplayer() && PhotonNetwork.InRoom; } catch { return PhotonNetwork.InRoom; } } internal static bool IsMaster() { try { if (!IsMultiplayer()) { return true; } return PhotonNetwork.IsMasterClient; } catch { return true; } } internal static GameObject Spawn(Item item, Vector3 pos, Quaternion rot) { //IL_0022: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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) if ((Object)(object)item == (Object)null) { return null; } GameObject val = null; if (IsMultiplayer() && IsMaster()) { val = ShopRegistry.SpawnViaRepoLib(item, pos, rot); if ((Object)(object)val == (Object)null) { string[] array = new string[5] { ShopRegistry.VanillaPhotonId, "Items/Item Drone Feather", "Items/Item Drone Heal", "Items/Item Drone Battery", "Items/Item Drone Indestructible" }; foreach (string text in array) { if (string.IsNullOrEmpty(text)) { continue; } try { val = PhotonNetwork.InstantiateRoomObject(text, pos, rot, (byte)0, (object[])null); if ((Object)(object)val != (Object)null) { break; } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Photon " + text + ": " + ex.Message)); } } } } if ((Object)(object)val == (Object)null && (!IsMultiplayer() || IsMaster())) { GameObject val2 = ShopRegistry.Alive(ShopRegistry.GetTemplate(item)) ?? ShopRegistry.Alive(ShopRegistry.VanillaPrefab); if ((Object)(object)val2 != (Object)null) { val = Object.Instantiate(val2, pos, rot); } } if ((Object)(object)val == (Object)null) { return null; } val.SetActive(true); ShopRegistry.ConvertToHealer(val, item); BroadcastConvert(val, item); return val; } internal static void BroadcastConvert(GameObject go, Item item) { //IL_0076: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null || (Object)(object)item == (Object)null || !IsMultiplayer() || !IsMaster()) { return; } PhotonView val = go.GetComponent() ?? go.GetComponentInChildren(); if ((Object)(object)val == (Object)null) { return; } try { object[] array = new object[3] { val.ViewID, item.itemName ?? "", ((Object)item).name ?? "" }; RaiseEventOptions val2 = new RaiseEventOptions { Receivers = (ReceiverGroup)0, CachingOption = (EventCaching)4 }; PhotonNetwork.RaiseEvent((byte)183, (object)array, val2, SendOptions.SendReliable); } catch (Exception ex) { Plugin.Log.LogDebug((object)("BroadcastConvert: " + ex.Message)); } } internal static void BroadcastTank(MedvacRuntime rt) { //IL_0069: 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_0070: 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_007f: Expected O, but got Unknown if ((Object)(object)rt == (Object)null || !IsMultiplayer() || !IsMaster()) { return; } PhotonView val = ((Component)rt).GetComponent() ?? ((Component)rt).GetComponentInChildren(); if ((Object)(object)val == (Object)null) { return; } try { PhotonNetwork.RaiseEvent((byte)184, (object)new object[3] { val.ViewID, rt.tankHp, rt.tankMax }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } catch { } } private static void OnEvent(EventData e) { try { if (e.Code == 183) { if (e.CustomData is object[] array && array.Length >= 3) { int viewId = Convert.ToInt32(array[0]); string itemName = (array[1] as string) ?? ""; string assetName = (array[2] as string) ?? ""; if ((Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ApplyConvert(viewId, itemName, assetName)); } } } else { if (e.Code != 184 || !(e.CustomData is object[] array2) || array2.Length < 3) { return; } int num = Convert.ToInt32(array2[0]); int tankHp = Convert.ToInt32(array2[1]); int tankMax = Convert.ToInt32(array2[2]); PhotonView val = PhotonView.Find(num); if (!((Object)(object)val == (Object)null)) { MedvacRuntime medvacRuntime = ((Component)val).GetComponent() ?? ((Component)val).GetComponentInChildren(); if (!((Object)(object)medvacRuntime == (Object)null)) { medvacRuntime.tankHp = tankHp; medvacRuntime.tankMax = tankMax; medvacRuntime.SyncBattery(); } } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("MedvacNet event: " + ex.Message)); } } private static IEnumerator ApplyConvert(int viewId, string itemName, string assetName) { for (int i = 0; i < 60; i++) { PhotonView val = PhotonView.Find(viewId); if ((Object)(object)val != (Object)null) { Item val2 = ShopRegistry.FindMedvacItem(itemName, assetName); if ((Object)(object)val2 != (Object)null) { ShopRegistry.ConvertToHealer(((Component)val).gameObject, val2); } yield break; } yield return (object)new WaitForSeconds(0.1f); } Plugin.Log.LogWarning((object)("Client never saw PhotonView " + viewId + " for " + itemName)); } } public class MedvacVisual : MonoBehaviour { private const float S = 0.24f; private Transform[] _rotors; private Light _plusLight; private Transform _bob; private float _t; private MeshRenderer[] _pips; private Material _pipOn; private Material _pipOff; private int _lastLit = -1; private void Start() { HideVanilla(); Build(); SetupGrabVolume(); } private void Update() { float deltaTime = Time.deltaTime; _t += deltaTime; if (_rotors == null) { return; } float num = 720f * deltaTime; for (int i = 0; i < _rotors.Length; i++) { if (!((Object)(object)_rotors[i] == (Object)null)) { _rotors[i].Rotate(0f, num * ((i % 2 == 0) ? 1f : (-1f)), 0f, (Space)1); } } } internal void RefreshPips() { UpdatePips(); } private void UpdatePips() { if (_pips == null) { return; } MedvacRuntime medvacRuntime = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInParent(); int num = Mathf.Clamp(Mathf.CeilToInt((((Object)(object)medvacRuntime != (Object)null) ? medvacRuntime.Fill01 : 1f) * (float)_pips.Length - 0.001f), 0, _pips.Length); if (num == _lastLit) { return; } _lastLit = num; for (int i = 0; i < _pips.Length; i++) { if (!((Object)(object)_pips[i] == (Object)null)) { ((Renderer)_pips[i]).sharedMaterial = ((i < num) ? _pipOn : _pipOff); } } } private void SetupGrabVolume() { //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)this).transform.Find("MV_Grab"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } PhysGrabObject val2 = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInParent(); if ((Object)(object)val2 != (Object)null) { val2.grabDisableTimer = 0f; } ItemAttributes val3 = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInParent(); if ((Object)(object)val3 != (Object)null) { val3.disableUI = false; } int num = -1; PhysGrabObjectCollider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); PhysGrabObjectCollider[] array = componentsInChildren; foreach (PhysGrabObjectCollider val4 in array) { if (!((Object)(object)val4 == (Object)null) && !(((Object)((Component)val4).gameObject).name == "MV_Grab")) { num = ((Component)val4).gameObject.layer; Enlarge(((Component)val4).gameObject, ((Component)this).transform); } } if (num < 0) { Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); foreach (Collider val5 in componentsInChildren2) { if (!((Object)(object)val5 == (Object)null) && !((Object)((Component)val5).gameObject).name.StartsWith("MV_") && ((Component)val5).gameObject.layer != 0) { num = ((Component)val5).gameObject.layer; break; } } } if (num < 0 && (Object)(object)val2 != (Object)null) { num = ((Component)val2).gameObject.layer; } if (num < 0) { num = ((Component)this).gameObject.layer; } if (componentsInChildren.Length == 0 && (Object)(object)val2 != (Object)null) { GameObject gameObject = ((Component)val2).gameObject; gameObject.layer = num; BoxCollider val6 = gameObject.GetComponent(); if ((Object)(object)val6 == (Object)null) { val6 = gameObject.AddComponent(); } val6.size = new Vector3(0.52f, 0.48f, 0.52f); val6.center = new Vector3(0f, 0.04f, 0f); ((Collider)val6).isTrigger = false; ((Collider)val6).enabled = true; PhysGrabObjectCollider val7 = gameObject.GetComponent(); if ((Object)(object)val7 == (Object)null) { val7 = gameObject.AddComponent(); } val7.colliderID = 1; AccessTools.Field(typeof(PhysGrabObjectCollider), "physGrabObject")?.SetValue(val7, val2); if (val2.colliders != null && !val2.colliders.Contains(gameObject.transform)) { val2.colliders.Add(gameObject.transform); } } Plugin.Log.LogInfo((object)("Grab setup: layer=" + num + " markers=" + ((Component)this).GetComponentsInChildren(true).Length)); } private static void Enlarge(GameObject host, Transform root) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_004b: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0151: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0.58f, 0.54f, 0.56f); Vector3 lossyScale = host.transform.lossyScale; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), val.y / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), val.z / Mathf.Max(0.001f, Mathf.Abs(lossyScale.z))); Vector3 center = host.transform.InverseTransformPoint(root.TransformPoint(new Vector3(0f, 0.04f, 0f))); BoxCollider component = host.GetComponent(); if ((Object)(object)component != (Object)null) { component.size = Vector3.Max(component.size, val2); component.center = center; ((Collider)component).enabled = true; ((Collider)component).isTrigger = false; } SphereCollider component2 = host.GetComponent(); if ((Object)(object)component2 != (Object)null) { float num = 0.34f / Mathf.Max(0.001f, Mathf.Max(new float[3] { Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z) })); component2.radius = Mathf.Max(component2.radius, num); component2.center = center; ((Collider)component2).enabled = true; ((Collider)component2).isTrigger = false; } CapsuleCollider component3 = host.GetComponent(); if ((Object)(object)component3 != (Object)null) { float num2 = Mathf.Max(0.001f, Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z))); component3.radius = Mathf.Max(component3.radius, 0.28f / num2); component3.height = Mathf.Max(component3.height, 0.54f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y))); component3.center = center; ((Collider)component3).enabled = true; } if ((Object)(object)component == (Object)null && (Object)(object)component2 == (Object)null && (Object)(object)component3 == (Object)null) { BoxCollider obj = host.AddComponent(); obj.size = val2; obj.center = center; ((Collider)obj).isTrigger = false; } } private void HideVanilla() { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)((Component)val).transform).name.StartsWith("MV_")) { val.enabled = false; } } } private void Build() { //IL_001e: 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_0042: 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_0057: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_010d: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Expected O, but got Unknown //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_06d5: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07fb: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_082e: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Unknown result type (might be due to invalid IL or missing references) //IL_0863: Unknown result type (might be due to invalid IL or missing references) //IL_0882: Unknown result type (might be due to invalid IL or missing references) //IL_0891: Unknown result type (might be due to invalid IL or missing references) //IL_08b8: Unknown result type (might be due to invalid IL or missing references) //IL_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_08de: Unknown result type (might be due to invalid IL or missing references) //IL_08ef: Unknown result type (might be due to invalid IL or missing references) //IL_0916: Unknown result type (might be due to invalid IL or missing references) //IL_0928: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_0951: Unknown result type (might be due to invalid IL or missing references) //IL_0965: Unknown result type (might be due to invalid IL or missing references) //IL_0990: Unknown result type (might be due to invalid IL or missing references) //IL_09bb: Unknown result type (might be due to invalid IL or missing references) //IL_09cd: Unknown result type (might be due to invalid IL or missing references) //IL_09e1: Unknown result type (might be due to invalid IL or missing references) //IL_0a04: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Unknown result type (might be due to invalid IL or missing references) //IL_0a13: Unknown result type (might be due to invalid IL or missing references) //IL_0a36: Unknown result type (might be due to invalid IL or missing references) //IL_0a3b: Unknown result type (might be due to invalid IL or missing references) //IL_0a45: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0a6e: Unknown result type (might be due to invalid IL or missing references) //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a8a: Unknown result type (might be due to invalid IL or missing references) //IL_0ab5: Unknown result type (might be due to invalid IL or missing references) //IL_0ac7: Unknown result type (might be due to invalid IL or missing references) //IL_0adb: Unknown result type (might be due to invalid IL or missing references) //IL_0b2e: Unknown result type (might be due to invalid IL or missing references) //IL_0b42: Unknown result type (might be due to invalid IL or missing references) //IL_0b77: Unknown result type (might be due to invalid IL or missing references) //IL_0b8b: Unknown result type (might be due to invalid IL or missing references) //IL_0bcf: Unknown result type (might be due to invalid IL or missing references) //IL_0be3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)this).transform.Find("MV_Root") != (Object)null) { return; } Transform transform = new GameObject("MV_Root").transform; transform.SetParent(((Component)this).transform, false); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one * 0.24f; _bob = new GameObject("MV_Bob").transform; _bob.SetParent(transform, false); Material mat = Mat(new Color(0.89f, 0.93f, 0.95f), 0f, 0.38f, 0.16f); Material val = Mat(new Color(0.23f, 0.66f, 0.64f), 0.25f, 0.32f, 0.28f); Material mat2 = Mat(new Color(0.11f, 0.14f, 0.16f), 0f, 0.4f, 0.4f); Material mat3 = Mat(new Color(0.78f, 1f, 0.88f), 1.15f, 0.22f, 0.05f); Material mat4 = Mat(new Color(1f, 0.45f, 0.45f), 0.9f, 0.3f, 0.08f); Material mat5 = Mat(new Color(0.78f, 1f, 0.97f), 1.2f, 0.2f, 0.05f); Material mat6 = Mat(new Color(0.1f, 0.11f, 0.13f), 0f, 0.48f, 0.25f); Material mat7 = Mat(new Color(0.04f, 0.05f, 0.07f), 0f, 0.12f, 0.85f); Material mat8 = (_pipOn = Mat(new Color(0.6f, 1f, 0.77f), 1.1f, 0.25f, 0.05f)); _pipOff = Mat(new Color(0.12f, 0.18f, 0.14f), 0f, 0.4f, 0.1f); Material mat9 = Mat(new Color(1f, 0.84f, 0.42f), 0.9f, 0.25f, 0.05f); Prim((PrimitiveType)3, "MV_Body", _bob, Vector3.zero, new Vector3(1.64f, 1.54f, 1.46f), mat); Corner(val, _bob, 1.64f, 1.54f, 1.46f, 1, 1); Corner(val, _bob, 1.64f, 1.54f, 1.46f, 1, -1); Corner(val, _bob, 1.64f, 1.54f, 1.46f, -1, 1); Corner(val, _bob, 1.64f, 1.54f, 1.46f, -1, -1); int[] array = new int[2] { -1, 1 }; float[] array2; foreach (int num in array) { array2 = new float[3] { -0.2f, 0f, 0.2f }; foreach (float num2 in array2) { Prim((PrimitiveType)3, "MV_Vent", _bob, new Vector3((float)num * 0.83f, num2, 0.04f), new Vector3(0.03f, 0.055f, 0.4f), mat2); } } array = new int[2] { -1, 1 }; foreach (int num3 in array) { int[] array3 = new int[2] { -1, 1 }; foreach (int num4 in array3) { Prim((PrimitiveType)2, "MV_LED", _bob, new Vector3((float)num3 * 0.52f, -0.78f, (float)num4 * 0.42f), new Vector3(0.07f, 0.012f, 0.07f), mat5); } } Prim((PrimitiveType)3, "MV_Bay", _bob, new Vector3(0f, 0.02f, 0.75f), new Vector3(1.18f, 1.14f, 0.05f), mat2); Prim((PrimitiveType)3, "MV_PlusH", _bob, new Vector3(0f, 0.02f, 0.785f), new Vector3(0.78f, 0.22f, 0.05f), mat3); Prim((PrimitiveType)3, "MV_PlusV", _bob, new Vector3(0f, 0.02f, 0.785f), new Vector3(0.22f, 0.78f, 0.05f), mat3); Prim((PrimitiveType)3, "MV_RedPlusH", _bob, new Vector3(0.4f, 0.4f, 0.79f), new Vector3(0.2f, 0.055f, 0.03f), mat4); Prim((PrimitiveType)3, "MV_RedPlusV", _bob, new Vector3(0.4f, 0.4f, 0.79f), new Vector3(0.055f, 0.2f, 0.03f), mat4); Frame(mat5, _bob, 1.28f, 1.22f, 0.77000004f, 0.045f); Prim((PrimitiveType)3, "MV_Gasket", _bob, new Vector3(0f, 0.782f, 0f), new Vector3(1.5f, 0.03f, 1.32f), val); GameObject val2 = new GameObject("MV_PlusLight"); val2.transform.SetParent(_bob, false); val2.transform.localPosition = new Vector3(0f, 0.05f, 0.93f); _plusLight = val2.AddComponent(); _plusLight.type = (LightType)2; _plusLight.color = new Color(0.35f, 1f, 0.55f); _plusLight.range = 1.2f; _plusLight.intensity = 0.35f; _plusLight.shadows = (LightShadows)0; _plusLight.renderMode = (LightRenderMode)2; Prim((PrimitiveType)0, "MV_Dome", _bob, new Vector3(0f, 0.78999996f, 0.22f), Vector3.one * 0.31f, mat7).localScale = new Vector3(0.31f, 0.16f, 0.31f); Prim((PrimitiveType)0, "MV_Amber", _bob, new Vector3(-0.22f, 0.82f, 0.32f), Vector3.one * 0.055f, mat9); Prim((PrimitiveType)0, "MV_Cyan", _bob, new Vector3(0.22f, 0.82f, 0.3f), Vector3.one * 0.05f, mat5); _rotors = (Transform[])(object)new Transform[4]; float[] array4 = new float[4] { 45f, 135f, 225f, 315f }; for (int k = 0; k < 4; k++) { Transform transform2 = new GameObject("MV_Arm" + k).transform; transform2.SetParent(_bob, false); transform2.localRotation = Quaternion.Euler(0f, array4[k], 0f); ((Component)Prim((PrimitiveType)2, "MV_Shoulder", transform2, new Vector3(0.78f, 0.52f, 0f), new Vector3(0.24f, 0.13f, 0.24f), mat)).transform.localRotation = Quaternion.Euler(0f, 0f, 90f); ((Component)Prim((PrimitiveType)2, "MV_Boom", transform2, new Vector3(1.19f, 0.52f, 0f), new Vector3(0.15f, 0.31f, 0.15f), mat)).transform.localRotation = Quaternion.Euler(0f, 0f, 90f); ((Component)Prim((PrimitiveType)2, "MV_Collar", transform2, new Vector3(1.14f, 0.52f, 0f), new Vector3(0.2f, 0.05f, 0.2f), val)).transform.localRotation = Quaternion.Euler(0f, 0f, 90f); Transform transform3 = new GameObject("MV_Motor").transform; transform3.SetParent(transform2, false); transform3.localPosition = new Vector3(1.5f, 0.78f, 0f); Prim((PrimitiveType)3, "MV_MotorBody", transform3, Vector3.zero, new Vector3(0.44f, 0.17f, 0.44f), mat); Transform transform4 = new GameObject("MV_Rotor").transform; transform4.SetParent(transform3, false); transform4.localPosition = new Vector3(0f, 0.22f, 0f); Prim((PrimitiveType)3, "MV_BladeA", transform4, Vector3.zero, new Vector3(1.5f, 0.016f, 0.1f), mat6); Prim((PrimitiveType)3, "MV_BladeB", transform4, Vector3.zero, new Vector3(0.1f, 0.016f, 1.5f), mat6); _rotors[k] = transform4; } Transform transform5 = new GameObject("MV_Gimbal").transform; transform5.SetParent(_bob, false); transform5.localPosition = new Vector3(0f, -0.96f, 0f); Prim((PrimitiveType)2, "MV_Neck", transform5, Vector3.zero, new Vector3(0.22f, 0.05f, 0.22f), val); Prim((PrimitiveType)0, "MV_Ball", transform5, new Vector3(0f, -0.16f, 0f), Vector3.one * 0.31f, mat); Prim((PrimitiveType)0, "MV_Lens", transform5, new Vector3(0f, -0.22f, 0.07f), Vector3.one * 0.18f, mat7); Prim((PrimitiveType)0, "MV_Lens2", transform5, new Vector3(0.055f, -0.2f, -0.055f), Vector3.one * 0.1f, mat7); Transform transform6 = new GameObject("MV_HUD").transform; transform6.SetParent(_bob, false); transform6.localPosition = new Vector3(0f, 0.86f, 0.74f); Prim((PrimitiveType)3, "MV_HudBack", transform6, Vector3.zero, new Vector3(1.24f, 0.17f, 0.05f), mat2); _pips = (MeshRenderer[])(object)new MeshRenderer[10]; for (int l = 0; l < 10; l++) { _pips[l] = ((Component)Prim((PrimitiveType)3, "MV_Pip" + l, transform6, new Vector3(-0.52f + (float)l * 0.104f, 0f, 0.03f), new Vector3(0.086f, 0.11f, 0.02f), mat8)).GetComponent(); } Prim((PrimitiveType)3, "MV_Nub", transform6, new Vector3(0.66f, 0f, 0f), new Vector3(0.07f, 0.09f, 0.03f), mat2); array2 = new float[3] { -0.1f, 0f, 0.1f }; foreach (float num5 in array2) { Prim((PrimitiveType)3, "MV_Pin", transform6, new Vector3(num5, -0.175f, 0f), new Vector3(0.028f, 0.1f, 0.02f), mat8); } } private static void Corner(Material teal, Transform parent, float bw, float bh, float bd, int sx, int sy) { //IL_0037: 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) Prim((PrimitiveType)3, "MV_Corner", parent, new Vector3((float)sx * (bw / 2f - 0.12f), (float)sy * (bh / 2f - 0.12f), bd / 2f + 0.01f), new Vector3(0.2f, 0.2f, 0.03f), teal); } private static void Frame(Material mat, Transform parent, float w, float h, float z, float t) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00a2: Unknown result type (might be due to invalid IL or missing references) Prim((PrimitiveType)3, "MV_FrmT", parent, new Vector3(0f, h / 2f, z), new Vector3(w, t, t), mat); Prim((PrimitiveType)3, "MV_FrmB", parent, new Vector3(0f, (0f - h) / 2f, z), new Vector3(w, t, t), mat); Prim((PrimitiveType)3, "MV_FrmL", parent, new Vector3((0f - w) / 2f, 0f, z), new Vector3(t, h, t), mat); Prim((PrimitiveType)3, "MV_FrmR", parent, new Vector3(w / 2f, 0f, z), new Vector3(t, h, t), mat); } private static Transform Prim(PrimitiveType type, string name, Transform parent, Vector3 localPos, Vector3 scale, Material mat) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) GameObject val = GameObject.CreatePrimitive(type); ((Object)val).name = name; Collider[] components = val.GetComponents(); for (int i = 0; i < components.Length; i++) { Object.Destroy((Object)(object)components[i]); } val.transform.SetParent(parent, false); val.transform.localPosition = localPos; val.transform.localScale = scale; MeshRenderer component = val.GetComponent(); ((Renderer)component).sharedMaterial = mat; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; ((Renderer)component).lightProbeUsage = (LightProbeUsage)0; ((Renderer)component).reflectionProbeUsage = (ReflectionProbeUsage)0; return val.transform; } private static Material Mat(Color color, float emission, float smoothness, float metallic) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_003f: 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_00b1: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Unlit/Color")); if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", smoothness); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (emission > 0.01f) { Color val2 = color * emission; if (val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", val2); } } return val; } } internal static class PrefabRefLivePatch { } [HarmonyPatch(typeof(StatsManager), "Awake")] internal static class StatsManagerAwakePatch { [HarmonyPostfix] private static void Postfix(StatsManager __instance) { ShopRegistry.TryInject(__instance); } } [HarmonyPatch(typeof(StatsManager), "Start")] internal static class StatsManagerStartPatch { [HarmonyPostfix] private static void Postfix(StatsManager __instance) { ShopRegistry.TryInject(__instance); } } [HarmonyPatch(typeof(StatsManager), "LoadItemsFromFolder")] internal static class LoadItemsPatch { [HarmonyPostfix] private static void Postfix(StatsManager __instance) { ShopRegistry.TryInject(__instance); } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] internal static class ChangeLevelPatch { [HarmonyPrefix] private static void Prefix() { ShopRegistry.ResetShopWait(); if ((Object)(object)StatsManager.instance != (Object)null) { ShopRegistry.TryInject(StatsManager.instance); } } [HarmonyPostfix] private static void Postfix() { if ((Object)(object)StatsManager.instance != (Object)null) { ShopRegistry.TryInject(StatsManager.instance); } ShopRegistry.RefreshRamCache(); } } [HarmonyPatch(typeof(ShopManager), "ShopInitialize")] internal static class ShopInitializePatch { [HarmonyPrefix] private static void Prefix() { ShopRegistry.TryInject(StatsManager.instance); } [HarmonyPostfix] private static void Postfix(ShopManager __instance) { ShopRegistry.TryInject(StatsManager.instance); ShopRegistry.RefreshRamCache(); } } [HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")] internal static class ShopCollectItemsPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ShopManager __instance) { ShopRegistry.AddToShop(__instance); } } [HarmonyPatch(typeof(PunManager), "ShopPopulateItemVolumes")] internal static class ShopPopulatePatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix() { ShopRegistry.TryInject(StatsManager.instance); } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix() { ShopRegistry.AddToShop(ShopManager.instance); ShopRegistry.SnapshotVolumes(); if ((Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ShopRegistry.AfterVanillaShopPopulate()); } } } [HarmonyPatch(typeof(ShopManager), "GetAllItemVolumesInScene")] internal static class ShopVolumesPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ShopManager __instance) { ShopRegistry.SnapshotFrom(__instance); } } [HarmonyPatch(typeof(PunManager), "SpawnShopItem")] internal static class SpawnShopItemPatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ItemVolume itemVolume, List itemList) { ShopRegistry.NoteVolume(itemVolume); itemList?.RemoveAll((Item it) => (Object)(object)it != (Object)null && Plugin.IsMedvacItem(it)); if (itemList != null) { ShopRegistry.BindLivePrefabs(itemList); } } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemVolume itemVolume) { if (!((Object)(object)itemVolume == (Object)null) && !((Object)(object)itemVolume.itemAttributes == (Object)null)) { Item item = itemVolume.itemAttributes.item; if (!((Object)(object)item == (Object)null) && Plugin.IsMedvacItem(item)) { ShopRegistry.ConvertToHealer(((Component)itemVolume.itemAttributes).gameObject, item); ShopRegistry.ApplyTierPrice(itemVolume.itemAttributes); } } } } [HarmonyPatch(typeof(PunManager), "SpawnItem")] internal static class PunSpawnItemPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(Item item, ItemVolume volume) { ShopRegistry.NoteVolume(volume); if (!((Object)(object)item == (Object)null) && Plugin.IsMedvacItem(item)) { ShopRegistry.BindSpawned(item, volume); if ((Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ShopRegistry.ConvertVolumeNextFrame(item, volume)); } } } } [HarmonyPatch(typeof(StatsManager), "ItemFetchName")] internal static class ItemFetchNameGuard { [HarmonyPrefix] private static bool Prefix(ItemAttributes itemAttributes) { if ((Object)(object)itemAttributes == (Object)null) { return true; } if ((Object)(object)((Component)itemAttributes).GetComponent() != (Object)null) { return false; } if (Plugin.IsMedvacItem(itemAttributes.item)) { return false; } return true; } [HarmonyPostfix] private static void Postfix(ItemAttributes itemAttributes) { if (!((Object)(object)itemAttributes == (Object)null) && (Object)(object)((Component)itemAttributes).GetComponent() != (Object)null) { ItemNamePatch.ForceName(itemAttributes); } } } [HarmonyPatch(typeof(PunManager), "SetItemName")] internal static class SetItemNameGuard { [HarmonyPrefix] private static bool Prefix(ItemAttributes itemAttributes) { if (!((Object)(object)itemAttributes == (Object)null)) { return (Object)(object)((Component)itemAttributes).GetComponent() == (Object)null; } return true; } } [HarmonyPatch(typeof(PunManager), "AddingItem")] internal static class PunAddingItemPatch { [HarmonyPostfix] private static void Postfix(string itemName, ItemAttributes itemAttributes) { if (!((Object)(object)itemAttributes == (Object)null)) { Item val = itemAttributes.item; if ((Object)(object)val == (Object)null && (Object)(object)StatsManager.instance != (Object)null && StatsManager.instance.itemDictionary.TryGetValue(itemName, out var value)) { val = value; } if (!((Object)(object)val == (Object)null) && Plugin.IsMedvacItem(val)) { ShopRegistry.ConvertToHealer(((Component)itemAttributes).gameObject, val); } } } } [HarmonyPatch(typeof(PunManager), "TruckPopulateItemVolumes")] internal static class TruckPopulatePatch { [HarmonyPostfix] private static void Postfix() { if ((Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ShopRegistry.ConvertAllNextFrame()); } else { ShopRegistry.ConvertAllMedvacInScene(); } } } [HarmonyPatch(typeof(ItemAttributes), "LateStart")] internal static class ItemAttributesLateStartPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance) { if (!((Object)(object)__instance == (Object)null) && Plugin.IsMedvacItem(__instance.item)) { ShopRegistry.ConvertToHealer(((Component)__instance).gameObject, __instance.item); ItemNamePatch.ForceName(__instance); } } } [HarmonyPatch(typeof(ItemManager), "ItemsInitialize")] internal static class ItemManagerInitPatch { [HarmonyPostfix] private static void Postfix() { ShopRegistry.TryInject(StatsManager.instance); ShopRegistry.RefreshRamCache(); } } [HarmonyPatch(typeof(ItemAttributes), "GetValue")] internal static class ItemValuePatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ItemAttributes __instance) { ShopRegistry.BindValueRange(__instance); } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance) { ShopRegistry.ApplyTierPrice(__instance); } } [HarmonyPatch(typeof(ItemAttributes), "GetValueRPC")] internal static class ItemValueRpcPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance) { ShopRegistry.ApplyTierPrice(__instance); } } [HarmonyPatch(typeof(SemiFunc), "ShopUpdateCost")] internal static class ShopCostPatch { [HarmonyPrefix] private static void Prefix() { ShopManager instance = ShopManager.instance; if ((Object)(object)instance == (Object)null || instance.shoppingList == null) { return; } foreach (ItemAttributes shopping in instance.shoppingList) { ShopRegistry.ApplyTierPrice(shopping, rollIfNeeded: false); } } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix() { ShopManager instance = ShopManager.instance; if ((Object)(object)instance == (Object)null || instance.shoppingList == null) { return; } int num = 0; HashSet hashSet = new HashSet(); foreach (ItemAttributes shopping in instance.shoppingList) { if ((Object)(object)shopping == (Object)null) { continue; } if ((Object)(object)((Component)shopping).GetComponent() == (Object)null && (Plugin.IsMedvacItem(shopping.item) || (shopping.itemName != null && shopping.itemName.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) >= 0))) { ShopRegistry.ConvertToHealer(((Component)shopping).gameObject, shopping.item); } ShopRegistry.ApplyTierPrice(shopping, rollIfNeeded: false); if (Plugin.IsMedvacItem(shopping.item) || (shopping.itemName != null && shopping.itemName.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) >= 0)) { string text = (((Object)(object)shopping.item != (Object)null) ? ((Object)shopping.item).name : shopping.itemName); if (!hashSet.Add(text ?? "MEDVAC")) { continue; } } num += Mathf.Max(0, shopping.value); } instance.totalCost = num; } } [HarmonyPatch(typeof(ItemAttributes), "Start")] internal static class ItemAttributesStartPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance) { if (!((Object)(object)__instance == (Object)null)) { GameObject gameObject = ((Component)__instance).gameObject; if (Plugin.IsMedvacItem(__instance.item) || (((Object)gameObject).name != null && ((Object)gameObject).name.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) >= 0) || (Object)(object)gameObject.GetComponent() != (Object)null) { ShopRegistry.ConvertToHealer(gameObject, __instance.item); ItemNamePatch.ForceName(__instance); } } } } [HarmonyPatch(typeof(ItemAttributes), "ShowInfo")] internal static class ItemNamePatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ItemAttributes __instance) { ForceName(__instance); } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance) { ForceName(__instance); if (Time.frameCount % 15 == 0) { RelabelWorld(__instance); } } internal static string Label(MedvacRuntime runtime) { if ((Object)(object)runtime == (Object)null) { return "MEDVAC"; } string text = (((Object)(object)runtime.boundItem != (Object)null) ? runtime.boundItem.itemName : "MEDVAC"); if (runtime.tankMax > 0) { return text + " " + runtime.tankHp + "/" + runtime.tankMax + "HP"; } return text; } internal static void ForceName(ItemAttributes attrs) { if ((Object)(object)attrs == (Object)null) { return; } MedvacRuntime medvacRuntime = ((Component)attrs).GetComponent() ?? ((Component)attrs).GetComponentInParent(); if (!((Object)(object)medvacRuntime == (Object)null)) { if ((Object)(object)medvacRuntime.boundItem != (Object)null) { attrs.item = medvacRuntime.boundItem; } attrs.instanceName = (attrs.promptName = (attrs.itemName = Label(medvacRuntime))); medvacRuntime.ApplyIdentity(); } } internal static void RelabelWorld(ItemAttributes attrs) { MedvacRuntime medvacRuntime = (((Object)(object)attrs != (Object)null) ? ((Component)attrs).GetComponent() : null); if ((Object)(object)medvacRuntime == (Object)null) { return; } string text = Label(medvacRuntime); Type type = AccessTools.TypeByName("TMPro.TMP_Text") ?? AccessTools.TypeByName("TMPro.TextMeshProUGUI"); if (type == null) { return; } PropertyInfo propertyInfo = AccessTools.Property(type, "text"); if (propertyInfo == null) { return; } Object[] array; try { array = Object.FindObjectsOfType(type); } catch { return; } Object[] array2 = array; foreach (Object val in array2) { if (!(val == (Object)null)) { string text2 = propertyInfo.GetValue(val) as string; if (!string.IsNullOrEmpty(text2) && (text2.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) < 0 || text2.IndexOf("HP", StringComparison.OrdinalIgnoreCase) < 0) && (text2.IndexOf("RECHARGE", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("ZERO GRAVITY", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("INDESTRUCTIBLE", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("FEATHER", StringComparison.OrdinalIgnoreCase) >= 0 || (text2.IndexOf("DRONE", StringComparison.OrdinalIgnoreCase) >= 0 && text2.IndexOf("[E]", StringComparison.OrdinalIgnoreCase) >= 0))) { bool flag = text2.IndexOf("[E]", StringComparison.OrdinalIgnoreCase) >= 0; propertyInfo.SetValue(val, flag ? (text + " [E]") : text); } } } } } [HarmonyPatch(typeof(ItemAttributes), "GetItemNameLocalized")] internal static class LocalizedNamePatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance, ref string __result) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponent() == (Object)null)) { __result = ItemNamePatch.Label(((Component)__instance).GetComponent()); } } } [HarmonyPatch(typeof(ItemAttributes), "ShowingInfo")] internal static class ItemShowingInfoPatch { [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(ItemAttributes __instance) { ItemNamePatch.ForceName(__instance); } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance) { ItemNamePatch.ForceName(__instance); } } [HarmonyPatch(typeof(ItemAttributes), "Update")] internal static class ItemAttributesUpdatePatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ItemAttributes __instance) { ItemNamePatch.ForceName(__instance); } } [HarmonyPatch(typeof(ItemDroneHeal), "Update")] internal static class ItemDroneHealUpdateGuard { [HarmonyPrefix] private static bool Prefix(ItemDroneHeal __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponent() == (Object)null; } return true; } } [HarmonyPatch(typeof(ItemDrone), "DrawBeamLine")] internal static class BlockMedvacBeam { [HarmonyPrefix] private static bool Prefix(ItemDrone __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponent() == (Object)null; } return true; } } [HarmonyPatch(typeof(ItemDrone), "StateBeamDeployed")] internal static class BlockMedvacBeamState { [HarmonyPrefix] private static bool Prefix(ItemDrone __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponent() == (Object)null; } return true; } } [HarmonyPatch(typeof(ItemDrone), "StateAttached")] internal static class BlockMedvacAttach { [HarmonyPrefix] private static bool Prefix(ItemDrone __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponent() == (Object)null; } return true; } } [HarmonyPatch(typeof(ItemDrone), "TargetFindPlayer")] internal static class BlockMedvacPlayerTarget { [HarmonyPrefix] private static bool Prefix(ItemDrone __instance, ref bool __result) { if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).GetComponent() == (Object)null) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ItemDrone), "ActivateMagnet")] internal static class BlockMedvacMagnet { [HarmonyPrefix] private static bool Prefix(ItemDrone __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponent() == (Object)null; } return true; } } [HarmonyPatch(typeof(ItemDrone), "FixedUpdate")] internal static class BlockMedvacVanillaFlight { [HarmonyPrefix] private static bool Prefix(ItemDrone __instance) { if (!((Object)(object)__instance == (Object)null)) { return (Object)(object)((Component)__instance).GetComponent() == (Object)null; } return true; } } [HarmonyPatch(typeof(ItemAttributes), "GenerateIcon")] internal static class MedvacIconPatch { [HarmonyPrefix] private static bool Prefix(ItemAttributes __instance, ref IEnumerator __result) { if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).GetComponent() == (Object)null) { return true; } __instance.icon = MedvacIcon.Sprite; __instance.hasIcon = true; __result = Empty(); return false; } private static IEnumerator Empty() { yield break; } } [HarmonyPatch(typeof(ItemDroneHeal), "CustomTargetingCondition")] internal static class HealTouchPatch { [HarmonyPostfix] private static void Postfix(ItemDroneHeal __instance, GameObject target, ref bool __result) { if (!((Object)(object)__instance == (Object)null) && (Object)(object)((Component)__instance).GetComponent() != (Object)null) { __result = false; } } } [HarmonyPatch(typeof(ItemHealthPack), "UsedRPC")] internal static class MedkitRefillPatch { [HarmonyPrefix] private static bool Prefix(ItemHealthPack __instance) { return true; } } internal static class RamSpawnPatch { private static bool _applied; internal static void TryApply(Harmony harmony) { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown if (_applied || harmony == null) { return; } try { Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { type = assembly.GetType("RepoAdminMenu.Utils.ItemUtil"); if (type == null) { Type[] types = assembly.GetTypes(); foreach (Type type2 in types) { if (type2.Name == "ItemUtil" && type2.Namespace != null && type2.Namespace.IndexOf("RepoAdmin") >= 0) { type = type2; break; } } } } catch { } if (type != null) { break; } } if (type == null) { return; } MethodInfo methodInfo = null; MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo2 in methods) { if (methodInfo2.Name.IndexOf("spawn", StringComparison.OrdinalIgnoreCase) >= 0) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length >= 1 && parameters[0].ParameterType.Name == "Item") { methodInfo = methodInfo2; break; } } } if (methodInfo == null) { List list = new List(); methods = type.GetMethods(); foreach (MethodInfo methodInfo3 in methods) { list.Add(methodInfo3.Name); } Plugin.Log.LogWarning((object)("R.A.M. ItemUtil found but no spawn method. Methods: " + string.Join(", ", list.ToArray()))); } else { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(RamSpawnPatch), "Prefix", (Type[])null) { priority = 800 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _applied = true; Plugin.Log.LogInfo((object)("Hooked R.A.M. " + type.FullName + "." + methodInfo.Name)); } } catch (Exception ex) { Plugin.Log.LogError((object)("R.A.M. hook failed: " + ex)); } } public static bool Prefix(Item item) { if ((Object)(object)item == (Object)null) { return true; } if (!Plugin.IsMedvacItem(item)) { return true; } Plugin.Log.LogInfo((object)("R.A.M. spawn intercepted for " + ((Object)item).name)); ShopRegistry.SpawnInWorld(item); return false; } } internal static class ShopRegistry { internal static readonly Dictionary Templates = new Dictionary(); internal static GameObject VanillaPrefab; internal static PrefabRef VanillaPrefabRef; internal static string VanillaPhotonId = "Items/Item Drone Feather"; internal static bool Injected; internal static readonly Dictionary Prefabs = new Dictionary(); internal static readonly HashSet RepoLibOnce = new HashSet(); private static bool _limitPatched; private static bool _leftPool; private static Item _poolLog; private static readonly List SeenVolumes = new List(); private static bool _waitRunning; private static bool _placedThisVisit; internal static void TryInject(StatsManager sm) { //IL_0163: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024b: 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_0128: 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_0158: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.InjectShop.Value || (Object)(object)sm == (Object)null || sm.itemDictionary == null || sm.itemDictionary.Count == 0) { return; } Item val = FindDrone(sm); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"No drone item in dictionary yet."); return; } GameObject val2 = ResolvePrefab(val); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"Drone prefab missing, cannot bind MEDVAC."); return; } VanillaPrefab = val2; VanillaPrefabRef = val.prefab; if (!string.IsNullOrEmpty(((Object)val).name)) { VanillaPhotonId = "Items/" + ((Object)val).name; } Tier[] tiers = Plugin.Tiers; foreach (Tier tier in tiers) { string text = "Item Drone MEDVAC " + tier.Name; Item val3 = FindExisting(sm, text, tier.ItemName); if ((Object)(object)val3 == (Object)null) { val3 = Object.Instantiate(val); ((Object)val3).name = text; val3.itemName = tier.ItemName; val3.description = $"Healer drone {tier.TankHp} HP tank. Heals on hull contact. Activate to patrol. Refill with medkits."; val3.disabled = false; val3.itemType = (itemType)0; val3.maxAmount = 8; val3.maxAmountInShop = 1; val3.maxPurchase = false; val3.physicalItem = true; val3.itemSecretShopType = (itemSecretShopType)0; try { val3.emojiIcon = (emojiIcon)0; } catch { val3.emojiIcon = val.emojiIcon; } val3.itemVolume = (itemVolume)0; val3.prefab = val.prefab; Value val4 = ScriptableObject.CreateInstance(); ((Object)val4).name = "Value MEDVAC " + tier.Name; val4.valueMin = tier.PriceMin; val4.valueMax = tier.PriceMax; val3.value = val4; sm.itemDictionary[text] = val3; EnsureDict(sm.itemStatBattery, text, 100); EnsureDict(sm.itemsPurchased, text, 0); Plugin.Log.LogInfo((object)$"Registered {text} ({tier.TankHp} HP)."); } BindHealerPrefab(val3, val2, tier); val3.maxAmount = 8; val3.maxAmountInShop = 1; val3.maxPurchase = false; val3.disabled = false; val3.itemType = (itemType)0; val3.itemVolume = (itemVolume)0; val3.itemSecretShopType = (itemSecretShopType)0; } Injected = true; ClampShopCaps(sm); } internal static void ClampShopCaps(StatsManager sm = null) { //IL_0123: 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_013d: Unknown result type (might be due to invalid IL or missing references) sm = sm ?? StatsManager.instance; if ((Object)(object)sm == (Object)null || sm.itemDictionary == null) { return; } foreach (KeyValuePair item in sm.itemDictionary) { if (!((Object)(object)item.Value == (Object)null) && Plugin.IsMedvacItem(item.Value)) { if (item.Value.maxAmountInShop != 1 || item.Value.maxAmount != 8) { Plugin.Log.LogInfo((object)("Shop cap " + item.Value.itemName + " " + item.Value.maxAmountInShop + "/" + item.Value.maxAmount + " -> 1/8")); item.Value.maxAmountInShop = 1; item.Value.maxAmount = 8; } item.Value.disabled = false; item.Value.maxPurchase = false; item.Value.itemType = (itemType)0; item.Value.itemVolume = (itemVolume)0; item.Value.itemSecretShopType = (itemSecretShopType)0; } } } internal static void ClampShopCapsNoArgs() { ClampShopCaps(); if ((Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(ClampSoon()); } } private static IEnumerator ClampSoon() { yield return null; ClampShopCaps(); yield return (object)new WaitForSeconds(0.15f); ClampShopCaps(); } internal static void PatchNoItemSpawnLimit(Harmony harmony) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown if (harmony == null || _limitPatched) { return; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { string text = ""; try { text = assembly.GetName().Name ?? ""; } catch { continue; } if (text.IndexOf("NoItemSpawnLimit", StringComparison.OrdinalIgnoreCase) < 0) { continue; } Type[] types = assembly.GetTypes(); foreach (Type type in types) { MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.IsAbstract || methodInfo.ContainsGenericParameters) { continue; } string name = methodInfo.Name; if (name.IndexOf("Apply", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Limit", StringComparison.OrdinalIgnoreCase) >= 0 || !(name != "Start") || !(name != "Awake")) { try { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(ShopRegistry), "ClampShopCapsNoArgs", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Plugin.Log.LogInfo((object)("Clamping MEDVAC shop cap after " + type.Name + "." + name)); } catch { } } } } _limitPatched = true; } } catch (Exception ex) { Plugin.Log.LogDebug((object)("NoItemSpawnLimit patch skipped: " + ex.Message)); } } internal static void SpawnInWorld(Item item) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //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_0053: 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_0062: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = SemiFunc.PlayerGetLocal() ?? PlayerAvatar.instance; Vector3 val2 = Vector3.up * 1.2f; Quaternion rot = Quaternion.identity; if ((Object)(object)val != (Object)null) { val2 = ((Component)val).transform.position + Vector3.up * 1.15f + ((Component)val).transform.forward * 1.2f; rot = ((Component)val).transform.rotation; } if (MedvacNet.IsMultiplayer() && !MedvacNet.IsMaster()) { Plugin.Log.LogInfo((object)"Client asked host-side spawn; skip."); } else if ((Object)(object)MedvacNet.Spawn(item, val2, rot) == (Object)null) { Plugin.Log.LogError((object)"MEDVAC spawn failed: no networked drone prefab."); } else { Plugin.Log.LogInfo((object)$"Spawned healer {item.itemName} at {val2}"); } } internal static void ConvertAllMedvacInScene() { ItemAttributes[] array = Object.FindObjectsOfType(); foreach (ItemAttributes val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.item == (Object)null) && Plugin.IsMedvacItem(val.item) && !((Object)(object)((Component)val).GetComponent() != (Object)null)) { ConvertToHealer(((Component)val).gameObject, val.item); } } } internal static IEnumerator ConvertVolumeNextFrame(Item item, ItemVolume volume) { yield return null; BindSpawned(item, volume); yield return (object)new WaitForSeconds(0.35f); BindSpawned(item, volume); ConvertAllMedvacInScene(); } internal static IEnumerator ConvertAllNextFrame() { yield return null; yield return (object)new WaitForSeconds(0.15f); ConvertAllMedvacInScene(); } internal static void BindSpawned(Item item, ItemVolume volume) { if (!((Object)(object)item == (Object)null) && Plugin.IsMedvacItem(item)) { if ((Object)(object)volume != (Object)null && (Object)(object)volume.itemAttributes != (Object)null) { ConvertToHealer(((Component)volume.itemAttributes).gameObject, item); } else { ConvertAllMedvacInScene(); } } } internal static GameObject Alive(GameObject go) { if (!Object.op_Implicit((Object)(object)go)) { return null; } return go; } private static GameObject ResolveAnyDronePrefab() { StatsManager instance = StatsManager.instance; if ((Object)(object)instance == (Object)null || instance.itemDictionary == null) { return null; } foreach (KeyValuePair item in instance.itemDictionary) { Item value = item.Value; if ((Object)(object)value == (Object)null || Plugin.IsMedvacItem(value)) { continue; } try { GameObject val = ((value.prefab != null) ? ((PrefabRef)(object)value.prefab).Prefab : null); if (Object.op_Implicit((Object)(object)val)) { return val; } } catch { } } return null; } internal static void ConvertNearby(Item item) { //IL_0043: 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) PlayerAvatar val = SemiFunc.PlayerGetLocal() ?? PlayerAvatar.instance; if ((Object)(object)val == (Object)null) { return; } ItemDrone[] array = Object.FindObjectsOfType(); ItemDrone val2 = null; float num = 4f; ItemDrone[] array2 = array; foreach (ItemDrone val3 in array2) { if (!((Object)(object)val3 == (Object)null)) { float num2 = Vector3.Distance(((Component)val3).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; val2 = val3; } } } if ((Object)(object)val2 != (Object)null && ((Object)(object)((Component)val2).GetComponent() != (Object)null || (((Object)val2).name != null && ((Object)val2).name.IndexOf("MEDVAC") >= 0))) { ConvertToHealer(((Component)val2).gameObject, item); } } internal static void ConvertToHealer(GameObject go, Item item) { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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) if (!((Object)(object)go == (Object)null) && !((Object)(object)item == (Object)null) && Plugin.IsMedvacItem(item)) { StripForeignDroneLogic(go); ItemAttributes val = go.GetComponent() ?? go.GetComponentInChildren(); if ((Object)(object)val != (Object)null) { val.item = item; val.itemName = (((Object)(object)item != (Object)null) ? item.itemName : val.itemName); val.icon = MedvacIcon.Sprite; val.hasIcon = true; ApplyTierPrice(val); } MedvacRuntime.PendingBind = item; MedvacRuntime medvacRuntime = go.GetComponent(); if ((Object)(object)medvacRuntime == (Object)null) { medvacRuntime = go.AddComponent(); } medvacRuntime.boundItem = item; medvacRuntime.ApplyIdentity(); MedvacRuntime.PendingBind = null; ItemDroneHeal component = go.GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; Object.Destroy((Object)(object)component); } if ((Object)(object)go.GetComponent() == (Object)null) { go.AddComponent(); } ItemDrone component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.targetPlayers = false; component2.targetValuables = false; component2.targetEnemies = false; component2.targetNonValuables = false; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.25f, 1f, 0.45f, 1f); AccessTools.Field(typeof(ItemDrone), "droneColor")?.SetValue(component2, val2); AccessTools.Field(typeof(ItemDrone), "beamColor")?.SetValue(component2, val2); AccessTools.Field(typeof(ItemDrone), "batteryColor")?.SetValue(component2, val2); } } } internal static void BindValueRange(ItemAttributes attrs) { if ((Object)(object)attrs == (Object)null) { return; } MedvacRuntime medvacRuntime = ((Component)attrs).GetComponent() ?? ((Component)attrs).GetComponentInParent(); Item val = (((Object)(object)medvacRuntime != (Object)null) ? medvacRuntime.boundItem : attrs.item); if (!((Object)(object)val == (Object)null) && Plugin.IsMedvacItem(val)) { Tier tier = Plugin.GetTier(val); attrs.itemValueMin = tier.PriceMin; attrs.itemValueMax = tier.PriceMax; if ((Object)(object)val.value != (Object)null) { val.value.valueMin = tier.PriceMin; val.value.valueMax = tier.PriceMax; } } } internal static int KMin(Tier tier) { return Mathf.Max(1, Mathf.RoundToInt(tier.PriceMin / 1000f)); } internal static int KMax(Tier tier) { return Mathf.Max(KMin(tier), Mathf.RoundToInt(tier.PriceMax / 1000f)); } internal static int RollTierPrice(Tier tier) { int num = KMin(tier); int num2 = KMax(tier); return Random.Range(num, num2 + 1); } internal static void ApplyTierPrice(ItemAttributes attrs, bool rollIfNeeded = true) { if ((Object)(object)attrs == (Object)null) { return; } MedvacRuntime medvacRuntime = ((Component)attrs).GetComponent() ?? ((Component)attrs).GetComponentInParent(); Item val = (((Object)(object)medvacRuntime != (Object)null) ? medvacRuntime.boundItem : attrs.item); if (!((Object)(object)val == (Object)null) && Plugin.IsMedvacItem(val)) { Tier tier = Plugin.GetTier(val); int num = KMin(tier); int num2 = KMax(tier); BindValueRange(attrs); int num3 = attrs.value; if (num3 >= num * 900) { num3 = Mathf.RoundToInt((float)num3 / 1000f); } if (num3 < num || num3 > num2) { num3 = (rollIfNeeded ? RollTierPrice(tier) : Mathf.Clamp((num3 <= 0) ? num : num3, num, num2)); } attrs.value = Mathf.Clamp(num3, num, num2); } } internal static void InjectIntoSpawnList(ItemVolume vol, List list) { //IL_001b: 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_0029: Invalid comparison between Unknown and I4 //IL_004f: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vol == (Object)null || list == null || (Object)(object)StatsManager.instance == (Object)null) { return; } bool flag = (int)vol.itemVolume == 0 || (int)vol.itemVolume == 1; bool flag2 = false; foreach (Item item in list) { if ((Object)(object)item != (Object)null && (int)item.itemType == 0) { flag2 = true; break; } } if (!flag && !flag2) { return; } int num = 0; foreach (KeyValuePair item2 in StatsManager.instance.itemDictionary) { Item value = item2.Value; if (!((Object)(object)value == (Object)null) && Plugin.IsMedvacItem(value)) { value.disabled = false; value.itemType = (itemType)0; value.itemVolume = (itemVolume)0; value.itemSecretShopType = (itemSecretShopType)0; if (value.maxAmountInShop < 1) { value.maxAmountInShop = 1; } if (!list.Contains(value)) { list.Add(value); num++; } } } if (num > 0) { Plugin.Log.LogInfo((object)("SpawnShopItem pool +" + num + " MEDVAC (list=" + list.Count + ", shelf=" + ((object)Unsafe.As(ref vol.itemVolume)/*cast due to .constrained prefix*/).ToString() + ")")); } } internal static void AddToShop(ShopManager shop) { if (!((Object)(object)shop == (Object)null) && shop.potentialItems != null) { int num = shop.potentialItems.RemoveAll((Item it) => (Object)(object)it != (Object)null && Plugin.IsMedvacItem(it)); if (num > 0 && !_leftPool) { _leftPool = true; Plugin.Log.LogInfo((object)("MEDVAC left shared shop roll (-" + num + "). Own shelf after other mods.")); } } } internal static IEnumerator ForceShopStockDelayed() { yield return (object)new WaitForSeconds(0.8f); ForceShopStock(); yield return (object)new WaitForSeconds(1.2f); ForceShopStock(); } internal static void ForceShopStock() { } internal static bool HasMedvacInShop() { //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_006b: 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_0054: 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) ItemAttributes[] array = Resources.FindObjectsOfTypeAll(); foreach (ItemAttributes val in array) { if ((Object)(object)val == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || IsTemplate((Component)(object)val) || ((Object)(object)((Component)val).transform != (Object)null && ((Component)val).transform.position.y < -500f)) { continue; } scene = ((Component)val).gameObject.scene; if ((((Scene)(ref scene)).name ?? "").IndexOf("DontDestroyOnLoad", StringComparison.OrdinalIgnoreCase) < 0 && (int)((Object)val).hideFlags == 0) { if ((Object)(object)((Component)val).GetComponent() != (Object)null) { return true; } if (Plugin.IsMedvacItem(val.item)) { return true; } if ((val.itemName ?? "").IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } } foreach (ItemVolume item in CollectVolumes()) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item.itemAttributes == (Object)null) && Plugin.IsMedvacItem(item.itemAttributes.item)) { return true; } } return false; } internal static Item PickRandomMedvac() { if ((Object)(object)StatsManager.instance == (Object)null) { return null; } List list = new List(); foreach (KeyValuePair item in StatsManager.instance.itemDictionary) { if (!((Object)(object)item.Value == (Object)null) && Plugin.IsMedvacItem(item.Value) && !list.Contains(item.Value)) { list.Add(item.Value); } } if (list.Count == 0) { return null; } return list[Random.Range(0, list.Count)]; } internal static void NoteVolume(ItemVolume vol) { if (!((Object)(object)vol == (Object)null) && !SeenVolumes.Contains(vol)) { SeenVolumes.Add(vol); } } private static bool IsUsableEmpty(ItemVolume vol) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vol == (Object)null) { return false; } if ((Object)(object)vol.itemAttributes != (Object)null) { return false; } if ((Object)(object)((Component)vol).transform != (Object)null && ((Component)vol).transform.position.y < -500f) { return false; } return true; } private static ItemVolume MakeOwnShelf() { //IL_0039: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_004c: Unknown result type (might be due to invalid IL or missing references) ItemVolume val = null; foreach (ItemVolume item in CollectVolumes()) { if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).transform == (Object)null) && !(((Component)item).transform.position.y < -500f)) { if ((int)item.itemVolume == 0) { val = item; break; } if ((Object)(object)val == (Object)null) { val = item; } } } if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = Object.Instantiate(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)val2).name = "Item Volume MEDVAC"; val2.SetActive(true); val2.transform.position = ((Component)val).transform.position + ((Component)val).transform.right * 0.9f + Vector3.up * 0.02f; val2.transform.rotation = ((Component)val).transform.rotation; ItemAttributes[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (ItemAttributes val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)(object)val2)) { Object.Destroy((Object)(object)((Component)val3).gameObject); } } ItemVolume val4 = val2.GetComponent() ?? val2.GetComponentInChildren(true); if ((Object)(object)val4 != (Object)null) { val4.itemAttributes = null; NoteVolume(val4); } ShopManager instance = ShopManager.instance; if ((Object)(object)instance != (Object)null && instance.itemVolumes != null && (Object)(object)val4 != (Object)null && !instance.itemVolumes.Contains(val4)) { instance.itemVolumes.Add(val4); } Plugin.Log.LogInfo((object)("Added own MEDVAC shelf next to " + ((Object)val).name)); return val4; } internal static void SnapshotVolumes() { SnapshotFrom(ShopManager.instance); } internal static void SnapshotFrom(ShopManager shop) { if ((Object)(object)shop == (Object)null) { return; } int count = SeenVolumes.Count; if (shop.itemVolumes != null) { foreach (ItemVolume itemVolume in shop.itemVolumes) { NoteVolume(itemVolume); } } if (shop.secretItemVolumes != null) { foreach (KeyValuePair> secretItemVolume in shop.secretItemVolumes) { if (secretItemVolume.Value == null) { continue; } foreach (ItemVolume item in secretItemVolume.Value) { NoteVolume(item); } } } if (SeenVolumes.Count != count) { Plugin.Log.LogInfo((object)("Shelf volumes seen=" + SeenVolumes.Count)); } } private static bool PlaceLoose(Item item) { return PlaceNextToShopItem(item); } private static bool PlaceNextToShopItem(Item item) { //IL_003e: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_01ac: 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) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_009c: 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_00e4: Unknown result type (might be due to invalid IL or missing references) ItemAttributes val = null; ItemAttributes[] array = Resources.FindObjectsOfTypeAll(); foreach (ItemAttributes val2 in array) { if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null) { continue; } Scene scene = ((Component)val2).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || IsTemplate((Component)(object)val2) || (int)((Object)val2).hideFlags != 0 || ((Object)(object)((Component)val2).transform != (Object)null && ((Component)val2).transform.position.y < -200f)) { continue; } scene = ((Component)val2).gameObject.scene; if ((((Scene)(ref scene)).name ?? "").IndexOf("DontDestroyOnLoad", StringComparison.OrdinalIgnoreCase) >= 0 || (Object)(object)((Component)val2).GetComponent() != (Object)null) { continue; } val = val2; try { if ((Object)(object)val2.item != (Object)null && (int)val2.item.itemType == 0) { break; } } catch { } } if ((Object)(object)(Alive(GetTemplate(item)) ?? Alive(VanillaPrefab)) == (Object)null && !MedvacNet.IsMultiplayer()) { return false; } Vector3 pos; Quaternion rot; if ((Object)(object)val != (Object)null) { pos = ((Component)val).transform.position + ((Component)val).transform.right * 0.75f + Vector3.up * 0.04f; rot = ((Component)val).transform.rotation; } else { ShopManager instance = ShopManager.instance; if ((Object)(object)instance == (Object)null) { return false; } pos = ((Component)instance).transform.position + Vector3.up * 1.15f + ((Component)instance).transform.forward * 1.4f; rot = Quaternion.identity; } GameObject val3 = MedvacNet.Spawn(item, pos, rot); if ((Object)(object)val3 == (Object)null) { return false; } ActivateShopInstance(val3); MarkShopStock(val3); Plugin.Log.LogInfo((object)("Shelf neighbor spawn " + item.itemName + (((Object)(object)val != (Object)null) ? (" next to " + ((Object)val).name) : " (no neighbor)"))); _placedThisVisit = (Object)(object)val3.GetComponent() != (Object)null; return _placedThisVisit; } internal static bool ForceAtLeastOne() { //IL_0046: 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_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ShopManager.instance == (Object)null) { return false; } try { if (SemiFunc.IsNotMasterClient()) { return true; } } catch { } if (HasMedvacInShop()) { return true; } Item val = PickRandomMedvac(); if ((Object)(object)val == (Object)null) { return false; } val.disabled = false; val.itemType = (itemType)0; val.itemVolume = (itemVolume)0; val.itemSecretShopType = (itemSecretShopType)0; if (val.maxAmountInShop < 1) { val.maxAmountInShop = 1; } ItemVolume val2 = PickEmptyDroneVolume() ?? MakeOwnShelf(); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"No shelf for MEDVAC, spawning in shop."); return PlaceLoose(val); } Plugin.Log.LogInfo((object)("Own shelf " + val.itemName + " -> " + ((Object)val2).name)); PlaceOnShelf(val, val2); if (HasMedvacInShop() || ((Object)(object)val2.itemAttributes != (Object)null && Plugin.IsMedvacItem(val2.itemAttributes.item))) { _placedThisVisit = true; return true; } return false; } private static ItemVolume PickEmptyDroneVolume() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) List list = CollectVolumes(); foreach (ItemVolume item in list) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item.itemAttributes != (Object)null) && (int)item.itemVolume == 0) { return item; } } foreach (ItemVolume item2 in list) { if (!((Object)(object)item2 == (Object)null) && !((Object)(object)item2.itemAttributes != (Object)null)) { return item2; } } return null; } private static ItemVolume PickShelf(List volumes, Item item) { //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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 //IL_0091: Unknown result type (might be due to invalid IL or missing references) foreach (ItemVolume volume in volumes) { if (!((Object)(object)volume == (Object)null) && !((Object)(object)volume.itemAttributes != (Object)null) && (Object)(object)item != (Object)null && volume.itemVolume == item.itemVolume) { return volume; } } foreach (ItemVolume volume2 in volumes) { if (!((Object)(object)volume2 == (Object)null) && !((Object)(object)volume2.itemAttributes != (Object)null) && ((int)volume2.itemVolume == 1 || (int)volume2.itemVolume == 0)) { return volume2; } } foreach (ItemVolume volume3 in volumes) { if (!((Object)(object)volume3 == (Object)null) && !((Object)(object)volume3.itemAttributes != (Object)null)) { return volume3; } } return null; } private static void MarkShopStock(GameObject go) { if (!((Object)(object)go == (Object)null)) { ItemAttributes val = go.GetComponent() ?? go.GetComponentInChildren(); if ((Object)(object)val != (Object)null) { val.shopItem = true; } ItemDrone component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.itemActivated = false; component.targetPlayers = false; } ItemToggle component2 = go.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.toggleState = false; } } } private static void PlaceOnShelf(Item item, ItemVolume slot) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0041: 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_004a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)item == (Object)null) && !((Object)(object)slot == (Object)null) && !((Object)(object)slot.itemAttributes != (Object)null)) { Vector3 pos = ((Component)slot).transform.position + Vector3.up * 0.12f; GameObject val = MedvacNet.Spawn(item, pos, ((Component)slot).transform.rotation); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("No live prefab for " + item.itemName)); return; } ActivateShopInstance(val); MarkShopStock(val); slot.itemAttributes = val.GetComponent() ?? val.GetComponentInChildren(); Plugin.Log.LogInfo((object)((((Object)(object)slot.itemAttributes != (Object)null) ? "Shop spawned " : "Shop FAILED ") + item.itemName + " on " + ((Object)slot).name)); } } private static void ActivateShopInstance(GameObject go) { if ((Object)(object)go == (Object)null) { return; } go.SetActive(true); ((Object)go).hideFlags = (HideFlags)0; Collider[] componentsInChildren = go.GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null) { val.enabled = true; } } Rigidbody[] componentsInChildren2 = go.GetComponentsInChildren(true); foreach (Rigidbody val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null)) { val2.detectCollisions = true; } } } internal static void RefreshRamCache() { try { Type type = AccessTools.TypeByName("RepoAdminMenu.Utils.ItemUtil"); if (!(type == null)) { AccessTools.Method(type, "Init", (Type[])null, (Type[])null)?.Invoke(null, null); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("R.A.M. refresh skipped: " + ex.Message)); } } private static void BindHealerPrefab(Item clone, GameObject sourcePrefab, Tier tier) { string name = ((Object)clone).name; if (Templates.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value) && ((Object)value).name != null && ((Object)value).name.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) >= 0) { BindLivePrefab(clone, value, Prefabs.TryGetValue(name, out var value2) ? value2 : clone.prefab); return; } GameObject val = Object.Instantiate(sourcePrefab); ((Object)val).name = name; ParkTemplate(val); Object.DontDestroyOnLoad((Object)(object)val); StripForeignDroneLogic(val); ItemAttributes val2 = val.GetComponent() ?? val.GetComponentInChildren(); if ((Object)(object)val2 != (Object)null) { val2.item = clone; val2.itemName = clone.itemName; } ConvertToHealer(val, clone); Templates[name] = val; if (!string.IsNullOrEmpty(clone.itemName)) { Templates[clone.itemName] = val; } PrefabRef prefabRef = RegisterRepoLibItemOnce(clone, val); BindLivePrefab(clone, val, prefabRef); Plugin.Log.LogInfo((object)("Live prefab bound for " + name)); } internal static void BindLivePrefabs(List items) { if (items == null) { return; } foreach (Item item in items) { if (!((Object)(object)item == (Object)null) && Plugin.IsMedvacItem(item)) { GameObject template = GetTemplate(item); if (!((Object)(object)template == (Object)null)) { BindLivePrefab(item, template, item.prefab); } } } } internal static void BindLivePrefab(Item clone, GameObject template, PrefabRef prefabRef) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (!((Object)(object)clone == (Object)null) && !((Object)(object)template == (Object)null)) { if (prefabRef == null) { prefabRef = clone.prefab; } if (prefabRef == null) { prefabRef = new PrefabRef(); } try { ((PrefabRef)(object)prefabRef).SetPrefab(template, (string)null); } catch (Exception ex) { Plugin.Log.LogDebug((object)("SetPrefab: " + ex.Message)); } clone.prefab = prefabRef; if (!string.IsNullOrEmpty(((Object)clone).name)) { Prefabs[((Object)clone).name] = prefabRef; } } } private static void ParkTemplate(GameObject template) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)template == (Object)null) { return; } ((Object)template).hideFlags = (HideFlags)0; template.SetActive(true); template.transform.position = new Vector3(0f, -8000f, 0f); Rigidbody[] componentsInChildren = template.GetComponentsInChildren(true); foreach (Rigidbody val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { val.isKinematic = true; val.detectCollisions = false; } } Collider[] componentsInChildren2 = template.GetComponentsInChildren(true); foreach (Collider val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null)) { val2.enabled = false; } } } internal static bool IsTemplate(Component c) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null) { return true; } if ((Object)(object)c.transform != (Object)null && c.transform.position.y < -1000f) { return true; } return false; } internal static void ResetShopWait() { _waitRunning = false; _placedThisVisit = false; _poolLog = null; _leftPool = false; SeenVolumes.Clear(); } internal static IEnumerator AfterVanillaShopPopulate() { if (_waitRunning) { yield break; } _waitRunning = true; try { bool placed = false; int shopTicks = 0; for (int i = 0; i < 36; i++) { yield return (object)new WaitForSeconds(0.35f); bool flag = false; try { flag = SemiFunc.RunIsShop(); } catch { } if (!flag) { continue; } shopTicks++; SnapshotVolumes(); ConvertAllMedvacInScene(); int num = CountSceneShopItems(); int count = CollectVolumes().Count; if ((num >= 3 || shopTicks >= 20) && (count != 0 || num >= 1 || shopTicks >= 22)) { if (HasMedvacInShop()) { Plugin.Log.LogInfo((object)("Shop has MEDVAC. vols=" + count)); _placedThisVisit = true; placed = true; break; } if (_placedThisVisit) { placed = true; break; } if (ForceAtLeastOne()) { placed = true; break; } if (shopTicks >= 24) { break; } } } if (!placed) { Plugin.Log.LogWarning((object)("Shop missed MEDVAC. vols=" + CollectVolumes().Count + " empty=" + ((Object)(object)PickEmptyDroneVolume() != (Object)null) + " potential=" + CountPotential())); } } finally { _waitRunning = false; } } internal static int CountPotential() { int num = 0; ShopManager instance = ShopManager.instance; if ((Object)(object)instance == (Object)null || instance.potentialItems == null) { return 0; } foreach (Item potentialItem in instance.potentialItems) { if (Plugin.IsMedvacItem(potentialItem)) { num++; } } return num; } internal static int CountSceneShopItems() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) int num = 0; ItemAttributes[] array = Resources.FindObjectsOfTypeAll(); foreach (ItemAttributes val in array) { if (!((Object)(object)val == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && (int)((Object)val).hideFlags == 0) { num++; } } } return num; } internal static List CollectVolumes() { //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) List list = new List(); ShopManager instance = ShopManager.instance; if ((Object)(object)instance != (Object)null) { if (instance.itemVolumes != null) { foreach (ItemVolume itemVolume in instance.itemVolumes) { if ((Object)(object)itemVolume != (Object)null && !list.Contains(itemVolume)) { list.Add(itemVolume); } } } if (instance.secretItemVolumes != null) { foreach (KeyValuePair> secretItemVolume in instance.secretItemVolumes) { if (secretItemVolume.Value == null) { continue; } foreach (ItemVolume item in secretItemVolume.Value) { if ((Object)(object)item != (Object)null && !list.Contains(item)) { list.Add(item); } } } } } foreach (ItemVolume seenVolume in SeenVolumes) { if ((Object)(object)seenVolume != (Object)null && !list.Contains(seenVolume)) { list.Add(seenVolume); } } ItemVolume[] array = Resources.FindObjectsOfTypeAll(); foreach (ItemVolume val in array) { if ((Object)(object)val == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && (!((Object)(object)((Component)val).transform != (Object)null) || !(((Component)val).transform.position.y < -500f))) { scene = ((Component)val).gameObject.scene; if ((((Scene)(ref scene)).name ?? "").IndexOf("DontDestroyOnLoad", StringComparison.OrdinalIgnoreCase) < 0 && !list.Contains(val)) { list.Add(val); } } } return list; } internal static void StripForeignDroneLogic(GameObject go) { if ((Object)(object)go == (Object)null) { return; } DestroyComp(go); DestroyComp(go); DestroyComp(go); DestroyComp(go); DestroyComp(go); MonoBehaviour[] components = go.GetComponents(); foreach (MonoBehaviour val in components) { if (!((Object)(object)val == (Object)null)) { string name = ((object)val).GetType().Name; if (name.IndexOf("Medvac", StringComparison.OrdinalIgnoreCase) < 0 && (name.IndexOf("ZeroGravity", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("DroneFeather", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Featherguard", StringComparison.OrdinalIgnoreCase) >= 0)) { ((Behaviour)val).enabled = false; Object.Destroy((Object)(object)val); } } } Transform[] componentsInChildren = go.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name != null && !((Object)val2).name.StartsWith("MV_") && ((Object)val2).name.IndexOf("Featherguard", StringComparison.OrdinalIgnoreCase) >= 0) { ((Component)val2).gameObject.SetActive(false); } } } private static void DestroyComp(GameObject go) where T : Component { T val = go.GetComponent(); if ((Object)(object)val == (Object)null) { val = go.GetComponentInChildren(true); } if (!((Object)(object)val == (Object)null)) { Object.DestroyImmediate((Object)(object)val); } } private static GameObject ResolvePrefab(Item source) { try { string[] array = new string[2] { "Items/Item Drone Heal", "Item Drone Heal" }; for (int i = 0; i < array.Length; i++) { GameObject val = Resources.Load(array[i]); if ((Object)(object)val != (Object)null) { return val; } } } catch { } try { if ((Object)(object)source != (Object)null && source.prefab != null && ((PrefabRef)(object)source.prefab).IsValid()) { return ((PrefabRef)(object)source.prefab).Prefab; } } catch { } return null; } internal static GameObject GetTemplate(Item item) { if ((Object)(object)item == (Object)null) { return null; } if (Templates.TryGetValue(((Object)item).name ?? "", out var value) && (Object)(object)value != (Object)null) { return value; } if (Templates.TryGetValue(item.itemName ?? "", out value) && (Object)(object)value != (Object)null) { return value; } try { if (item.prefab != null && ((PrefabRef)(object)item.prefab).IsValid()) { return ((PrefabRef)(object)item.prefab).Prefab; } } catch { } return null; } internal static void RegisterPhotonPrefab(Item item) { if ((Object)(object)item == (Object)null) { return; } GameObject template = GetTemplate(item); if ((Object)(object)template == (Object)null) { return; } string key = "Items/" + ((Object)item).name; try { IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool; DefaultPool val = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null); if (val != null && val.ResourceCache != null) { val.ResourceCache[key] = template; val.ResourceCache[((Object)item).name] = template; } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Photon pool register skipped: " + ex.Message)); } TryRegisterNetwork(item, template); } internal static GameObject SpawnViaRepoLib(Item item, Vector3 pos, Quaternion rot) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) Type type = AccessTools.TypeByName("REPOLib.Modules.Items"); if (type == null) { return null; } MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name != "SpawnItem") { continue; } ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length >= 3 && parameters[0].ParameterType == typeof(Item) && parameters[1].ParameterType == typeof(Vector3) && parameters[2].ParameterType == typeof(Quaternion)) { object[] array = new object[parameters.Length]; array[0] = item; array[1] = pos; array[2] = rot; for (int j = 3; j < parameters.Length; j++) { array[j] = (parameters[j].HasDefaultValue ? parameters[j].DefaultValue : (parameters[j].ParameterType.IsValueType ? Activator.CreateInstance(parameters[j].ParameterType) : null)); } object? obj = methodInfo.Invoke(null, array); return (GameObject)((obj is GameObject) ? obj : null); } } return null; } private static PrefabRef RegisterRepoLibItemOnce(Item item, GameObject template) { if ((Object)(object)item == (Object)null || (Object)(object)template == (Object)null) { return null; } if (!RepoLibOnce.Add(((Object)item).name)) { Prefabs.TryGetValue(((Object)item).name, out var value); return value; } try { Type type = AccessTools.TypeByName("REPOLib.Modules.Items"); if (type == null) { Plugin.Log.LogWarning((object)"REPOLib.Modules.Items not found."); return null; } ItemAttributes val = template.GetComponent() ?? template.GetComponentInChildren(); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Template has no ItemAttributes: " + ((Object)template).name)); return null; } val.item = item; MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "RegisterItem")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1 && !(parameters[0].ParameterType.Name != "ItemAttributes")) { object? obj = methodInfo.Invoke(null, new object[1] { val }); Plugin.Log.LogInfo((object)("REPOLib RegisterItem once: " + item.itemName)); return (PrefabRef)((obj is PrefabRef) ? obj : null); } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("REPOLib RegisterItem skipped: " + ex.Message)); } return null; } private static void RegisterRepoLibItem(Item item) { RegisterRepoLibItemOnce(item, GetTemplate(item)); } private static void TryAddItemToStats(StatsManager sm, Item item) { if ((Object)(object)sm == (Object)null || (Object)(object)item == (Object)null) { return; } try { AccessTools.Method(((object)sm).GetType(), "AddItem", new Type[1] { typeof(Item) }, (Type[])null)?.Invoke(sm, new object[1] { item }); } catch (Exception ex) { Plugin.Log.LogDebug((object)("AddItem skipped: " + ex.Message)); } } private static object[] BuildDefaultArgs(MethodInfo m, Item item) { ParameterInfo[] parameters = m.GetParameters(); object[] array = new object[parameters.Length]; array[0] = item; for (int i = 1; i < parameters.Length; i++) { array[i] = (parameters[i].HasDefaultValue ? parameters[i].DefaultValue : (parameters[i].ParameterType.IsValueType ? Activator.CreateInstance(parameters[i].ParameterType) : null)); } return array; } private static void TryRegisterNetwork(Item item, GameObject prefab) { try { Type type = AccessTools.TypeByName("REPOLib.Modules.NetworkPrefabs"); if (!(type == null)) { AccessTools.Method(type, "RegisterNetworkPrefab", new Type[2] { typeof(string), typeof(GameObject) }, (Type[])null)?.Invoke(null, new object[2] { "Items/" + ((Object)item).name, prefab }); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Network prefab register skipped: " + ex.Message)); } } private static void EnsureDict(Dictionary dict, string key, int value) { if (dict != null && !string.IsNullOrEmpty(key) && !dict.ContainsKey(key)) { dict[key] = value; } } private static Item FindExisting(StatsManager sm, string assetName, string itemName) { foreach (KeyValuePair item in sm.itemDictionary) { Item value = item.Value; if (!((Object)(object)value == (Object)null) && (((Object)value).name == assetName || value.itemName == itemName || item.Key == assetName || item.Key == itemName)) { return value; } } return null; } internal static Item FindMedvacItem(string itemName, string assetName) { StatsManager instance = StatsManager.instance; if (instance?.itemDictionary == null) { return null; } foreach (KeyValuePair item in instance.itemDictionary) { Item value = item.Value; if (!((Object)(object)value == (Object)null) && Plugin.IsMedvacItem(value)) { if (!string.IsNullOrEmpty(itemName) && value.itemName == itemName) { return value; } if (!string.IsNullOrEmpty(assetName) && ((Object)value).name == assetName) { return value; } } } if (!string.IsNullOrEmpty(itemName)) { Tier[] tiers = Plugin.Tiers; foreach (Tier tier in tiers) { if (itemName.IndexOf(tier.Name, StringComparison.OrdinalIgnoreCase) < 0) { continue; } foreach (KeyValuePair item2 in instance.itemDictionary) { Item value2 = item2.Value; if ((Object)(object)value2 != (Object)null && Plugin.IsMedvacItem(value2) && (value2.itemName ?? "").IndexOf(tier.Name, StringComparison.OrdinalIgnoreCase) >= 0) { return value2; } } } } return PickRandomMedvac(); } private static Item FindDrone(StatsManager sm) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) Item val = null; Item val2 = null; foreach (KeyValuePair item in sm.itemDictionary) { Item value = item.Value; if ((Object)(object)value == (Object)null || Plugin.IsMedvacItem(value) || (((Object)value).name != null && ((Object)value).name.IndexOf("MEDVAC") >= 0)) { continue; } string text = (value.itemName ?? item.Key ?? ((Object)value).name ?? "").ToLowerInvariant(); if ((int)value.itemType != 0 && !text.Contains("drone")) { continue; } if (text.Contains("featherguard") || text.Contains("zero") || text.Contains("gravity") || text.Contains("feather") || text.Contains("recharge") || text.Contains("battery") || text.Contains("cargo") || text.Contains("echo") || text.Contains("mannequin") || text.Contains("backpack") || text.Contains("cart") || text.Contains("pocket")) { if ((Object)(object)val2 == (Object)null) { val2 = value; } continue; } if (text.Contains("heal")) { return value; } if ((Object)(object)val == (Object)null) { val = value; } } return val ?? val2; } } [DefaultExecutionOrder(32000)] public class MedvacRuntime : MonoBehaviour, IPunObservable { internal static Item PendingBind; public Item boundItem; public int tankHp; public int tankMax; private ItemBattery _battery; private ItemAttributes _attrs; private float _pulse; private float _idTimer; private ItemDrone _drone; private ItemToggle _toggle; private float _sipTimer; private Vector3 _idlePos; private bool _idleSet; private float _stuckT; private Vector3 _lastStuckPos; private float _lastPlayerDist = 999f; internal float promptUntil; private float _hudLinger; internal float Fill01 { get { if (tankMax > 0) { return Mathf.Clamp01((float)tankHp / (float)tankMax); } return 1f; } } private void Awake() { if ((Object)(object)PendingBind != (Object)null) { boundItem = PendingBind; PendingBind = null; } _drone = ((Component)this).GetComponent(); _toggle = ((Component)this).GetComponent(); ApplyIdentity(); } private void Start() { ApplyIdentity(); _battery = ((Component)this).GetComponent(); Tier tier = Plugin.GetTier(boundItem ?? (((Object)(object)_attrs != (Object)null) ? _attrs.item : null)); tankMax = tier.TankHp; tankHp = tankMax; HideVanillaCharge(); SyncBattery(); StripForever(); ObservePhoton(); } private void Update() { TickHudLinger(); _idTimer += Time.deltaTime; if (_idTimer > 0.4f) { _idTimer = 0f; ApplyIdentity(); } if ((Object)(object)_drone == (Object)null) { _drone = ((Component)this).GetComponent(); } if ((Object)(object)_toggle == (Object)null) { _toggle = ((Component)this).GetComponent(); } if ((Object)(object)_toggle != (Object)null) { _toggle.disabled = false; } bool flag = IsActivated(); if ((Object)(object)_drone != (Object)null) { _drone.targetPlayers = false; _drone.magnetActive = false; _drone.itemActivated = flag; if ((Object)(object)_drone.lineBetweenTwoPoints != (Object)null) { ((Behaviour)_drone.lineBetweenTwoPoints).enabled = false; } } TrySipMedkits(flag); if (!InShopHub() && MedvacNet.IsMaster() && flag && tankHp > 0) { _pulse += Time.deltaTime; if (!(_pulse < Plugin.HealInterval.Value)) { _pulse = 0f; HealTouching(); SyncBattery(); } } } private void TrySipMedkits(bool following) { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (InShopHub() || !MedvacNet.IsMaster() || tankHp >= tankMax || tankMax - tankHp <= 0) { return; } _sipTimer += Time.deltaTime; if (_sipTimer < 0.45f) { return; } float num = (following ? (Plugin.TouchRange.Value + 0.7f) : 1.05f); ItemHealthPack val = null; int num2 = int.MaxValue; float num3 = num; ItemHealthPack[] array = Object.FindObjectsOfType(); foreach (ItemHealthPack val2 in array) { if ((Object)(object)val2 == (Object)null || val2.used || IsUnsoldShopPack(val2)) { continue; } int num4 = PackHeal(val2); if (num4 <= 0 || !MedkitTable.CanSip(tankHp, tankMax, num4)) { continue; } PhysGrabObject component = ((Component)val2).GetComponent(); if (!((Object)(object)component != (Object)null) || !component.grabbed) { float num5 = Vector3.Distance(((Component)val2).transform.position, ((Component)this).transform.position); if (!(num5 > num) && (num4 < num2 || (num4 == num2 && num5 < num3))) { num2 = num4; num3 = num5; val = val2; } } } if (!((Object)(object)val == (Object)null)) { _sipTimer = 0f; int packHp = PackHeal(val); int amount = MedkitTable.Give(tankHp, tankMax, packHp); Refill(amount); val.used = true; Plugin.Log.LogInfo((object)("MEDVAC tank +" + amount + " from " + packHp + " HP pack. now " + tankHp + "/" + tankMax)); ConsumePack(val); MedvacNet.BroadcastTank(this); } } private static int PackHeal(ItemHealthPack pack) { if ((Object)(object)pack == (Object)null) { return 0; } if (pack.healAmount > 0) { return pack.healAmount; } ItemAttributes val = ((Component)pack).GetComponent() ?? ((Component)pack).GetComponentInChildren(); string text = ((((Object)(object)val != (Object)null) ? val.itemName : null) ?? ((Object)pack).name ?? "").ToUpperInvariant(); if (text.Contains("100")) { return 100; } if (text.Contains("50")) { return 50; } if (text.Contains("25")) { return 25; } return 0; } private static bool InShopHub() { try { return SemiFunc.RunIsShop(); } catch { return false; } } private static bool IsUnsoldShopPack(ItemHealthPack pack) { try { if (!SemiFunc.RunIsShop()) { return false; } } catch { return false; } return (Object)(object)((Component)pack).GetComponentInParent() != (Object)null; } private static void ConsumePack(ItemHealthPack pack) { if ((Object)(object)pack == (Object)null) { return; } try { ParticleSystem[] particles = pack.particles; foreach (ParticleSystem val in particles) { if ((Object)(object)val != (Object)null) { val.Play(); } } } catch { } MeshRenderer mesh = pack.mesh; if ((Object)(object)mesh != (Object)null) { ((Renderer)mesh).enabled = false; } Collider[] componentsInChildren = ((Component)pack).GetComponentsInChildren(true); foreach (Collider val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null) { val2.enabled = false; } } if ((Object)(object)((Component)pack).GetComponent() != (Object)null && PhotonNetwork.IsMasterClient) { PhotonNetwork.Destroy(((Component)pack).gameObject); } else { Object.Destroy((Object)(object)((Component)pack).gameObject, 0.15f); } } internal void ApplyIdentity() { if ((Object)(object)_attrs == (Object)null) { _attrs = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(); } if ((Object)(object)_attrs == (Object)null) { return; } if ((Object)(object)boundItem == (Object)null && (Object)(object)_attrs.item != (Object)null && Plugin.IsMedvacItem(_attrs.item)) { boundItem = _attrs.item; } if ((Object)(object)boundItem == (Object)null) { return; } ItemAttributes[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (ItemAttributes val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { val.item = boundItem; val.itemName = boundItem.itemName; } } ((Object)((Component)this).gameObject).name = ((Object)boundItem).name; if ((Object)(object)_drone == (Object)null) { _drone = ((Component)this).GetComponent(); } if ((Object)(object)_drone != (Object)null) { _drone.targetPlayers = false; _drone.magnetActive = false; _drone.droneIcon = (Texture)(object)MedvacIcon.Texture; } string text = ItemNamePatch.Label(this); _attrs.item = boundItem; _attrs.itemName = text; _attrs.promptName = text; _attrs.icon = MedvacIcon.Sprite; _attrs.hasIcon = true; } private void RelabelUi() { if ((Object)(object)boundItem == (Object)null) { return; } string itemName = boundItem.itemName; Component[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } string name = ((object)val).GetType().Name; if (name.IndexOf("TextMeshPro", StringComparison.OrdinalIgnoreCase) < 0 && name != "TMP_Text") { continue; } PropertyInfo propertyInfo = AccessTools.Property(((object)val).GetType(), "text"); if (propertyInfo == null) { continue; } string text = propertyInfo.GetValue(val) as string; if (!string.IsNullOrEmpty(text) && text.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) < 0 && (text.IndexOf("DRONE", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("MODE", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("RECHARGE", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("ZERO", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("FEATHER", StringComparison.OrdinalIgnoreCase) >= 0)) { if (text.IndexOf("MODE", StringComparison.OrdinalIgnoreCase) >= 0) { propertyInfo.SetValue(val, "HEAL ON TOUCH"); } else { propertyInfo.SetValue(val, (text.IndexOf("[E]", StringComparison.OrdinalIgnoreCase) >= 0) ? (itemName + " [E]") : itemName); } } } } private void FixedUpdate() { //IL_0131: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: 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_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) if (!MedvacNet.IsMaster()) { return; } PhysGrabObject component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { component.grabDisableTimer = 0f; if (component.grabbed) { _idleSet = false; return; } } ItemDrone component2 = ((Component)this).GetComponent(); ItemToggle component3 = ((Component)this).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.disabled = false; } bool flag = IsActivated(); if ((Object)(object)component2 != (Object)null) { component2.itemActivated = flag; } if (!flag) { return; } Rigidbody val = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(); if ((Object)(object)val == (Object)null) { return; } if (val.isKinematic) { val.isKinematic = false; } val.useGravity = false; PlayerAvatar val2 = null; List list = SemiFunc.PlayerGetAll(); if (list != null) { float num = 50f; foreach (PlayerAvatar item in list) { if (!((Object)(object)item == (Object)null) && !item.deadSet) { float num2 = Vector3.Distance(val.position, ((Component)item).transform.position); if (num2 < num) { num = num2; val2 = item; } } } } if ((Object)(object)val2 == (Object)null) { return; } Vector3 val3 = ((Component)val2).transform.position + ((Component)val2).transform.right * 0.85f + ((Component)val2).transform.forward * 0.35f + Vector3.up * 1.05f; float num3 = val3.y - 2f; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val.position + Vector3.up * 0.2f, Vector3.down, ref val4, 8f, -5, (QueryTriggerInteraction)1) && ((Object)(object)((RaycastHit)(ref val4)).transform == (Object)null || !((RaycastHit)(ref val4)).transform.IsChildOf(((Component)this).transform))) { num3 = ((RaycastHit)(ref val4)).point.y; } float num4 = num3 + 6f; RaycastHit val5 = default(RaycastHit); if (Physics.Raycast(val.position, Vector3.up, ref val5, 6f, -5, (QueryTriggerInteraction)1) && ((Object)(object)((RaycastHit)(ref val5)).transform == (Object)null || !((RaycastHit)(ref val5)).transform.IsChildOf(((Component)this).transform))) { num4 = ((RaycastHit)(ref val5)).point.y; } val3.y = Mathf.Clamp(((Component)val2).transform.position.y + 1.15f, num3 + 0.9f, num4 - 0.5f); Vector3 val6 = Vector3.ClampMagnitude((val3 - val.position) * 2.6f, 2.2f); val.velocity = Vector3.Lerp(val.velocity, val6, 0.28f); val.angularVelocity = Vector3.Lerp(val.angularVelocity, Vector3.zero, 0.35f); Vector3 val7 = ((Component)val2).transform.position - val.position; val7.y = 0f; if (((Vector3)(ref val7)).sqrMagnitude > 0.05f) { val.MoveRotation(Quaternion.Slerp(val.rotation, Quaternion.LookRotation(((Vector3)(ref val7)).normalized, Vector3.up), 0.1f)); } float num5 = Vector3.Distance(val.position, ((Component)val2).transform.position); Vector3 val8 = val3 - val.position; float num6 = ((((Vector3)(ref val8)).sqrMagnitude > 0.01f) ? Vector3.Dot(val.velocity, ((Vector3)(ref val8)).normalized) : 1f); bool flag2 = false; RaycastHit val9 = default(RaycastHit); if (((Vector3)(ref val8)).sqrMagnitude > 0.04f && Physics.SphereCast(val.position, 0.14f, ((Vector3)(ref val8)).normalized, ref val9, 0.7f, -5, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val9)).transform != (Object)null && !((RaycastHit)(ref val9)).transform.IsChildOf(((Component)this).transform) && (Object)(object)((Component)((RaycastHit)(ref val9)).transform).GetComponentInParent() == (Object)null) { flag2 = true; } bool flag3 = num5 > 2.6f; bool flag4 = num6 < 0.2f && num5 >= _lastPlayerDist - 0.05f; _lastPlayerDist = num5; if (num5 > 6f) { UnstuckNearPlayer(val, val2); } else if (flag3 && (flag2 || flag4)) { _stuckT += Time.fixedDeltaTime; if (_stuckT > 0.55f) { UnstuckNearPlayer(val, val2); } } else { _stuckT = Mathf.Max(0f, _stuckT - Time.fixedDeltaTime * 2f); } } private bool Occupied(Vector3 pos, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Collider[] array = Physics.OverlapSphere(pos, radius, -5, (QueryTriggerInteraction)1); foreach (Collider val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).transform == (Object)(object)((Component)this).transform) && !((Component)val).transform.IsChildOf(((Component)this).transform) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !val.isTrigger) { return true; } } return false; } private void UnstuckNearPlayer(Rigidbody rb, PlayerAvatar player) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004e: 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_0062: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009d: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0132: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0157: 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_0168: 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_016f: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_01ed: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0224: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_01a7: 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_01b6: 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) _stuckT = 0f; Vector3 position = ((Component)player).transform.position; Vector3[] array = (Vector3[])(object)new Vector3[6] { ((Component)player).transform.right * 1.1f + Vector3.up * 1.2f + ((Component)player).transform.forward * 0.45f, -((Component)player).transform.right * 1.1f + Vector3.up * 1.2f + ((Component)player).transform.forward * 0.45f, ((Component)player).transform.forward * 1.15f + Vector3.up * 1.25f, -((Component)player).transform.forward * 1f + Vector3.up * 1.3f, ((Component)player).transform.right * 0.7f + Vector3.up * 1.7f, Vector3.up * 1.5f }; foreach (Vector3 val in array) { Vector3 val2 = position + val; if (!Occupied(val2, 0.32f)) { rb.position = val2; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; _idlePos = val2; _idleSet = true; _lastStuckPos = val2; return; } } Vector3 val3 = (rb.position = position + ((Component)player).transform.right * 0.9f + Vector3.up * 1.4f); rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; _idlePos = val3; _idleSet = true; _lastStuckPos = val3; } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { stream.SendNext((object)tankHp); stream.SendNext((object)tankMax); } else { tankHp = (int)stream.ReceiveNext(); tankMax = (int)stream.ReceiveNext(); } } private void ObservePhoton() { PhotonView val = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(); if ((Object)(object)val == (Object)null) { return; } try { if (val.ObservedComponents != null && !val.ObservedComponents.Contains((Component)(object)this)) { val.ObservedComponents.Add((Component)(object)this); } } catch { } } private void StripForever() { ShopRegistry.StripForeignDroneLogic(((Component)this).gameObject); } private void HealTouching() { if (InShopHub()) { return; } List list = SemiFunc.PlayerGetAll(); if (list == null) { return; } foreach (PlayerAvatar item in list) { if ((Object)(object)item == (Object)null || item.deadSet || (Object)(object)item.playerHealth == (Object)null || !HandTouches(item)) { continue; } PlayerHealth playerHealth = item.playerHealth; if (playerHealth.health >= playerHealth.maxHealth) { continue; } int num = Mathf.Min(new int[3] { Plugin.HealAmount.Value, playerHealth.maxHealth - playerHealth.health, tankHp }); if (num > 0) { playerHealth.Heal(num, true); tankHp = Mathf.Max(0, tankHp - num); SyncBattery(); MedvacNet.BroadcastTank(this); (((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren())?.RefreshPips(); if (tankHp <= 0) { break; } } } } private bool HandTouches(PlayerAvatar player) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) PhysGrabber[] array = ((Component)player).GetComponentsInChildren(true); if ((array == null || array.Length == 0) && (Object)(object)PhysGrabber.instance != (Object)null) { array = (PhysGrabber[])(object)new PhysGrabber[1] { PhysGrabber.instance }; } if (array == null) { return false; } PhysGrabObject component = ((Component)this).GetComponent(); Rigidbody val = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(); PhysGrabber[] array2 = array; foreach (PhysGrabber val2 in array2) { if ((Object)(object)val2 == (Object)null || ((Object)(object)val2.playerAvatar != (Object)null && (Object)(object)val2.playerAvatar != (Object)(object)player)) { continue; } if (val2.grabbed) { if ((Object)(object)component != (Object)null && (Object)(object)val2.grabbedPhysGrabObject == (Object)(object)component) { return true; } if ((Object)(object)val2.grabbedObject != (Object)null && ((Object)(object)val2.grabbedObject == (Object)(object)val || (Object)(object)((Component)val2.grabbedObject).transform == (Object)(object)((Component)this).transform || ((Component)val2.grabbedObject).transform.IsChildOf(((Component)this).transform))) { return true; } } if (Vector3.Distance(((Object)(object)val2.physGrabPoint != (Object)null) ? val2.physGrabPoint.position : val2.physGrabPointPosition, ((Component)this).transform.position) <= 0.42f) { return true; } } return false; } public void Refill(int amount) { tankHp = Mathf.Min(tankMax, tankHp + amount); (((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren())?.RefreshPips(); } private bool IsActivated() { if ((Object)(object)_toggle == (Object)null) { _toggle = ((Component)this).GetComponent(); } if ((Object)(object)_drone == (Object)null) { _drone = ((Component)this).GetComponent(); } if ((Object)(object)_toggle != (Object)null) { _toggle.disabled = false; return _toggle.toggleState; } if ((Object)(object)_drone != (Object)null) { return _drone.itemActivated; } return false; } private void TickHudLinger() { bool flag = false; PhysGrabber instance = PhysGrabber.instance; PhysGrabObject val = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInParent(); if ((Object)(object)instance != (Object)null && instance.grabbed && (Object)(object)val != (Object)null && (Object)(object)instance.grabbedPhysGrabObject == (Object)(object)val) { flag = true; } ItemAttributes val2 = _attrs ?? ((Component)this).GetComponent(); if ((Object)(object)val2 != (Object)null && val2.showInfoTimer > 0f) { flag = true; } if (flag) { _hudLinger = 0.4f; } else { _hudLinger = Mathf.Max(0f, _hudLinger - Time.unscaledDeltaTime); } } private bool IsTankPromptVisible() { return _hudLinger > 0f; } private void OnGUI() { //IL_00d5: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) if (IsTankPromptVisible()) { int num = 10; int num2 = Mathf.Clamp(Mathf.RoundToInt(Fill01 * (float)num), 0, num); float num3 = Mathf.Max(8f, (float)Screen.height * 0.011f); float num4 = Mathf.Max(14f, (float)Screen.height * 0.018f); float num5 = Mathf.Max(2f, (float)Screen.height * 0.003f); float num6 = (float)num * num3 + (float)(num - 1) * num5; float num7 = (float)Screen.width * 0.5f - num6 * 0.5f; float num8 = (float)Screen.height * 0.768f; Rect val = default(Rect); ((Rect)(ref val))..ctor(num7 - 6f, num8 - 5f, num6 + 12f, num4 + 10f); GUI.color = new Color(0.08f, 0.09f, 0.1f, 0.92f); GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(0.35f, 1f, 0.55f, 0.55f); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - 1f, ((Rect)(ref val)).width, 1f), (Texture)(object)Texture2D.whiteTexture); for (int i = 0; i < num; i++) { GUI.color = ((i < num2) ? new Color(0.4f, 1f, 0.58f, 1f) : new Color(0.16f, 0.18f, 0.16f, 0.95f)); GUI.DrawTexture(new Rect(num7 + (float)i * (num3 + num5), num8, num3, num4), (Texture)(object)Texture2D.whiteTexture); } GUI.color = Color.white; } } private void HideVanillaCharge() { _battery = _battery ?? ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(true); if (!((Object)(object)_battery == (Object)null)) { _battery.suppressBatteryUI = true; _battery.hasBatteryVisuals = false; _battery.showBattery = false; _battery.batteryActive = false; _battery.isUnchargable = true; _battery.batteryBars = 0; _battery.onlyShowWhenItemToggleIsOn = false; if ((Object)(object)_battery.batteryTransform != (Object)null) { ((Component)_battery.batteryTransform).gameObject.SetActive(false); } ItemDroneBattery component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } } } internal void SyncBattery() { HideVanillaCharge(); (((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren())?.RefreshPips(); } } [BepInPlugin("MEDVAC.HealerDrone", "MEDVAC Healer Drone", "1.8.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "MEDVAC.HealerDrone"; public const string PluginName = "MEDVAC Healer Drone"; public const string PluginVersion = "1.8.4"; internal static Plugin Instance; internal static ManualLogSource Log; internal static readonly Tier[] Tiers = new Tier[4] { new Tier("MV-50", 50, 25000f, 50000f, 38000), new Tier("MV-100", 100, 50000f, 100000f, 82000), new Tier("MV-150", 150, 100000f, 150000f, 128000), new Tier("MV-200", 200, 150000f, 200000f, 185000) }; internal static ConfigEntry TouchRange; internal static ConfigEntry HealInterval; internal static ConfigEntry HealAmount; internal static ConfigEntry MedkitRestore; internal static ConfigEntry InjectShop; private Harmony _harmony; internal Harmony Harmony => _harmony; private void Awake() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; TouchRange = ((BaseUnityPlugin)this).Config.Bind("Heal", "TouchRange", 0.85f, "Hull contact range (meters). Heal only on touch."); HealInterval = ((BaseUnityPlugin)this).Config.Bind("Heal", "HealInterval", 0.45f, "Seconds between contact heals."); HealAmount = ((BaseUnityPlugin)this).Config.Bind("Heal", "HealAmount", 5, "HP given per tick on contact."); MedkitRestore = ((BaseUnityPlugin)this).Config.Bind("Tank", "MedkitRestore", 50, "Battery HP restored when a health pack is used near the drone."); InjectShop = ((BaseUnityPlugin)this).Config.Bind("Shop", "InjectTiers", true, "Put MV-50/100/150/200 in the shop."); _harmony = new Harmony("MEDVAC.HealerDrone"); Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { try { _harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Log.LogWarning((object)("Skipped patch " + type.Name + ": " + ex.Message)); } } RamSpawnPatch.TryApply(_harmony); MedvacNet.Hook(); Log.LogInfo((object)"MEDVAC Healer Drone 1.8.4 loaded."); MedkitTable.LogOnce(); } private void Start() { ((MonoBehaviour)this).StartCoroutine(RetryRegister()); } private IEnumerator RetryRegister() { for (int i = 0; i < 40; i++) { yield return (object)new WaitForSeconds(0.5f); RamSpawnPatch.TryApply(Harmony); ShopRegistry.PatchNoItemSpawnLimit(Harmony); Compat.PatchAll(Harmony); MedvacNet.Hook(); if ((Object)(object)StatsManager.instance != (Object)null) { ShopRegistry.TryInject(StatsManager.instance); ShopRegistry.ClampShopCaps(); ShopRegistry.RefreshRamCache(); } } } internal static bool IsMedvacItem(Item item) { if ((Object)(object)item == (Object)null) { return false; } string text = item.itemName ?? ""; string text2 = ((Object)item).name ?? ""; if (text.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) < 0 && text2.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("MV-50", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("MV-100", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("MV-150", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("MV-200", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } internal static Tier GetTier(Item item) { if ((Object)(object)item == (Object)null) { return Tiers[0]; } string text = (item.itemName + " " + ((Object)item).name).ToUpperInvariant(); Tier[] tiers = Tiers; foreach (Tier tier in tiers) { if (text.IndexOf(tier.Name, StringComparison.OrdinalIgnoreCase) >= 0) { return tier; } } return Tiers[0]; } } public sealed class Tier { public readonly string Name; public readonly int TankHp; public readonly float PriceMin; public readonly float PriceMax; public readonly int PriceMid; public string ItemName => "MEDVAC " + Name; public Tier(string name, int tankHp, float priceMin, float priceMax, int priceMid) { Name = name; TankHp = tankHp; PriceMin = priceMin; PriceMax = priceMax; PriceMid = priceMid; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "MEDVAC.HealerDrone"; public const string PLUGIN_NAME = "MEDVAC Healer Drone"; public const string PLUGIN_VERSION = "1.0.0"; } }