Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RepoLiveCargo v0.1.0
BepInEx/plugins/RepoLiveCargo/RepoLiveCargo.dll
Decompiled 5 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("RepoLiveCargo")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("RepoLiveCargo")] [assembly: AssemblyTitle("RepoLiveCargo")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 Matsu.RepoLiveCargo { public static class CargoAssets { public static readonly Dictionary<CargoEquipment, Item> Registered = new Dictionary<CargoEquipment, Item>(); private static Transform? holder; public static bool Ready => Registered.Count == 4; public static string RegistrationStatus { get; private set; } = "Not attempted"; public static bool TryRegister() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown if (Ready) { return true; } Item val = ((IEnumerable<Item>)Items.AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => (Object)(object)item != (Object)null && (Object)(object)((PrefabRef<GameObject>)(object)item.prefab)?.Prefab != (Object)null && (((Object)item).name == "Item Leaf Blower" || ((Object)item).name.IndexOf("flashlight", StringComparison.OrdinalIgnoreCase) >= 0) && (Object)(object)((PrefabRef<GameObject>)(object)item.prefab).Prefab.GetComponent<ItemAttributes>() != (Object)null && (Object)(object)((PrefabRef<GameObject>)(object)item.prefab).Prefab.GetComponent<ItemEquippable>() != (Object)null && (Object)(object)((PrefabRef<GameObject>)(object)item.prefab).Prefab.GetComponent<ItemBattery>() != (Object)null)); if ((Object)(object)val == (Object)null) { RegistrationStatus = "Supported native rechargeable template not found; item count=" + Items.AllItems.Count; return false; } if (!CargoVisuals.InitializeMaterial()) { RegistrationStatus = "No supported opaque material; source=" + ((Object)val).name; return false; } RegistrationStatus = "Registering from " + ((Object)val).name; if ((Object)(object)holder == (Object)null) { GameObject val2 = new GameObject("LiveCargo inactive prefab templates"); val2.SetActive(false); Object.DontDestroyOnLoad((Object)val2); holder = val2.transform; } foreach (CargoEquipment value in Enum.GetValues(typeof(CargoEquipment))) { if (!Registered.ContainsKey(value)) { Register(val, value); } } RegistrationStatus = "Ready: " + Registered.Count + " equipment types"; return Ready; } private static void Register(Item source, CargoEquipment kind) { //IL_0089: 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_00cf: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)source.prefab).Prefab, holder, false); ((Object)val).name = "Item LiveCargo " + kind; val.SetActive(true); Item val2 = Object.Instantiate<Item>(source); ((Object)val2).name = ((Object)val).name; val2.itemName = DisplayName(kind); val2.itemNameLocalized = null; val2.description = (CargoRules.IsCage(kind) ? "Physically carry sedated, netted live cargo. Cannot enter inventory, even empty. Use inside an active extractor to deliver." : ((kind == CargoEquipment.Tranquilizer) ? "Weaken ordinary enemy attacks for 12s. Repeated doses sedate supported cargo. Non-lethal; rechargeable." : "A physical net slows enemy movement without disabling attacks. Also required for capture. Rechargeable.")); val2.itemType = (itemType)13; val2.maxAmount = 24; val2.maxAmountInShop = 3; val2.itemVolume = (itemVolume)(kind switch { CargoEquipment.LightCage => 2, CargoEquipment.ReinforcedCage => 8, _ => 0, }); val2.minPlayerCount = 1; val2.maxPurchase = false; val2.disabled = false; val2.physicalItem = true; val2.itemSecretShopType = (itemSecretShopType)0; val2.value = Object.Instantiate<Value>(source.value); float valueMax = kind switch { CargoEquipment.LightCage => 2000, CargoEquipment.ReinforcedCage => 5500, _ => 3000, }; val2.value.valueMin = (val2.value.valueMax = valueMax); val.GetComponent<ItemAttributes>().item = val2; ItemVolume componentInChildren = val.GetComponentInChildren<ItemVolume>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.itemVolume = val2.itemVolume; ((Component)componentInChildren).transform.localPosition = Vector3.zero; } Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Light[] componentsInChildren2 = val.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } PhysGrabObjectCollider[] componentsInChildren3 = val.GetComponentsInChildren<PhysGrabObjectCollider>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Collider[] componentsInChildren4 = val.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } MonoBehaviour[] componentsInChildren5 = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val3 in componentsInChildren5) { if (val3 is ItemLeafBlower || val3 is HurtCollider || val3 is PhysGrabObjectGrabArea || ((object)val3).GetType().Name.IndexOf("flashlight", StringComparison.OrdinalIgnoreCase) >= 0) { ((Behaviour)val3).enabled = false; } } ParticleSystem[] componentsInChildren6 = val.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren6.Length; i++) { componentsInChildren6[i].Stop(true, (ParticleSystemStopBehavior)0); } ItemToggle component = val.GetComponent<ItemToggle>(); if ((Object)(object)component != (Object)null) { component.onToggle = new UnityEvent(); ((Behaviour)component).enabled = false; component.playSound = false; } ItemBattery component2 = val.GetComponent<ItemBattery>(); if ((Object)(object)component2 != (Object)null) { component2.autoDrain = false; component2.batteryActive = false; } Rigidbody component3 = val.GetComponent<Rigidbody>(); PhysGrabObject component4 = val.GetComponent<PhysGrabObject>(); component4.clientNonKinematic = false; component4.colliders.Clear(); Transform val4 = val.transform.Find("Force Grab Point"); if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(!CargoRules.IsCage(kind)); if (!CargoRules.IsCage(kind)) { val4.localPosition = new Vector3(0f, -0.14f, -0.06f); } } Color dark = default(Color); ((Color)(ref dark))..ctor(0.1f, 0.14f, 0.18f); Color metal = default(Color); ((Color)(ref metal))..ctor(0.45f, 0.54f, 0.58f); Color cyan = default(Color); ((Color)(ref cyan))..ctor(0.1f, 0.9f, 0.95f); if (CargoRules.IsCage(kind)) { CargoCage cargoCage = val.AddComponent<CargoCage>(); cargoCage.Kind = kind; cargoCage.Integrity = CargoRules.Integrity(kind); BuildCage(val.transform, cargoCage, dark, metal, cyan); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } ((Behaviour)val.GetComponent<ItemEquippable>()).enabled = false; component3.mass = (component4.massOriginal = CargoRules.CageMass(kind)); } else { val.AddComponent<CargoTool>().Kind = kind; BuildTool(val.transform, kind, dark, metal, cyan); component3.mass = (component4.massOriginal = 1.8f); } PrefabRef val5 = Items.RegisterItem(val.GetComponent<ItemAttributes>()); if (val5 == null) { throw new InvalidOperationException("Registration failed: " + kind); } val2.prefab = val5; Registered.Add(kind, val2); Plugin.Log.LogInfo((object)("Registered " + val2.itemName + " with native physics/inventory.")); } public static string DisplayName(CargoEquipment kind) { return kind switch { CargoEquipment.LightCage => "Live Cargo: Light Cage", CargoEquipment.ReinforcedCage => "Live Cargo: Reinforced Cage", CargoEquipment.Tranquilizer => "Live Cargo: Tranquilizer", _ => "Live Cargo: Net Launcher", }; } private static void BuildCage(Transform root, CargoCage cage, Color dark, Color metal, Color cyan) { //IL_0035: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_02af: 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_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_01ba: 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) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) float num = CargoRules.CageWidth(cage.Kind); float num2 = CargoRules.CageDepth(cage.Kind); float interiorHeight = cage.InteriorHeight; CargoVisuals.Part(root, "Reinforced floor", (PrimitiveType)3, new Vector3(0f, 0.08f, 0f), new Vector3(num, 0.16f, num2), dark, collide: true); CargoVisuals.Part(root, "Roof", (PrimitiveType)3, new Vector3(0f, interiorHeight, 0f), new Vector3(num, 0.1f, num2), metal, collide: true); for (int i = -1; i <= 1; i += 2) { for (int j = 0; j < 6; j++) { float num3 = Mathf.Lerp((0f - num) / 2f, num / 2f, (float)j / 5f); CargoVisuals.Part(root, "Front/back containment bar", (PrimitiveType)3, new Vector3(num3, interiorHeight / 2f, (float)i * num2 / 2f), new Vector3(0.045f, interiorHeight, 0.045f), metal, collide: true); float num4 = Mathf.Lerp((0f - num2) / 2f, num2 / 2f, (float)j / 5f); CargoVisuals.Part(root, "Side containment bar", (PrimitiveType)3, new Vector3((float)i * num / 2f, interiorHeight / 2f, num4), new Vector3(0.045f, interiorHeight, 0.045f), metal, collide: true); } CargoVisuals.Part(root, "Carry handle", (PrimitiveType)3, new Vector3((float)i * (num / 2f - 0.035f), interiorHeight * 0.68f, 0f), new Vector3(0.1f, 0.08f, 0.3f), cyan, collide: true); for (int k = 0; k < 5; k++) { CargoVisuals.Part(root, "Caution stripe", (PrimitiveType)3, new Vector3((float)(k - 2) * num / 5f, 0.175f, (float)i * (num2 / 2f - 0.06f)), new Vector3(num / 12f, 0.018f, 0.07f), new Color(1f, 0.7f, 0.07f), collide: false); } } cage.Lamp = CargoVisuals.Part(root, "Status beacon", (PrimitiveType)0, new Vector3(num * 0.38f, interiorHeight + 0.09f, 0f), Vector3.one * 0.14f, cyan, collide: false); GameObject val = new GameObject("Occupied cargo sedation receiver"); val.transform.SetParent(root, false); val.layer = LayerMask.NameToLayer("Enemy"); val.AddComponent<CargoSedationReceiver>(); cage.SedationReceiver = val.AddComponent<BoxCollider>(); ((Collider)cage.SedationReceiver).isTrigger = true; ((Collider)cage.SedationReceiver).enabled = false; cage.SedationReceiver.center = new Vector3(0f, interiorHeight * 0.5f, 0f); cage.SedationReceiver.size = cage.InteriorSize; Transform val2 = root.Find("Center of Mass"); if ((Object)(object)val2 != (Object)null) { val2.localPosition = new Vector3(0f, 0.23f, 0f); } } private static void BuildTool(Transform root, CargoEquipment kind, Color dark, Color metal, Color cyan) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) bool flag = kind == CargoEquipment.NetLauncher; CargoVisuals.Part(root, "Receiver hitbox", (PrimitiveType)3, Vector3.zero, new Vector3(flag ? 0.24f : 0.14f, 0.15f, 0.33f), dark, collide: true).enabled = false; CargoVisuals.Part(root, "Grip hitbox", (PrimitiveType)3, new Vector3(0f, -0.14f, -0.06f), new Vector3(0.1f, 0.23f, 0.12f), metal, collide: true).enabled = false; CargoModels.Build(root, kind); } } public enum CargoCue { Dart, Net, Secured, Wake, Impact, Breach, Escaped, Delivered } public static class CargoAudio { private static readonly Dictionary<CargoCue, Sound> sounds = new Dictionary<CargoCue, Sound>(); public static void Emit(CargoCue cue, Vector3 position) { //IL_0009: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (NativeAccess.Host) { Play(cue, position); CargoNetwork.Broadcast("cue", new CargoAudioState { Epoch = (CargoDirector.Instance?.Epoch ?? ""), Cue = cue, X = position.x, Y = position.y, Z = position.z }); } } public static AudioSource? Play(CargoCue cue, Vector3 position) { //IL_000d: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)AudioManager.instance == (Object)null || !NativeAccess.Finite(position) || !Enum.IsDefined(typeof(CargoCue), cue)) { return null; } if (!sounds.TryGetValue(cue, out Sound value)) { Sound val = new Sound(); val.Sounds = (AudioClip[])(object)new AudioClip[1] { CreateClip(cue) }; val.Type = (AudioType)3; val.Volume = ((cue == CargoCue.Wake || cue == CargoCue.Breach) ? 0.65f : 0.5f); val.VolumeRandom = 0f; val.Pitch = 1f; val.PitchRandom = 0f; val.SpatialBlend = 1f; val.Doppler = 0f; val.FalloffMultiplier = 1.3f; value = val; sounds.Add(cue, value); } return value.Play(position, 1f, 1f, 1f, 1f); } public static AudioClip CreateClip(CargoCue cue) { float num = cue switch { CargoCue.Delivered => 0.65f, CargoCue.Secured => 0.38f, CargoCue.Impact => 0.24f, CargoCue.Net => 0.22f, CargoCue.Dart => 0.1f, _ => 0.6f, }; float[] array = new float[(int)(22050f * num)]; Random random = new Random((int)(400 + cue)); for (int i = 0; i < array.Length; i++) { double time = (double)i / 22050.0; double num2 = time / (double)num; double num3 = Math.Min(1.0, time / 0.008) * Math.Min(1.0, ((double)num - time) / 0.025); double num5; switch (cue) { case CargoCue.Dart: case CargoCue.Net: num5 = (random.NextDouble() * 2.0 - 1.0) * Math.Exp((0.0 - num2) * 5.0) * 0.45 + Sine((cue == CargoCue.Net) ? 440 : 180) * 0.1; break; case CargoCue.Impact: num5 = (Sine(110.0) * 0.55 + Sine(367.0) * 0.25 + Sine(821.0) * 0.1) * Math.Exp((0.0 - num2) * 7.0); break; case CargoCue.Secured: case CargoCue.Delivered: { int num6 = (int)(num2 * (double)((cue == CargoCue.Delivered) ? 3 : 2)); double hz = num6 switch { 1 => 554.37, 0 => 440.0, _ => 659.25, }; double num7 = num2 * (double)((cue == CargoCue.Delivered) ? 3 : 2) - (double)num6; num5 = Sine(hz) * 0.5 * Math.Min(1.0, num7 * 20.0) * Math.Min(1.0, (1.0 - num7) * 8.0); break; } default: { double num4 = ((Math.Sin(Math.PI * 2.0 * time * (double)((cue == CargoCue.Wake) ? 4 : 7)) > -0.1) ? 1.0 : 0.1); num5 = (Sine(cue switch { CargoCue.Escaped => 180, CargoCue.Wake => 660, _ => 330, }) * 0.45 + Sine(993.0) * 0.1) * num4; break; } } array[i] = (float)(num5 * num3 * 0.8); double Sine(double num8) { return Math.Sin(Math.PI * 2.0 * time * num8); } } AudioClip obj = AudioClip.Create("LiveCargo " + cue, array.Length, 1, 22050, false); obj.SetData(array, 0); return obj; } } public sealed class CargoAudioState { public string Epoch = ""; public CargoCue Cue; public float X; public float Y; public float Z; } public sealed class CargoCage : CargoEquipmentBehaviour { public float Integrity; public Renderer? Lamp; public BoxCollider? SedationReceiver; private float collisionGate; private float nextIndicator; private bool wasAwake; public CargoCreature? Occupant { get; internal set; } public CargoRecord? Record { get; internal set; } public float MaxIntegrity => CargoRules.Integrity(Kind); public float InteriorHeight { get { if (Kind != CargoEquipment.LightCage) { return 1.6f; } return 1f; } } public Vector3 InteriorSize => new Vector3(CargoRules.CageWidth(Kind) - 0.12f, InteriorHeight - 0.2f, CargoRules.CageDepth(Kind) - 0.12f); public override string Prompt { get { CargoRecord? record = Record; if (record == null || record.Phase != CargoPhase.PaymentPending) { if (!(Integrity <= 0f)) { if (!((Object)(object)Occupant == (Object)null)) { return "USE: deliver inside an active extractor | tranquilizer keeps it calm"; } return "USE: load nearby SEDATED + NETTED creature"; } return "Containment breached: recover another cage"; } return "Payment awaiting confirmation: do not attempt another delivery"; } } protected override void Start() { base.Start(); if (Integrity <= 0f) { Integrity = MaxIntegrity; } SetMass(); } protected override void Update() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) base.Update(); if ((Object)(object)SedationReceiver != (Object)null) { BoxCollider? sedationReceiver = SedationReceiver; int enabled; if ((Object)(object)Occupant != (Object)null && Occupant.Alive) { CargoRecord? record = Record; enabled = ((record != null && record.Phase == CargoPhase.Contained) ? 1 : 0); } else { enabled = 0; } ((Collider)sedationReceiver).enabled = (byte)enabled != 0; } bool flag = Record?.Awake ?? false; if (flag && !wasAwake) { CargoAudio.Play(CargoCue.Wake, ((Component)this).transform.position); } wasAwake = flag; if (Time.time >= nextIndicator) { nextIndicator = Time.time + 0.15f; RefreshIndicators(); } if (!((Object)(object)Occupant == (Object)null) && NativeAccess.Host) { CargoRecord? record2 = Record; if (record2 != null && record2.Phase == CargoPhase.Contained && !Occupant.Alive) { CargoDirector.Instance?.QueueEscape(Occupant); } } } public void SetMass() { if (!((Object)(object)base.Physics == (Object)null) && !((Object)(object)base.Body == (Object)null)) { float num = CargoRules.CageMass(Kind) + (((Object)(object)Occupant != (Object)null) ? CargoRules.Mass(Occupant.Species) : 0f); base.Physics.massOriginal = num; base.Body.mass = num; } } public void Damage(float amount) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00c3: Unknown result type (might be due to invalid IL or missing references) if (!NativeAccess.Host) { return; } CargoRecord? record = Record; if ((record == null || record.Phase != CargoPhase.PaymentPending) && CargoRules.Finite(amount) && !(amount <= 0f) && !(Integrity <= 0f)) { Integrity = Mathf.Max(0f, Integrity - amount); if (Record != null) { Record.Stress = Mathf.Min(100f, Record.Stress + amount); } CargoVisuals.Pulse(((Component)this).transform.position + Vector3.up * 0.6f, Color.red, 0.5f); CargoAudio.Emit((Integrity <= 0f) ? CargoCue.Breach : CargoCue.Impact, ((Component)this).transform.position); if (Integrity <= 0f && (Object)(object)Occupant != (Object)null) { CargoDirector.Instance?.QueueEscape(Occupant); } } } private void OnCollisionEnter(Collision collision) { //IL_003b: 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_00b8: 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_00c0: Unknown result type (might be due to invalid IL or missing references) if (!NativeAccess.Host || (Object)(object)Occupant == (Object)null) { return; } CargoRecord? record = Record; if ((record != null && record.Phase == CargoPhase.PaymentPending) || Time.time < collisionGate) { return; } Vector3 relativeVelocity = collision.relativeVelocity; float magnitude = ((Vector3)(ref relativeVelocity)).magnitude; if (!(magnitude < 3.2f)) { collisionGate = Time.time + 0.8f; Damage(Mathf.Clamp((magnitude - 3f) * 5f, 0f, 35f)); if (magnitude >= 6f && Occupant.Alive) { EnemyHealth health = Occupant.Health; int num = Mathf.CeilToInt((magnitude - 5f) * 3f); relativeVelocity = collision.relativeVelocity; health.Hurt(num, ((Vector3)(ref relativeVelocity)).normalized); } } } private void RefreshIndicators() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00fd: 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_010f: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) CargoRecord? record = Record; bool flag = (record != null && record.Awake) || Integrity <= MaxIntegrity * 0.3f; Color val = (Color)((Integrity <= 0f || ((Object)(object)Occupant != (Object)null && !Occupant.Alive)) ? Color.red : (flag ? new Color(1f, 0.35f, 0.1f) : (((Object)(object)Occupant == (Object)null) ? new Color(0.3f, 0.9f, 1f) : new Color(0.25f, 1f, 0.65f)))); float num = (flag ? (0.35f + 0.65f * (0.5f + 0.5f * Mathf.Sin(Time.time * 9f))) : 1f); if ((Object)(object)Lamp != (Object)null) { MaterialPropertyBlock val2 = new MaterialPropertyBlock(); val2.SetColor("_Color", val * num); val2.SetColor("_BaseColor", val * num); val2.SetColor("_EmissionColor", val * (3f * num)); Lamp.SetPropertyBlock(val2); } } protected override void OnDestroy() { CargoDirector.Instance?.CageRemoved(this); base.OnDestroy(); } } public sealed class CargoSedationReceiver : MonoBehaviour { } public sealed class CargoCombatUtility { private sealed class Effect { public EnemyParent Parent; public Enemy Enemy; public NavMeshAgent? Agent; public EnemyHealth Health; public CargoCreature? Cargo; public GameObject? Drops; public Transform[] Beads = Array.Empty<Transform>(); public CargoNavigationLease Navigation = new CargoNavigationLease(); public float NextEligibility; public void RestoreNavigation() { if (Navigation.Scaled && !((Object)(object)Agent == (Object)null)) { float speed = Agent.speed; float acceleration = Agent.acceleration; Navigation.Restore(ref speed, ref acceleration); Agent.speed = speed; Agent.acceleration = acceleration; } } public void Dispose() { RestoreNavigation(); if ((Object)(object)Drops != (Object)null) { Object.Destroy((Object)(object)Drops); } } } private readonly Dictionary<int, Effect> effects = new Dictionary<int, Effect>(); private readonly List<CargoCombatState> frameStates = new List<CargoCombatState>(); private readonly List<int> removed = new List<int>(); public CargoCombatLedger Ledger { get; } = new CargoCombatLedger(); public static EnemyParent? Resolve(Enemy? enemy) { if (!((Object)(object)enemy != (Object)null)) { return null; } return NativeAccess.EnemyOwner.Invoke(enemy); } public static EnemyParent? Resolve(Collider? collider) { if ((Object)(object)collider == (Object)null) { return null; } EnemyRigidbody componentInParent = ((Component)collider).GetComponentInParent<EnemyRigidbody>(); if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.enemy != (Object)null)) { return ((Component)collider).GetComponentInParent<EnemyParent>(); } return Resolve(componentInParent.enemy); } public static bool Eligible(EnemyParent? parent) { if ((Object)(object)parent == (Object)null || (Object)(object)parent.EnableObject == (Object)null || !parent.EnableObject.activeInHierarchy || !NativeAccess.Spawned.Invoke(parent) || !CargoRegistry.NativeOrdinary(parent)) { return false; } CargoCreature component = ((Component)parent).GetComponent<CargoCreature>(); if ((Object)(object)component != (Object)null && (component.Suspended || component.Retired)) { return false; } EnemyHealth componentInChildren = ((Component)parent).GetComponentInChildren<EnemyHealth>(true); if ((Object)(object)componentInChildren != (Object)null && NativeAccess.CurrentHealth.Invoke(componentInChildren) > 0) { return !NativeAccess.DeadEnemy.Invoke(componentInChildren); } return false; } public bool Weaken(EnemyParent parent) { if (NativeAccess.Host && Eligible(parent)) { return Ledger.Weaken(NativeAccess.Id((Component)(object)parent)); } return false; } public bool Snare(EnemyParent parent, float seconds) { if (NativeAccess.Host && Eligible(parent)) { return Ledger.Snare(NativeAccess.Id((Component)(object)parent), seconds); } return false; } public bool Weak(EnemyParent? parent) { if ((Object)(object)parent != (Object)null && (Object)(object)CargoDirector.Instance != (Object)null && !CargoDirector.Instance.Transitioning) { CargoCombatState? cargoCombatState = Ledger.Find(NativeAccess.Id((Component)(object)parent)); if (cargoCombatState != null && cargoCombatState.WeakLeft > 0f) { return Eligible(parent); } } return false; } public void Clear() { Ledger.Clear(); foreach (Effect value in effects.Values) { value.Dispose(); } effects.Clear(); } public void LateUpdate(float seconds) { //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Expected O, but got Unknown //IL_041a: Unknown result type (might be due to invalid IL or missing references) if (!NativeAccess.Host) { Ledger.Advance(seconds); } frameStates.Clear(); frameStates.AddRange(Ledger.States); foreach (CargoCombatState frameState in frameStates) { if (!CargoRegistry.Enemies.TryGetValue(frameState.EnemyId, out EnemyParent value) || (Object)(object)value == (Object)null) { continue; } if (effects.TryGetValue(frameState.EnemyId, out Effect value2) && (Object)(object)value2.Parent != (Object)(object)value) { value2.Dispose(); effects.Remove(frameState.EnemyId); } if (!effects.TryGetValue(frameState.EnemyId, out Effect e)) { if (!Eligible(value)) { Ledger.Remove(frameState.EnemyId); continue; } Enemy componentInChildren = ((Component)value).GetComponentInChildren<Enemy>(true); if ((Object)(object)componentInChildren == (Object)null) { Ledger.Remove(frameState.EnemyId); continue; } e = new Effect { Parent = value, Enemy = componentInChildren, Agent = ((Component)componentInChildren).GetComponent<NavMeshAgent>(), Health = ((Component)value).GetComponentInChildren<EnemyHealth>(true), Cargo = ((Component)value).GetComponent<CargoCreature>() }; effects.Add(frameState.EnemyId, e); } CargoCreature cargo = e.Cargo; if (Time.time >= e.NextEligibility) { e.NextEligibility = Time.time + 2f; if (!CargoRegistry.NativeOrdinary(value)) { Ledger.Remove(frameState.EnemyId); continue; } } if ((Object)(object)value.EnableObject == (Object)null || (Object)(object)e.Enemy == (Object)null || !value.EnableObject.activeInHierarchy || !NativeAccess.Spawned.Invoke(value) || (Object)(object)e.Health == (Object)null || NativeAccess.CurrentHealth.Invoke(e.Health) <= 0 || NativeAccess.DeadEnemy.Invoke(e.Health) || ((Object)(object)cargo != (Object)null && (cargo.Suspended || cargo.Retired))) { Ledger.Remove(frameState.EnemyId); continue; } if (NativeAccess.Host && frameState.SnareLeft > 0f && (Object)(object)e.Agent != (Object)null) { if (e.Navigation.Apply(e.Agent.speed, e.Agent.acceleration)) { e.Agent.speed = e.Navigation.AppliedSpeed; e.Agent.acceleration = e.Navigation.AppliedAcceleration; } value.SpawnedTimerPause(0.5f); } else { e.RestoreNavigation(); } if (frameState.WeakLeft > 0f) { if ((Object)(object)e.Drops == (Object)null) { e.Drops = new GameObject("LiveCargo medicine droplets"); e.Beads = (from n in Enumerable.Range(0, 4) select ((Component)CargoVisuals.Part(e.Drops.transform, "Medicine droplet", (PrimitiveType)0, Vector3.zero, new Vector3(0.065f, 0.12f, 0.065f), new Color(0.38f, 1f, 0.16f), collide: false)).transform).ToArray(); } e.Drops.transform.position = e.Enemy.CenterTransform.position; for (int num = 0; num < e.Beads.Length; num++) { float num2 = Time.time * 2f + (float)num * (float)Math.PI * 0.5f; e.Beads[num].localPosition = new Vector3(Mathf.Cos(num2) * 0.38f, Mathf.Sin(Time.time * 4f + (float)num) * 0.14f, Mathf.Sin(num2) * 0.38f); } } else if ((Object)(object)e.Drops != (Object)null) { Object.Destroy((Object)(object)e.Drops); e.Drops = null; } } removed.Clear(); foreach (KeyValuePair<int, Effect> effect in effects) { if (Ledger.Find(effect.Key) == null || (Object)(object)effect.Value.Parent == (Object)null) { removed.Add(effect.Key); } } foreach (int item in removed) { effects[item].Dispose(); effects.Remove(item); } } } [HarmonyPatch(typeof(HurtCollider), "PlayerHurt")] internal static class CargoWeakAttackPatch { internal struct Saved { public bool Applied; public int Damage; public int ImpactDamage; public float HitForce; public float TumbleForce; public float Torque; } private static void Prefix(HurtCollider __instance, out Saved __state) { __state = default(Saved); CargoCombatUtility cargoCombatUtility = CargoDirector.Instance?.Combat; EnemyParent parent = CargoCombatUtility.Resolve(__instance.enemyHost) ?? ((Component)__instance).GetComponentInParent<EnemyParent>(); if (cargoCombatUtility != null && cargoCombatUtility.Weak(parent) && !__instance.playerKill) { __state = new Saved { Applied = true, Damage = __instance.playerDamage, ImpactDamage = __instance.playerTumbleImpactHurtDamage, HitForce = __instance.playerHitForce, TumbleForce = __instance.playerTumbleForce, Torque = __instance.playerTumbleTorque }; __instance.playerDamage = CargoUtilityRules.WeakenDamage(__state.Damage); __instance.playerTumbleImpactHurtDamage = CargoUtilityRules.WeakenDamage(__state.ImpactDamage); __instance.playerHitForce = CargoUtilityRules.WeakenForce(__state.HitForce); __instance.playerTumbleForce = CargoUtilityRules.WeakenForce(__state.TumbleForce); __instance.playerTumbleTorque = CargoUtilityRules.WeakenForce(__state.Torque); } } private static Exception? Finalizer(HurtCollider __instance, Saved __state, Exception? __exception) { Restore(__instance, __state); return __exception; } private static void Restore(HurtCollider collider, Saved s) { if (s.Applied && !((Object)(object)collider == (Object)null)) { collider.playerDamage = s.Damage; collider.playerTumbleImpactHurtDamage = s.ImpactDamage; collider.playerHitForce = s.HitForce; collider.playerTumbleForce = s.TumbleForce; collider.playerTumbleTorque = s.Torque; } } } public sealed class CargoCreature : MonoBehaviour { private readonly List<(Behaviour component, bool enabled)> behaviours = new List<(Behaviour, bool)>(); private readonly List<(Collider component, bool enabled)> colliders = new List<(Collider, bool)>(); private readonly List<(Rigidbody component, bool kinematic, bool gravity, Vector3 localPosition, Quaternion localRotation)> bodies = new List<(Rigidbody, bool, bool, Vector3, Quaternion)>(); private Vector3 originalScale; private Vector3 modelOffset; private float scaleFactor = 1f; public EnemyParent Parent { get; private set; } public Enemy Enemy { get; private set; } public EnemyHealth Health { get; private set; } public CargoSpecies Species { get; private set; } public bool Suspended { get; private set; } public bool Retired { get; private set; } public CargoCage? Cage { get; private set; } public int Id => NativeAccess.Id((Component)(object)Parent); public int Hp { get { if (!((Object)(object)Health != (Object)null)) { return 0; } return NativeAccess.CurrentHealth.Invoke(Health); } } public bool Alive { get { if ((Object)(object)Health != (Object)null && Hp > 0) { return !NativeAccess.DeadEnemy.Invoke(Health); } return false; } } public bool Eligible { get { if ((Object)(object)Parent != (Object)null && (Object)(object)Parent.EnableObject != (Object)null && Parent.EnableObject.activeInHierarchy && NativeAccess.Spawned.Invoke(Parent) && Alive && !Retired) { return CargoRegistry.Ordinary(Parent); } return false; } } public void Initialize(EnemyParent parent, CargoSpecies species) { Parent = parent; Species = species; Enemy = ((Component)parent).GetComponentInChildren<Enemy>(true); Health = ((Component)parent).GetComponentInChildren<EnemyHealth>(true); } public bool Contain(CargoCage cage) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) if (Suspended) { Cage = cage; return !Retired; } if (!Eligible || !CargoRules.Fits(Species, cage.Kind)) { return false; } originalScale = ((Component)this).transform.localScale; Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(Enemy.CenterTransform.position, Vector3.one * 0.3f); bool flag = false; Renderer[] componentsInChildren = Parent.EnableObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (val.enabled && !(val is ParticleSystemRenderer)) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } modelOffset = ((Component)this).transform.InverseTransformPoint(((Bounds)(ref bounds)).center); Vector3 val2 = cage.InteriorSize * 0.9f; scaleFactor = Mathf.Min(1f, Mathf.Min(val2.x / Mathf.Max(0.1f, ((Bounds)(ref bounds)).size.x), Mathf.Min(val2.y / Mathf.Max(0.1f, ((Bounds)(ref bounds)).size.y), val2.z / Mathf.Max(0.1f, ((Bounds)(ref bounds)).size.z)))); Behaviour[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Behaviour>(true); foreach (Behaviour val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)(object)this) && !(val3 is Animator) && !(val3 is Light) && !(val3 is AudioSource) && (val3 is MonoBehaviour || val3 is NavMeshAgent)) { behaviours.Add((val3, val3.enabled)); val3.enabled = false; } } Collider[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<Collider>(true); foreach (Collider val4 in componentsInChildren3) { colliders.Add((val4, val4.enabled)); val4.enabled = false; } Rigidbody[] componentsInChildren4 = ((Component)this).GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val5 in componentsInChildren4) { bodies.Add((val5, val5.isKinematic, val5.useGravity, ((Component)val5).transform.localPosition, ((Component)val5).transform.localRotation)); if (!val5.isKinematic) { val5.velocity = Vector3.zero; val5.angularVelocity = Vector3.zero; } val5.useGravity = false; val5.isKinematic = true; } ((Component)this).transform.localScale = originalScale * scaleFactor; Suspended = true; Cage = cage; FollowCage(); return true; } private void LateUpdate() { if (Suspended && !Retired && (Object)(object)Cage != (Object)null) { FollowCage(); } } private void FollowCage() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references) //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_00ad: 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) if ((Object)(object)Cage == (Object)null) { return; } ((Component)this).transform.rotation = ((Component)Cage).transform.rotation; Vector3 val = ((Component)Cage).transform.TransformPoint(0f, Cage.InteriorHeight * 0.48f, 0f); ((Component)this).transform.position = val - ((Component)this).transform.TransformVector(modelOffset); foreach (var body in bodies) { if ((Object)(object)body.component != (Object)null) { body.component.position = ((Component)body.component).transform.position; body.component.rotation = ((Component)body.component).transform.rotation; } } } public void Release(Vector3 position, Quaternion rotation) { //IL_0018: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_01f0: Unknown result type (might be due to invalid IL or missing references) if (!Suspended || Retired) { return; } ((Component)this).transform.localScale = originalScale; ((Component)this).transform.SetPositionAndRotation(position, rotation); foreach (var body in bodies) { if (!((Object)(object)body.component == (Object)null)) { ((Component)body.component).transform.localPosition = body.localPosition; ((Component)body.component).transform.localRotation = body.localRotation; body.component.position = ((Component)body.component).transform.position; body.component.rotation = ((Component)body.component).transform.rotation; body.component.useGravity = body.gravity; body.component.isKinematic = body.kinematic; } } foreach (var collider in colliders) { if ((Object)(object)collider.component != (Object)null) { collider.component.enabled = collider.enabled; } } foreach (var behaviour in behaviours) { if ((Object)(object)behaviour.component != (Object)null) { behaviour.component.enabled = behaviour.enabled; } } behaviours.Clear(); colliders.Clear(); bodies.Clear(); Suspended = false; Cage = null; if ((Object)(object)Enemy != (Object)null) { Enemy.CurrentState = (EnemyState)2; if (NativeAccess.Host) { Enemy.EnemyTeleported(position); } if (NativeAccess.Host && Alive) { ((MonoBehaviour)this).StartCoroutine(ReleaseGrace(CargoDirector.Instance?.Epoch ?? "")); } } Parent.SpawnedTimerPause(8f); } private IEnumerator ReleaseGrace(string epoch) { float deadline = Time.time + 4f; while ((Object)(object)Enemy != (Object)null && NativeAccess.Teleported.Invoke(Enemy) > 0f && Time.time < deadline) { if (!NativeAccess.Host || !Alive || Suspended || Retired || CargoDirector.Instance?.Epoch != epoch) { yield break; } yield return null; } if (!((Object)(object)Enemy == (Object)null) && NativeAccess.Host && Alive && !Suspended && !Retired && !(CargoDirector.Instance?.Epoch != epoch)) { EnemyStateStunned component = ((Component)Enemy).GetComponent<EnemyStateStunned>(); if ((Object)(object)component != (Object)null) { component.Set(1.5f); } } } public void Retire() { Suspended = true; Retired = true; Cage = null; ((Behaviour)Parent).enabled = false; if ((Object)(object)Parent.EnableObject != (Object)null) { Parent.EnableObject.SetActive(false); } } private void OnDestroy() { if (!((Object)(object)Parent == (Object)null)) { int id = Id; if (CargoRegistry.Creatures.TryGetValue(id, out CargoCreature value) && (Object)(object)value == (Object)(object)this) { CargoRegistry.Creatures.Remove(id); } } } } public sealed class CargoDartProjectile : MonoBehaviour { public const float Speed = 50f; public const float Radius = 0.045f; public const float Range = 18f; private static readonly Dictionary<int, CargoDartProjectile> active = new Dictionary<int, CargoDartProjectile>(); private static readonly HashSet<int> terminal = new HashSet<int>(); private static readonly Queue<int> terminalOrder = new Queue<int>(); private static int serial; private CargoShot shot; private CargoTool? source; private PlayerAvatar? owner; private Action<RaycastHit>? impact; private bool authoritative; private float travelled; public static bool HasCapacity => active.Count < 64; public static CargoShot Launch(string epoch, Vector3 origin, Vector3 direction, CargoTool source, PlayerAvatar owner, Action<RaycastHit> impact) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_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) if (!NativeAccess.Host || !HasCapacity) { throw new InvalidOperationException("Dart authority/capacity unavailable"); } CargoShot cargoShot = CargoShot.Create(epoch, origin, origin + ((Vector3)(ref direction)).normalized * 18f, net: false); cargoShot.Id = ++serial; CargoDartProjectile cargoDartProjectile = Build(cargoShot); cargoDartProjectile.authoritative = true; cargoDartProjectile.source = source; cargoDartProjectile.owner = owner; cargoDartProjectile.impact = impact; return cargoShot; } private static CargoDartProjectile Build(CargoShot shot) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0043: 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_0059: 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_0081: 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_00bb: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("LiveCargo swept tranquilizer dart"); CargoDartProjectile cargoDartProjectile = val.AddComponent<CargoDartProjectile>(); cargoDartProjectile.shot = shot; val.transform.position = shot.Origin; Transform transform = val.transform; Vector3 val2 = shot.End - shot.Origin; transform.forward = ((Vector3)(ref val2)).normalized; CargoVisuals.Part(val.transform, "Dart shaft", (PrimitiveType)3, Vector3.zero, new Vector3(0.025f, 0.025f, 0.19f), new Color(0.6f, 0.7f, 0.73f), collide: false); CargoVisuals.Part(val.transform, "Medicine capsule", (PrimitiveType)3, new Vector3(0f, 0f, -0.09f), new Vector3(0.05f, 0.05f, 0.09f), new Color(0.35f, 1f, 0.12f), collide: false); active.Add(shot.Id, cargoDartProjectile); CargoAudio.Play(CargoCue.Dart, shot.Origin); return cargoDartProjectile; } private void FixedUpdate() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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) if ((Object)(object)CargoDirector.Instance == (Object)null || CargoDirector.Instance.Transitioning || CargoDirector.Instance.Epoch != shot.Epoch) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Vector3 val = shot.End - shot.Origin; Vector3 normalized = ((Vector3)(ref val)).normalized; float num = Mathf.Min(50f * Time.fixedDeltaTime, Vector3.Distance(shot.Origin, shot.End) - travelled); if (authoritative) { if (!NativeAccess.Host) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } RaycastHit[] array = Physics.SphereCastAll(((Component)this).transform.position, 0.045f, normalized, num, LayerMask.op_Implicit(SemiFunc.LayerMaskGetShouldHits()) | LayerMask.GetMask(new string[1] { "Enemy" }), (QueryTriggerInteraction)2); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num2 = 0; num2 < array2.Length; num2++) { RaycastHit obj = array2[num2]; if (!Ignored(((RaycastHit)(ref obj)).collider)) { impact?.Invoke(obj); impact = null; CargoDartImpact cargoDartImpact = new CargoDartImpact { Epoch = shot.Epoch, Id = shot.Id, Ox = shot.Ox, Oy = shot.Oy, Oz = shot.Oz, X = ((RaycastHit)(ref obj)).point.x, Y = ((RaycastHit)(ref obj)).point.y, Z = ((RaycastHit)(ref obj)).point.z }; CargoNativeBulletVisual.Play(cargoDartImpact); CargoNetwork.Broadcast("impact", cargoDartImpact); Object.Destroy((Object)(object)((Component)this).gameObject); return; } } } travelled += num; Transform transform = ((Component)this).transform; transform.position += normalized * num; if (travelled >= Vector3.Distance(shot.Origin, shot.End) - 0.001f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private bool Ignored(Collider collider) { if ((Object)(object)collider == (Object)null || (Object)(object)((Component)collider).GetComponentInParent<CargoNetContact>() != (Object)null) { return true; } if (collider.isTrigger && (Object)(object)((Component)collider).GetComponent<CargoSedationReceiver>() == (Object)null) { return true; } if (!((Object)(object)source != (Object)null) || !((Component)collider).transform.IsChildOf(((Component)source).transform)) { if ((Object)(object)owner != (Object)null) { if (!((Object)(object)((Component)collider).GetComponentInParent<PlayerAvatar>() == (Object)(object)owner)) { if ((Object)(object)owner.playerTransform != (Object)null) { return ((Component)collider).transform.IsChildOf(owner.playerTransform); } return false; } return true; } return false; } return true; } public static void Receive(CargoShot shot) { if (!NativeAccess.Host && !shot.Net && shot.Id > 0 && !terminal.Contains(shot.Id) && !active.ContainsKey(shot.Id) && HasCapacity) { Build(shot); } } public static void Receive(CargoDartImpact packet) { if (!NativeAccess.Host && packet != null && packet.Valid() && !(packet.Epoch != CargoDirector.Instance?.Epoch) && !terminal.Contains(packet.Id)) { terminal.Add(packet.Id); terminalOrder.Enqueue(packet.Id); while (terminalOrder.Count > 256) { terminal.Remove(terminalOrder.Dequeue()); } if (active.TryGetValue(packet.Id, out CargoDartProjectile value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } CargoNativeBulletVisual.Play(packet); } } public static void Clear() { CargoDartProjectile[] array = active.Values.ToArray(); foreach (CargoDartProjectile cargoDartProjectile in array) { if ((Object)(object)cargoDartProjectile != (Object)null) { Object.Destroy((Object)(object)((Component)cargoDartProjectile).gameObject); } } active.Clear(); terminal.Clear(); terminalOrder.Clear(); serial = 0; } private void OnDestroy() { if (shot != null && active.TryGetValue(shot.Id, out CargoDartProjectile value) && (Object)(object)value == (Object)(object)this) { active.Remove(shot.Id); } } } public sealed class CargoDartImpact { public string Epoch = ""; public int Id; public float Ox; public float Oy; public float Oz; public float X; public float Y; public float Z; public bool Valid() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (CargoProtocol.Epoch(Epoch) && Id > 0 && CargoProtocol.Position(Ox, Oy, Oz) && CargoProtocol.Position(X, Y, Z)) { return Vector3.Distance(new Vector3(Ox, Oy, Oz), new Vector3(X, Y, Z)) <= 19f; } return false; } } public static class CargoNativeBulletVisual { private static readonly FieldRef<ItemGunBullet, Vector3> hitPosition = AccessTools.FieldRefAccess<ItemGunBullet, Vector3>("hitPosition"); private static readonly FieldRef<ItemGunBullet, bool> bulletHit = AccessTools.FieldRefAccess<ItemGunBullet, bool>("bulletHit"); private static readonly FieldRef<ItemGunBullet, AnimationCurve> widthCurve = AccessTools.FieldRefAccess<ItemGunBullet, AnimationCurve>("shootLineWidthCurve"); private static ItemGun? nativeGun; public static void Play(CargoDartImpact packet) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)nativeGun == (Object)null) { Item? obj = ((IEnumerable<Item>)Items.AllItems).FirstOrDefault((Func<Item, bool>)delegate(Item i) { object obj4; if (i == null) { obj4 = null; } else { PrefabRef prefab3 = i.prefab; if (prefab3 == null) { obj4 = null; } else { GameObject prefab4 = ((PrefabRef<GameObject>)(object)prefab3).Prefab; obj4 = ((prefab4 != null) ? prefab4.GetComponent<ItemGunTranq>() : null); } } return (Object)obj4 != (Object)null; }); object obj2; if (obj == null) { obj2 = null; } else { PrefabRef prefab = obj.prefab; if (prefab == null) { obj2 = null; } else { GameObject prefab2 = ((PrefabRef<GameObject>)(object)prefab).Prefab; obj2 = ((prefab2 != null) ? prefab2.GetComponent<ItemGun>() : null); } } nativeGun = (ItemGun?)obj2; } if ((Object)(object)nativeGun == (Object)null || (Object)(object)nativeGun.bulletPrefab == (Object)null) { CargoVisuals.Pulse(new Vector3(packet.X, packet.Y, packet.Z), Color.green, 0.2f); return; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(packet.Ox, packet.Oy, packet.Oz); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(packet.X, packet.Y, packet.Z); GameObject bulletPrefab = nativeGun.bulletPrefab; Vector3 val3 = val; Vector3 val4 = val2 - val; GameObject val5 = Object.Instantiate<GameObject>(bulletPrefab, val3, Quaternion.LookRotation((((Vector3)(ref val4)).sqrMagnitude > 0.001f) ? (val2 - val) : Vector3.forward)); ItemGunBullet component = val5.GetComponent<ItemGunBullet>(); Collider[] componentsInChildren = val5.GetComponentsInChildren<Collider>(true); for (int num = 0; num < componentsInChildren.Length; num++) { componentsInChildren[num].enabled = false; } HurtCollider[] componentsInChildren2 = val5.GetComponentsInChildren<HurtCollider>(true); foreach (HurtCollider obj3 in componentsInChildren2) { ((Behaviour)obj3).enabled = false; ((Component)obj3).gameObject.SetActive(false); } component.hasHurtCollider = false; component.hasExtraParticles = false; component.hitGameObject = new GameObject("LiveCargo harmless native impact"); component.hitGameObject.transform.SetParent(val5.transform); component.hitGameObjectDestroyTime = 0.1f; hitPosition.Invoke(component) = val2; bulletHit.Invoke(component) = true; widthCurve.Invoke(component) = nativeGun.shootLineWidthCurve; component.ActivateAll(); Object.Destroy((Object)(object)val5, 3f); } } public sealed class CargoDirector : MonoBehaviour { private int sceneHandle = -1; private float nextRegistration; private float nextRegistry; private float nextTick; private float previousTick; private float nextBroadcast; private float nextSync; private float startedScene; private float nextKit; private long sequence; private long clientSequence = -1L; private float lastClientState = float.NegativeInfinity; private float nextClientApply; private bool kitIssued; private CargoSnapshot? clientSnapshot; private readonly Dictionary<int, int> actorSerials = new Dictionary<int, int>(); private readonly Dictionary<int, float> equipmentCooldown = new Dictionary<int, float>(); private readonly Dictionary<int, Vector3> releasePositions = new Dictionary<int, Vector3>(); private readonly List<int> removedEquipment = new List<int>(); private int pendingPaymentActor; private CargoCreature? pendingPaymentCreature; private Vector3 pendingPaymentOrigin; private float nextPaymentCheck; private string notification = ""; public static CargoDirector? Instance { get; private set; } public CargoLedger Ledger { get; } = new CargoLedger(); public CargoCombatUtility Combat { get; } = new CargoCombatUtility(); public string Epoch { get { object obj; if (!NativeAccess.Host) { obj = clientSnapshot?.Epoch; if (obj == null) { return ""; } } else { obj = Ledger.Epoch; } return (string)obj; } } public bool Transitioning { get; private set; } private void Awake() { Instance = this; Plugin.Log.LogInfo((object)"Cargo native-scene director created."); } public void PrepareSceneExit() { Transitioning = true; Combat.Clear(); } public void ResetRunProgress() { PrepareSceneExit(); CargoPhysicalNet.Clear(); CargoDartProjectile.Clear(); CargoRegistry.Clear(); Ledger.Reset(Guid.NewGuid().ToString("N")); clientSnapshot = null; clientSequence = -1L; actorSerials.Clear(); equipmentCooldown.Clear(); releasePositions.Clear(); removedEquipment.Clear(); pendingPaymentActor = 0; pendingPaymentCreature = null; nextPaymentCheck = 0f; sceneHandle = -1; } public void LevelChanged(int handle) { if (sceneHandle != handle) { Transitioning = true; Combat.Clear(); CargoPhysicalNet.Clear(); CargoDartProjectile.Clear(); CargoRegistry.Clear(); actorSerials.Clear(); equipmentCooldown.Clear(); releasePositions.Clear(); removedEquipment.Clear(); Ledger.Reset(Guid.NewGuid().ToString("N")); clientSnapshot = null; clientSequence = -1L; pendingPaymentActor = 0; pendingPaymentCreature = null; nextPaymentCheck = 0f; sceneHandle = handle; kitIssued = false; startedScene = Time.time; nextKit = Time.time + 3f; previousTick = Time.time; nextRegistry = 0f; nextSync = 0f; lastClientState = float.NegativeInfinity; nextClientApply = 0f; Transitioning = false; } } private void Update() { if ((Object)(object)GameManager.instance == (Object)null || Transitioning) { return; } if (!CargoAssets.Ready && Time.time >= nextRegistration) { nextRegistration = Time.time + 0.5f; try { CargoAssets.TryRegister(); } catch (Exception ex) { nextRegistration = Time.time + 10f; Plugin.Log.LogError((object)("Cargo equipment registration failed: " + ex)); } } if (!((Object)(object)RunManager.instance != (Object)null) || (!SemiFunc.RunIsLevel() && !SemiFunc.RunIsLobby() && !SemiFunc.RunIsTutorial()) || (Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated || !CargoAssets.Ready) { return; } if (Time.time >= nextRegistry) { nextRegistry = Time.time + 2f; CargoRegistry.Refresh(); foreach (CargoCreature value in CargoRegistry.Creatures.Values) { if ((Object)(object)value != (Object)null && NativeAccess.Host) { Ledger.Register(value.Id, value.Species); } } } if (NativeAccess.Host) { if (Ledger.PendingPayment != null && Time.time >= nextPaymentCheck) { ReconcilePayment(); } if (Time.time >= nextKit && !kitIssued && Plugin.LoanerKit.Value) { IssueKit(); } if (Time.time >= nextTick) { nextTick = Time.time + 0.1f; float dt = Mathf.Max(0f, Time.time - previousTick); previousTick = Time.time; Advance(dt); } if (Time.time >= nextBroadcast) { Broadcast(); } } else { if (Time.time >= nextSync && Time.time - lastClientState > 6f) { nextSync = Time.time + 3f; CargoNetwork.RequestSnapshot(); } if (Time.time >= nextClientApply) { nextClientApply = Time.time + 0.2f; ApplyClientSnapshot(); } } } private void LateUpdate() { if ((Object)(object)GameManager.instance != (Object)null && !Transitioning) { Combat.LateUpdate(Time.deltaTime); } } private void IssueKit() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) nextKit = Time.time + 2f; if ((Object)(object)PlayerAvatar.instance == (Object)null || !NativeAccess.IsAlive(PlayerAvatar.instance) || Time.time - startedScene < 3f) { return; } Transform obj = (((Object)(object)TruckSafetySpawnPoint.instance != (Object)null) ? ((Component)TruckSafetySpawnPoint.instance).transform : ((Component)PlayerAvatar.instance).transform); Vector3 position = obj.position; Vector3 val = Vector3.ProjectOnPlane(obj.right, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; val = Vector3.ProjectOnPlane(obj.forward, Vector3.up); Vector3 normalized2 = ((Vector3)(ref val)).normalized; foreach (CargoEquipment kind in Enum.GetValues(typeof(CargoEquipment))) { if (!CargoRegistry.Equipment.Values.Any((CargoEquipmentBehaviour e) => (Object)(object)e != (Object)null && e.Kind == kind)) { Physics.SyncTransforms(); if (!TryKitPosition(kind, position, normalized, normalized2, out var position2)) { return; } GameObject val2 = Items.SpawnItem(CargoAssets.Registered[kind], position2, Quaternion.identity); if ((Object)(object)val2 == (Object)null) { return; } PhysGrabObject component = val2.GetComponent<PhysGrabObject>(); if (component != null) { component.OverrideIndestructible(5f); } } } kitIssued = true; Plugin.Log.LogInfo((object)"Issued live-recovery loaner kit in the starting truck."); } private static bool TryKitPosition(CargoEquipment kind, Vector3 origin, Vector3 right, Vector3 forward, out Vector3 position) { //IL_001e: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f0: 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_00f8: 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_0107: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) bool flag = CargoRules.IsCage(kind); bool flag2 = kind == CargoEquipment.ReinforcedCage; Vector3 val = (flag ? new Vector3(flag2 ? 0.86f : 0.56f, flag2 ? 0.86f : 0.57f, flag2 ? 0.76f : 0.54f) : new Vector3(0.2f, 0.23f, 0.3f)); int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) | LayerMask.GetMask(new string[1] { "PhysGrabObject" }); int mask = LayerMask.GetMask(new string[3] { "Default", "PhysGrabObjectHinge", "StaticGrabObject" }); float[] array = new float[9] { 1.2f, 0f, -1.2f, 2.2f, -2.2f, 3.2f, -3.2f, 4.2f, -4.2f }; RaycastHit val2 = default(RaycastHit); RaycastHit val4 = default(RaycastHit); foreach (float num2 in array) { float[] array2 = new float[13] { -0.9f, 0.9f, 0f, -0.45f, 0.45f, -1.6f, 1.6f, -2.6f, 2.6f, -3.6f, 3.6f, -4.6f, 4.6f }; foreach (float num3 in array2) { if (!Physics.Raycast(origin + right * num3 + forward * num2 + Vector3.up * 0.6f, Vector3.down, ref val2, 3.5f, mask, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.85f) { continue; } Vector3 val3 = ((RaycastHit)(ref val2)).point + Vector3.up * (flag ? 0.05f : 0.28f); if (Physics.CheckBox(val3 + Vector3.up * (flag ? val.y : 0f), val, Quaternion.identity, num, (QueryTriggerInteraction)1)) { continue; } bool flag3 = true; for (int k = -1; k <= 1; k += 2) { for (int l = -1; l <= 1; l += 2) { if (!Physics.Raycast(((RaycastHit)(ref val2)).point + new Vector3((float)k * val.x, 0.2f, (float)l * val.z), Vector3.down, ref val4, 0.45f, mask, (QueryTriggerInteraction)1) || Mathf.Abs(((RaycastHit)(ref val4)).point.y - ((RaycastHit)(ref val2)).point.y) > 0.12f) { flag3 = false; } } } if (flag3) { position = val3; return true; } } } position = origin; return false; } public bool HandleAction(int actor, CargoAction request) { //IL_0035: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_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_0150: Unknown result type (might be due to invalid IL or missing references) if (!NativeAccess.Host || Transitioning || actor <= 0 || request.Epoch != Ledger.Epoch || request.Serial <= 0 || !NativeAccess.Finite(request.Direction) || !CargoRegistry.Equipment.TryGetValue(request.EquipmentId, out CargoEquipmentBehaviour value) || (Object)(object)value == (Object)null) { return false; } if (actorSerials.TryGetValue(actor, out var value2) && request.Serial <= value2) { return false; } PlayerAvatar val = NativeAccess.Player(actor); if (!NativeAccess.IsAlive(val) || (Object)(object)val == (Object)null || !NativeAccess.Holder(value, val)) { return false; } if (equipmentCooldown.TryGetValue(value.Id, out var value3) && Time.time < value3) { return false; } Vector3 direction = request.Direction; if (!(((Vector3)(ref direction)).sqrMagnitude < 0.9f)) { direction = request.Direction; if (!(((Vector3)(ref direction)).sqrMagnitude > 1.1f)) { actorSerials[actor] = request.Serial; equipmentCooldown[value.Id] = Time.time + CargoRules.Cooldown(value.Kind); if (value is CargoCage cage) { return UseCage(cage, actor); } if (value is CargoTool tool) { direction = request.Direction; return Shoot(tool, val, actor, ((Vector3)(ref direction)).normalized); } return false; } } return false; } private bool UseCage(CargoCage cage, int actor) { //IL_00ae: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) if (cage.Integrity <= 0f) { Feedback(actor, "Cage broken. Use another cage."); return false; } if ((Object)(object)cage.Occupant != (Object)null) { if (Ledger.PendingPayment != null) { Feedback(actor, "Payment pending. Cargo retained."); return false; } if (!InsideExtractor(cage)) { Feedback(actor, "Place the entire cage in an active extractor."); return false; } if (TryDeliver(cage, actor)) { return true; } return false; } CargoCreature cargoCreature = null; float num = 2.2f; foreach (CargoCreature value in CargoRegistry.Creatures.Values) { if (!((Object)(object)value == (Object)null) && value.Eligible && !value.Suspended) { float num2 = Vector3.Distance(cage.Physics.midPoint, value.Enemy.CenterTransform.position); if (num2 < num) { num = num2; cargoCreature = value; } } } if ((Object)(object)cargoCreature == (Object)null) { Feedback(actor, "No loadable target within reach."); return false; } CargoRecord cargoRecord = Ledger.Register(cargoCreature.Id, cargoCreature.Species); if (!CargoRules.Fits(cargoCreature.Species, cage.Kind)) { Feedback(actor, "Use a reinforced cage."); return false; } if (!CargoRules.CanCapture(cargoCreature.Species, cage.Kind, cargoRecord.Sedation, cargoRecord.NetLeft, cargoCreature.Hp)) { Feedback(actor, "Requires sedation and a net."); return false; } if (!LoadingPathClear(cage, cargoCreature)) { Feedback(actor, "The loading path is blocked."); return false; } if (!Ledger.TryCapture(cargoCreature.Id, cage.Id, cage.Kind, cargoCreature.Hp)) { return false; } if (!cargoCreature.Contain(cage)) { Ledger.TryRelease(cargoCreature.Id); return false; } Combat.Ledger.Remove(cargoCreature.Id); cage.Occupant = cargoCreature; cage.Record = cargoRecord; cage.SetMass(); CargoAudio.Emit(CargoCue.Secured, ((Component)cage).transform.position); CargoVisuals.Pulse(((Component)cage).transform.position, Color.green, 1f); Feedback(actor, "Cargo secured."); Broadcast(force: true); return true; } public bool LoadingPathClear(CargoCage cage, CargoCreature target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0061: Unknown result type (might be due to invalid IL or missing references) Vector3 midPoint = cage.Physics.midPoint; Vector3 val = target.Enemy.CenterTransform.position - midPoint; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { return true; } RaycastHit[] array = Physics.RaycastAll(midPoint, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)cage).transform) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)target).transform) && ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<CargoNetContact>()?.Net?.TargetId != target.Id) { return false; } } return true; } private bool Shoot(CargoTool tool, PlayerAvatar player, int actor, Vector3 direction) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0079: 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_0084: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_01aa: 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_018e: Unknown result type (might be due to invalid IL or missing references) bool flag = tool.Kind == CargoEquipment.NetLauncher; if (flag && !CargoPhysicalNet.HasCapacity) { Feedback(actor, "Too many nets. Wait for one to expire."); return false; } if (!flag && !CargoDartProjectile.HasCapacity) { return false; } if (!tool.Spend()) { Feedback(actor, "Battery empty."); return false; } Vector3 val = NativeAccess.Eye(player) + direction * 0.15f; if (!flag) { CargoShot payload = CargoDartProjectile.Launch(Epoch, val, direction, tool, player, delegate(RaycastHit hit) { if (NativeAccess.Host && !Transitioning) { CargoCage componentInParent3 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<CargoCage>(); CargoCreature cargoCreature = (((Object)(object)componentInParent3 != (Object)null) ? componentInParent3.Occupant : ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<CargoCreature>()); EnemyParent val3 = CargoCombatUtility.Resolve(((RaycastHit)(ref hit)).collider); bool flag2 = (Object)(object)val3 != (Object)null && Combat.Weaken(val3); if ((Object)(object)cargoCreature == (Object)null || !cargoCreature.Alive || cargoCreature.Retired || (!cargoCreature.Suspended && !cargoCreature.Eligible)) { if (flag2) { Feedback(actor, "Attacks weakened for 12s. Stay clear of lethal attacks."); Broadcast(force: true); } } else { CargoRecord cargoRecord = Ledger.Register(cargoCreature.Id, cargoCreature.Species); cargoRecord.Sedate(45f); Feedback(actor, "Sedation " + Mathf.RoundToInt(cargoRecord.Sedation) + "/" + CargoRules.Threshold(cargoRecord.Species)); Broadcast(force: true); } } }); CargoNetwork.Broadcast("shot", payload); return true; } float num = (flag ? 8 : 18); Vector3 end = val + direction * num; RaycastHit[] array = Physics.SphereCastAll(val, flag ? 0.15f : 0.035f, direction, num, LayerMask.op_Implicit(SemiFunc.LayerMaskGetShouldHits()), (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num2 = 0; num2 < array2.Length; num2++) { RaycastHit val2 = array2[num2]; PlayerAvatar componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<PlayerAvatar>(); CargoEquipmentBehaviour componentInParent2 = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<CargoEquipmentBehaviour>(); if (!((Object)(object)componentInParent == (Object)(object)player) && !((Object)(object)componentInParent2 == (Object)(object)tool) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<CargoNetContact>() != (Object)null) && (!((Object)(object)player.playerTransform != (Object)null) || !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(player.playerTransform))) { end = ((RaycastHit)(ref val2)).point; break; } } CargoNetState payload2 = CargoPhysicalNet.Launch(Epoch, val, end, tool, player, delegate(EnemyParent restrained) { if (!NativeAccess.Host || Transitioning || !CargoCombatUtility.Eligible(restrained)) { return; } CargoCreature component = ((Component)restrained).GetComponent<CargoCreature>(); int num3; float num4; if ((Object)(object)component != (Object)null && component.Eligible) { num3 = ((!component.Suspended) ? 1 : 0); if (num3 != 0) { num4 = 20f; goto IL_0050; } } else { num3 = 0; } num4 = 8f; goto IL_0050; IL_0050: float seconds = num4; Combat.Snare(restrained, seconds); if (num3 != 0) { CargoRecord cargoRecord = Ledger.Register(component.Id, component.Species); if (cargoRecord.Phase == CargoPhase.Wild) { cargoRecord.NetLeft = 20f; } } Feedback(actor, "Feet tangled. It can still attack."); Broadcast(force: true); }); CargoNetwork.Broadcast("net", payload2); return true; } public bool InsideExtractor(CargoCage cage) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_00b8: 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_00d9: 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_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_00f8: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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) foreach (ExtractionPoint extractor in CargoRegistry.Extractors) { if ((Object)(object)extractor == (Object)null || extractor.isLocked || (Object)(object)extractor.roomVolume == (Object)null || !extractor.roomVolume.activeInHierarchy) { continue; } State val = NativeAccess.ExtractionState.Invoke(extractor); if ((int)val != 2 && (int)val != 3 && (int)val != 4) { continue; } BoxCollider componentInChildren = extractor.roomVolume.GetComponentInChildren<BoxCollider>(); if ((Object)(object)componentInChildren == (Object)null) { continue; } bool flag = true; Collider[] componentsInChildren = ((Component)cage).GetComponentsInChildren<Collider>(); foreach (Collider val2 in componentsInChildren) { if (!val2.enabled || val2.isTrigger) { continue; } Bounds bounds = val2.bounds; for (int j = -1; j <= 1 && flag; j += 2) { for (int k = -1; k <= 1 && flag; k += 2) { for (int l = -1; l <= 1 && flag; l += 2) { Vector3 val3 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)j, (float)k, (float)l)); Vector3 val4 = ((Component)componentInChildren).transform.InverseTransformPoint(val3) - componentInChildren.center; if (Mathf.Abs(val4.x) > componentInChildren.size.x / 2f + 0.02f || Mathf.Abs(val4.z) > componentInChildren.size.z / 2f + 0.02f || Mathf.Abs(val4.y) > componentInChildren.size.y / 2f + 0.02f) { flag = false; } } } } } if (flag) { return true; } } return false; } public bool TryDeliver(CargoCage cage, int actor) { //IL_00f8: 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) if (!NativeAccess.Host || Transitioning || (Object)(object)cage.Occupant == (Object)null || !cage.Occupant.Alive || !cage.Occupant.Suspended) { return false; } PlayerAvatar val = NativeAccess.Player(actor); bool authorized = (Object)(object)val != (Object)null && NativeAccess.IsAlive(val) && NativeAccess.Holder(cage, val); CargoCreature occupant = cage.Occupant; int balance; try { balance = SemiFunc.StatGetRunCurrency(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Cannot read native currency for delivery: " + ex.Message)); Feedback(actor, "Payment unavailable. Cargo retained."); return false; } if (!Ledger.TryBeginPayment(occupant.Id, cage.Id, authorized, InsideExtractor(cage), occupant.Hp, occupant.Health.health, cage.Integrity, cage.MaxIntegrity, balance, out CargoPayment payment) || payment == null) { return false; } pendingPaymentActor = actor; pendingPaymentCreature = occupant; pendingPaymentOrigin = ((Component)cage).transform.position; Broadcast(force: true); try { SemiFunc.StatSetRunCurrency(payment.After); } catch (Exception ex2) { Plugin.Log.LogError((object)("Native live-cargo payout failed; reconciling balance before retry: " + ex2)); } return ReconcilePayment(); } private bool ReconcilePayment() { //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) nextPaymentCheck = Time.time + 1f; CargoPayment pendingPayment = Ledger.PendingPayment; if (pendingPayment == null || !NativeAccess.Host || Transitioning) { return false; } int num; try { num = SemiFunc.StatGetRunCurrency(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Live-cargo payment confirmation unavailable: " + ex.Message)); return false; } if (num == pendingPayment.Before) { if (!Ledger.TryCancelPayment(pendingPayment, num)) { return false; } Feedback(pendingPaymentActor, "Payment failed. Cargo retained; retry later."); CargoCreature cargoCreature = pendingPaymentCreature; pendingPaymentCreature = null; if ((Object)(object)cargoCreature != (Object)null && cargoCreature.Suspended && ((Object)(object)cargoCreature.Cage == (Object)null || cargoCreature.Cage.Integrity <= 0f)) { QueueEscape(cargoCreature); } Broadcast(force: true); return false; } CargoRegistry.Creatures.TryGetValue(pendingPayment.EnemyId, out CargoCreature value); if ((Object)(object)value == (Object)null) { value = pendingPaymentCreature; } if (num != pendingPayment.After || (Object)(object)value == (Object)null) { Feedback(pendingPaymentActor, "Payment pending. Cargo retained."); return false; } if (!Ledger.TryCommitPayment(pendingPayment, num)) { return false; } CargoCage cage = value.Cage; value.Retire(); pendingPaymentCreature = null; if ((Object)(object)cage != (Object)null) { cage.Occupant = null; cage.Record = null; cage.SetMass(); } CargoAudio.Emit(CargoCue.Delivered, ((Object)(object)cage != (Object)null) ? ((Component)cage).transform.position : pendingPaymentOrigin); Feedback(pendingPaymentActor, "Live cargo delivered +$" + (pendingPayment.Reward * 1000).ToString("N0")); Plugin.Log.LogInfo((object)("Live delivery epoch=" + Epoch + " enemy=" + value.Id + " rewardUnits=" + pendingPayment.Reward + " currency=" + pendingPayment.Before + "->" + num)); Broadcast(force: true); return true; } private void Advance(float dt) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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) //IL_01da: 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_01ef: 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) Combat.Ledger.Advance(dt); foreach (CargoRecord record in Ledger.Records) { if (!CargoRegistry