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.Text; using BepInEx; using FishNet; using FishNet.Broadcast; using FishNet.Connection; using FishNet.Managing; using FishNet.Managing.Object; using FishNet.Object; using FishNet.Serializing; using FishNet.Transporting; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DroneMod { public enum GunClass { Shotgun, Pistol, SMG, Rifle, Sniper } public static class Rules { public const int KitPrice = 10000; public const int FishPrice = 20000; public const int BossPrice = 100000; public const int MaxLevel = 10; public const float AcquisitionSeconds = 1f; public const float ManagementRange = 12f; public static bool Finite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } public static bool SurfaceAllowed(float normalY) { if (Finite(normalY)) { return normalY >= 0.02f; } return false; } public static bool CanRecall(bool freeSlot, bool emptyHands) { return freeSlot || emptyHands; } public static bool NeedsWeaponPurchase(int currentWeaponId, int requestedWeaponId) { return currentWeaponId != requestedWeaponId; } private static int Level(int level) { return Math.Min(10, Math.Max(0, level)); } private static double Growth(double rate, int level) { return Math.Pow(1.0 + rate, Level(level)); } public static float ReloadSeconds(float baseline, int upgrades) { return (float)((double)Math.Max(0.01f, baseline) / Growth(0.1, upgrades)); } public static string CleanName(string value) { if (value == null) { return ""; } StringBuilder stringBuilder = new StringBuilder(); string text = value.Trim(); foreach (char c in text) { if (!char.IsControl(c) && c != '<' && c != '>') { stringBuilder.Append(c); if (stringBuilder.Length == 32) { break; } } } return stringBuilder.ToString(); } public static bool InManagementRange(float distance) { if (Finite(distance)) { return distance <= 12f; } return false; } public static int DronePrice(int ownedDrones) { if (ownedDrones > 0) { return 0; } return 10000; } public static int UpgradePrice(int level) { if (level < 0 || level >= 10) { return 0; } return 1500 * (level + 1); } public static int TierPrice(int tier) { return tier switch { 1 => 100000, 0 => 20000, _ => 0, }; } public static int UpgradeInvestment(int level) { int num = 0; for (int i = 0; i < Math.Min(10, Math.Max(0, level)); i++) { num += UpgradePrice(i); } return num; } public static int TierInvestment(int tier) { if (tier > 0) { if (tier != 1) { return 120000; } return 20000; } return 0; } public static int ResaleValue(int purchasePrice, int level, int tier) { return (Math.Max(10000, purchasePrice) + UpgradeInvestment(level) + TierInvestment(tier)) / 2; } public static int ResaleValue(int level, int tier) { return ResaleValue(10000, level, tier); } public static GunClass Classify(string name) { string text = name.ToLowerInvariant(); if (text.Contains("snip") || text.Contains("awp") || text.Contains("scout")) { return GunClass.Sniper; } if (text.Contains("shot") || text.Contains("blunder")) { return GunClass.Shotgun; } if (text.Contains("smg") || text.Contains("uzi") || text.Contains("submachine") || text.Contains("mp5") || text.Contains("p90")) { return GunClass.SMG; } if (text.Contains("pistol") || text.Contains("revol") || text.Contains("handgun") || text.Contains("glock") || text.Contains("deagle") || text.Contains("desert eagle")) { return GunClass.Pistol; } return GunClass.Rifle; } public static float Radius(GunClass gun, int level) { return (float)((double)(new float[5] { 25f, 45f, 55f, 75f, 120f })[(int)gun] * Growth(0.05, level)); } public static float Reload(GunClass gun, int level) { return (float)((double)(new float[5] { 3f, 2.4f, 2.8f, 3f, 3.5f })[(int)gun] / Growth(0.1, level)); } public static float Interval(GunClass gun, int level) { return (float)((double)(new float[5] { 1.1f, 0.4f, 0.16f, 0.22f, 1.6f })[(int)gun] / Growth(0.1, level)); } public static int Magazine(GunClass gun) { return (new int[5] { 2, 12, 25, 20, 5 })[(int)gun]; } public static int Damage(int damage, int level) { return Math.Max(1, (int)Math.Round((double)damage * Growth(0.1, level))); } public static float Accuracy(int level) { return 0.85f + (float)Math.Min(10, Math.Max(0, level)) * 0.015f; } public static float AccuracyCone(int level) { return 3f - (float)Math.Min(10, Math.Max(0, level)) * 0.27f; } public static bool Eligible(int tier, bool seagull, bool fish, bool boss, bool dead, bool held) { if (!dead && !held && (seagull || fish)) { if (!boss) { if (!seagull) { return tier >= 1 && fish; } return true; } return tier >= 2; } return false; } public static float FollowDistance(float value) { return Math.Min(5f, Math.Max(1f, value)); } public static bool LeashReturning(float horizontalDistance, float radius, bool currentlyReturning) { radius = FollowDistance(radius); if (!currentlyReturning) { return horizontalDistance > radius; } return horizontalDistance > radius * 0.5f; } public static bool NeedsFollowRecovery(bool positionsFinite, float plannedSeparation, float actualSeparation, float heightFromPlayer) { if (positionsFinite && Finite(plannedSeparation) && Finite(actualSeparation) && !(plannedSeparation > 12f) && !(actualSeparation > 12f)) { return heightFromPlayer < -0.75f; } return true; } public static float ColorChannel(float value) { return Math.Min(1f, Math.Max(0f, value)); } } [Serializable] public sealed class DroneData { public int serial; public int level; public int tier; public int ammo; public int shots; public int reloads; public int acquisition; public int activations; public int modeChanges; public int purchasePrice; public int followDefaultsVersion; public ulong owner; public string ownerName; public string customName; public bool deployed; public bool friendlyFire; public bool acquiring; public bool hasTarget; public int mode; public int followPosition = 2; public float followDistance = 3f; public Vector3 bodyColor = new Vector3(0.1f, 0.14f, 0.18f); public Vector3 propellerColor = new Vector3(0.85f, 0.95f, 0.05f); public Vector3 accentColor = new Vector3(0.05f, 0.85f, 1f); public bool available = true; public string combatStatus = "Not deployed"; public Vector3 surfaceNormal = Vector3.up; public Vector3 position; public Vector3 aim; public Vector3 shotAim; public float yaw; public SavedItem weapon; [NonSerialized] public float nextShot; [NonSerialized] public bool reloading; [NonSerialized] public Creature lockedTarget; [NonSerialized] public float lockUntil; [NonSerialized] public Vector3 followVelocity; [NonSerialized] public float activationUntil; [NonSerialized] public Vector3 lastObservedFollowPosition; [NonSerialized] public float followStuckSince; [NonSerialized] public bool hasObservedFollowPosition; [NonSerialized] public bool leashReturning; [NonSerialized] public bool returningFromMode; public string DisplayName { get { if (!string.IsNullOrEmpty(customName)) { return customName; } return "Drone #" + serial; } } public Quaternion BaseRotation => Quaternion.FromToRotation(Vector3.up, (((Vector3)(ref surfaceNormal)).sqrMagnitude > 0.01f) ? surfaceNormal : Vector3.up) * Quaternion.Euler(0f, yaw, 0f); } [Serializable] public sealed class WorldData { public string name; public List drones = new List(); public List retired = new List(); } [Serializable] public sealed class SaveData { public int version = 1; public int nextSerial = 1; public List worlds = new List(); } [Serializable] public sealed class Command { public int protocol = 4; public int sequence; public int serial; public int argument; public string action; public string text; public Vector3 position; public Vector3 normal; } [Serializable] public sealed class Snapshot { public int protocol = 4; public string world; public List drones = new List(); } [Serializable] public sealed class Reply { public int sequence; public int serial; public string message; } [Serializable] public sealed class HitFeedback { public Vector3 position; public int damage; public int worth; public bool killed; public string creatureName; } [Serializable] public sealed class ModeSoundEvent { public int serial; public int mode; public int eventId; public Vector3 position; } public struct RequestMessage : IBroadcast { public string json; } public struct StateMessage : IBroadcast { public string json; } public struct ReplyMessage : IBroadcast { public string json; } public struct HitFeedbackMessage : IBroadcast { public string json; } public struct ModeSoundMessage : IBroadcast { public string json; } public sealed class Gun { public Weapon prefab; public string name; public GunClass kind; public int damage; public int price; public int magazine; public int extendedMagazine; public int[] ammoDamages; public float reload; public int Magazine(SavedItem state) { if (state == null || !state.ExtendedMag) { return magazine; } return extendedMagazine; } public int Damage(SavedItem state) { int num = state?.AmmoType ?? 0; if (ammoDamages == null || num < 0 || num >= ammoDamages.Length) { return damage; } return ammoDamages[num]; } } public static class Kit { public const byte Id = 248; public const ushort Collection = 42422; public static Item Prefab; private static GameObject storage; public static bool Is(Item item) { if ((Object)(object)item != (Object)null && item.ID == 248) { return (Object)(object)((Component)item).GetComponent() != (Object)null; } return false; } public static int Serial(Item item) { if (!Is(item)) { return 0; } return Mathf.RoundToInt(item.BettingMultiplier); } public static void Register() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown //IL_0349: 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_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Prefab != (Object)null || (Object)(object)InstanceFinder.NetworkManager == (Object)null) { return; } Dictionary dictionary = (Dictionary)AccessTools.Field(typeof(GameInfo), "_idToSpawnable").GetValue(null); if (dictionary.Count == 0) { return; } if (dictionary.ContainsKey(248)) { throw new Exception("DroneMod item ID 248 is already in use; refusing to replace another item."); } Item val = (from i in dictionary.Values where (Object)(object)i != (Object)null && ((object)i).GetType() == typeof(Item) && (Object)(object)((Component)i).GetComponent() != (Object)null orderby i.ID select i).FirstOrDefault(); if ((Object)(object)val == (Object)null) { throw new Exception("No compatible base Item prefab found for the inventory kit."); } storage = new GameObject("DroneMod prefab storage"); storage.SetActive(false); Object.DontDestroyOnLoad((Object)(object)storage); Item val2 = Object.Instantiate(val, storage.transform); ((Object)val2).name = "Drone Mod Kit"; AccessTools.Field(typeof(Item), "_id").SetValue(val2, (byte)248); AccessTools.Field(typeof(Item), "_cost").SetValue(val2, 10000); AccessTools.Field(typeof(Item), "_worth").SetValue(val2, 5000); AccessTools.Field(typeof(Item), "_ignoredBySeagulls").SetValue(val2, true); AccessTools.Field(typeof(Item), "_ignoredByMoneyNPC").SetValue(val2, false); AccessTools.Field(typeof(Item), "_ignoredByCloseDots").SetValue(val2, false); AccessTools.Field(typeof(Item), "_heldPos").SetValue(val2, (object)new Vector3(0f, -0.16f, 0.5f)); AccessTools.Field(typeof(Item), "_heldRot").SetValue(val2, (object)new Vector3(6f, 0f, 0f)); Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); for (int num = 0; num < componentsInChildren.Length; num++) { componentsInChildren[num].enabled = false; } Collider[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren(true); foreach (Collider val3 in componentsInChildren2) { if (!val3.isTrigger) { val3.enabled = false; } } GameObject val4 = new GameObject("DroneModBodyCollider"); val4.transform.SetParent(((Component)val2).transform, false); BoxCollider val5 = val4.AddComponent(); val5.center = new Vector3(0f, 0.25f, 0f); val5.size = new Vector3(1.18f, 0.42f, 1.06f); AccessTools.Field(typeof(Item), "_worldColliders").SetValue(val2, new Collider[1] { (Collider)val5 }); Collider val6 = (Collider)AccessTools.Field(typeof(Item), "_pickUpCollider").GetValue(val2); if ((Object)(object)val6 != (Object)null) { val6.isTrigger = true; } if (val6 is SphereCollider) { ((SphereCollider)val6).radius = 0.52f; ((SphereCollider)val6).center = new Vector3(0f, 0.28f, 0f); } else if (val6 is BoxCollider) { ((BoxCollider)val6).size = new Vector3(1.18f, 0.72f, 1.06f); ((BoxCollider)val6).center = new Vector3(0f, 0.28f, 0f); } AccessTools.Field(typeof(Item), "_outOfHandHolder").SetValue(val2, null); AccessTools.Field(typeof(Item), "_inHandHolder").SetValue(val2, null); KitVisual kitVisual = ((Component)val2).gameObject.AddComponent(); kitVisual.Build(); AccessTools.Field(typeof(Item), "_mesh").SetValue(val2, kitVisual.InventoryMesh()); AccessTools.Field(typeof(Item), "_inventoryMeshScale").SetValue(val2, 0.58f); AccessTools.Field(typeof(Item), "_inventoryMeshPos").SetValue(val2, (object)new Vector3(0f, -0.2f, 0f)); AccessTools.Field(typeof(Item), "_inventoryMeshRot").SetValue(val2, (object)new Vector3(0f, 35f, 0f)); AccessTools.Field(typeof(Item), "_renderers").SetValue(val2, (from r in ((Component)kitVisual).GetComponentsInChildren(true) where r.enabled select r).ToList()); NetworkObject component = ((Component)val2).GetComponent(); component.SetIsSpawnable(true); PrefabObjects prefabObjects = InstanceFinder.NetworkManager.GetPrefabObjects((ushort)42422, true); if (prefabObjects.GetObjectCount() != 0) { throw new Exception("DroneMod network prefab collection 42422 is already occupied."); } prefabObjects.AddObject(component, false, true); dictionary.Add(248, val2); ((Dictionary)AccessTools.Field(typeof(GameInfo), "_allItems").GetValue(null)).Add(248, val2); ((Dictionary)AccessTools.Field(typeof(GameInfo), "_nameToSpawnable").GetValue(null)).Add("dronemodkit", val2); Prefab = val2; Plugin.Log("Inventory kit registered using " + ((Object)val).name + "; dedicated network collection " + (ushort)42422 + "."); } } public sealed class KitVisual : MonoBehaviour { public Transform head; public Transform socket; private Transform aimPivot; private Item item; private int gunId = -1; private int gunStateSignature = int.MinValue; private int lastShot; private int lastReload; private int lastAcquisition; private int lastActivation = int.MinValue; private LineRenderer tracer; private LineRenderer lockLaser; private float tracerUntil; private GameObject mountedGun; private Vector3 displayedPosition; private Vector3 displayVelocity; private Vector3 localFpvAim; private Vector3 lastFollowAuthoritativePosition; private Quaternion displayedRotation; private bool displayedPositionReady; private bool followTargetReady; private float followLastMovedAt; private float followIdleHoverBlend; private int displayedMode = int.MinValue; private Animation mountedAnimation; private Transform mountedMuzzle; private ParticleSystem mountedFireParticle; private BarrelAttachment mountedBarrel; private AudioSequence fireSequence; private AudioSequence fireLastSequence; private AudioSequence reloadSequence; private AudioSequence reloadLastSequence; private bool hasLastFire; private bool hasLastReload; private bool proceduralReload; private float recoilUntil; private float reloadStarted; private float reloadUntil; private Vector3 mountedBasePosition; private Quaternion mountedBaseRotation; private Material bodyMaterial; private Material propellerMaterial; private Material accentMaterial; private static Material glow; private static Material lockGlow; private readonly List propellers = new List(); private bool materialsReady; private AudioSource startupSource; private AudioSource humA; private AudioSource humB; private AudioLowPassFilter humFilterA; private AudioLowPassFilter humFilterB; private bool humRunning; private bool humCrossfading; private bool wasFlying; private bool pendingStartup; private int activeHum; private float humAllowedAt; private float humCrossfadeAt; private float humFadeStart; private float launchVisualUntil; public Vector3 MuzzlePosition { get { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)mountedMuzzle != (Object)null)) { if (!((Object)(object)head != (Object)null)) { return ((Component)this).transform.position + ((Component)this).transform.up * 1.2f; } return head.position + head.forward * 0.55f; } return mountedMuzzle.position; } } public int InventoryGunSignature => WeaponSignature(((Object)(object)Plugin.Instance == (Object)null) ? null : Plugin.Instance.Find(Kit.Serial(item))?.weapon); public void Build() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005a: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_05ac: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((Component)this).transform.Find("DroneModBase") != (Object)null)) { Shader val = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); bodyMaterial = new Material(val) { color = new Color(0.1f, 0.18f, 0.28f) }; propellerMaterial = new Material(val) { color = new Color(0.85f, 0.95f, 0.05f) }; accentMaterial = new Material(val) { color = new Color(0.05f, 0.85f, 1f) }; if ((Object)(object)glow == (Object)null) { glow = new Material(Shader.Find("Sprites/Default")) { color = Color.cyan }; } if ((Object)(object)lockGlow == (Object)null) { lockGlow = new Material(Shader.Find("Sprites/Default")) { color = Color.red }; } Part("DroneModBase", ((Component)this).transform, (PrimitiveType)0, new Vector3(0f, 0.29f, 0f), new Vector3(0.5f, 0.16f, 0.43f), bodyMaterial); Part("Canopy", ((Component)this).transform, (PrimitiveType)0, new Vector3(0f, 0.38f, 0.015f), new Vector3(0.33f, 0.13f, 0.28f), bodyMaterial); Part("BodyBand", ((Component)this).transform, (PrimitiveType)2, new Vector3(0f, 0.27f, 0f), new Vector3(0.51f, 0.055f, 0.44f), bodyMaterial); Vector3 val2 = default(Vector3); for (int i = 0; i < 4; i++) { float num = ((i % 2 == 0) ? (-1f) : 1f); float num2 = ((i < 2) ? 1f : (-1f)); ((Vector3)(ref val2))..ctor(num * 0.34f, 0.29f, num2 * 0.29f); Vector3 pos = val2 * 0.55f + new Vector3(0f, 0.015f, 0f); Part("Arm", ((Component)this).transform, (PrimitiveType)3, pos, new Vector3(0.065f, 0.055f, 0.43f), bodyMaterial).localEulerAngles = new Vector3(0f, num * num2 * -49f, 0f); Part("Motor", ((Component)this).transform, (PrimitiveType)2, val2, new Vector3(0.085f, 0.07f, 0.085f), bodyMaterial); Ring("PropGuard", ((Component)this).transform, val2 + Vector3.up * 0.035f, 0.245f, 0.205f, 0.035f, bodyMaterial); Part("GuardBraceX", ((Component)this).transform, (PrimitiveType)3, val2 + Vector3.up * 0.035f, new Vector3(0.46f, 0.025f, 0.025f), bodyMaterial); Part("GuardBraceZ", ((Component)this).transform, (PrimitiveType)3, val2 + Vector3.up * 0.035f, new Vector3(0.025f, 0.025f, 0.46f), bodyMaterial); Transform transform = new GameObject("Propeller").transform; transform.SetParent(((Component)this).transform, false); transform.localPosition = val2 + Vector3.up * 0.075f; propellers.Add(transform); Part("BladeA", transform, (PrimitiveType)3, Vector3.zero, new Vector3(0.38f, 0.018f, 0.055f), propellerMaterial).localEulerAngles = new Vector3(0f, 12f, 0f); Part("BladeB", transform, (PrimitiveType)3, Vector3.zero, new Vector3(0.055f, 0.018f, 0.38f), propellerMaterial).localEulerAngles = new Vector3(0f, 12f, 0f); } float[] array = new float[3] { -0.2f, 0f, 0.2f }; foreach (float num3 in array) { Part("StatusLight", ((Component)this).transform, (PrimitiveType)3, new Vector3(num3, 0.28f, 0.405f), new Vector3(0.11f, 0.045f, 0.025f), accentMaterial); } head = new GameObject("DroneModHead").transform; head.SetParent(((Component)this).transform, false); head.localPosition = new Vector3(0f, 0.095f, 0f); Part("Cradle", head, (PrimitiveType)3, Vector3.zero, new Vector3(0.24f, 0.07f, 0.2f), accentMaterial); aimPivot = new GameObject("DroneModGunAimPivot").transform; aimPivot.SetParent(head, false); aimPivot.localPosition = new Vector3(0f, -0.055f, 0f); socket = new GameObject("WeaponSocket").transform; socket.SetParent(aimPivot, false); socket.localPosition = Vector3.zero; Part("SocketEmpty", socket, (PrimitiveType)3, Vector3.zero, new Vector3(0.16f, 0.045f, 0.18f), bodyMaterial); } } public void RefreshColors(DroneData data) { //IL_00b1: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0119: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01b3: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) EnsureInstanceMaterials(); if (data == null) { return; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Rules.ColorChannel(data.bodyColor.x), Rules.ColorChannel(data.bodyColor.y), Rules.ColorChannel(data.bodyColor.z)); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Rules.ColorChannel(data.propellerColor.x), Rules.ColorChannel(data.propellerColor.y), Rules.ColorChannel(data.propellerColor.z)); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Rules.ColorChannel(data.accentColor.x), Rules.ColorChannel(data.accentColor.y), Rules.ColorChannel(data.accentColor.z)); Color val4 = default(Color); ((Color)(ref val4))..ctor(val.x, val.y, val.z); Color val5 = default(Color); ((Color)(ref val5))..ctor(val2.x, val2.y, val2.z); Color val6 = default(Color); ((Color)(ref val6))..ctor(val3.x, val3.y, val3.z); SetMaterialColor(bodyMaterial, val4); SetMaterialColor(propellerMaterial, val5); SetMaterialColor(accentMaterial, val6); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Renderer val7 in componentsInChildren) { if (!((Object)(object)val7 == (Object)null) && !((Component)val7).transform.IsChildOf(socket)) { string name = ((Object)((Component)val7).gameObject).name; Color val8 = (name.Contains("Blade") ? val5 : ((name == "StatusLight" || name == "Cradle") ? val6 : val4)); MaterialPropertyBlock val9 = new MaterialPropertyBlock(); val7.GetPropertyBlock(val9); val9.SetColor("_BaseColor", val8); val9.SetColor("_Color", val8); val7.SetPropertyBlock(val9); } } } private static void SetMaterialColor(Material material, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { material.color = color; if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); } if (material.HasProperty("_Color")) { material.SetColor("_Color", color); } } } private void EnsureInstanceMaterials() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_006d: 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_0077: Expected O, but got Unknown //IL_0094: 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_009e: Expected O, but got Unknown if (materialsReady) { return; } materialsReady = true; Shader val = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); bodyMaterial = (((Object)(object)bodyMaterial == (Object)null) ? new Material(val) : new Material(bodyMaterial)); propellerMaterial = (((Object)(object)propellerMaterial == (Object)null) ? new Material(val) : new Material(propellerMaterial)); accentMaterial = (((Object)(object)accentMaterial == (Object)null) ? new Material(val) : new Material(accentMaterial)); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!((Component)val2).transform.IsChildOf(socket)) { string name = ((Object)((Component)val2).gameObject).name; val2.sharedMaterial = (name.Contains("Blade") ? propellerMaterial : ((name == "StatusLight" || name == "Cradle") ? accentMaterial : bodyMaterial)); } } } private static Transform Part(string name, Transform parent, PrimitiveType primitive, Vector3 pos, Vector3 scale, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(primitive); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = pos; obj.transform.localScale = scale; Object.DestroyImmediate((Object)(object)obj.GetComponent()); obj.GetComponent().sharedMaterial = material; return obj.transform; } private static Transform Ring(string name, Transform parent, Vector3 pos, float outerRadius, float innerRadius, float height, Material material) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[116]; int[] array2 = new int[672]; for (int i = 0; i <= 28; i++) { float num = (float)i * (float)Math.PI * 2f / 28f; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); int num4 = i * 4; array[num4] = new Vector3(num2 * outerRadius, (0f - height) * 0.5f, num3 * outerRadius); array[num4 + 1] = new Vector3(num2 * outerRadius, height * 0.5f, num3 * outerRadius); array[num4 + 2] = new Vector3(num2 * innerRadius, height * 0.5f, num3 * innerRadius); array[num4 + 3] = new Vector3(num2 * innerRadius, (0f - height) * 0.5f, num3 * innerRadius); } int num5 = 0; for (int j = 0; j < 28; j++) { int num6 = j * 4; int num7 = (j + 1) * 4; int[] array3 = new int[24] { num6, num6 + 1, num7 + 1, num6, num7 + 1, num7, num6 + 1, num6 + 2, num7 + 2, num6 + 1, num7 + 2, num7 + 1, num6 + 2, num6 + 3, num7 + 3, num6 + 2, num7 + 3, num7 + 2, num6 + 3, num6, num7, num6 + 3, num7, num7 + 3 }; for (int k = 0; k < array3.Length; k++) { array2[num5++] = array3[k]; } } Mesh val = new Mesh { name = name + " Mesh", vertices = array, triangles = array2 }; val.RecalculateNormals(); val.RecalculateBounds(); GameObject val2 = new GameObject(name); val2.transform.SetParent(parent, false); val2.transform.localPosition = pos; val2.AddComponent().sharedMesh = val; ((Renderer)val2.AddComponent()).sharedMaterial = material; return val2.transform; } private static string RelativePath(Transform root, Transform child) { if ((Object)(object)root == (Object)null || (Object)(object)child == (Object)null) { return null; } if ((Object)(object)root == (Object)(object)child) { return ""; } List list = new List(); Transform val = child; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) { list.Add(((Object)val).name); val = val.parent; } if ((Object)(object)val != (Object)(object)root) { return null; } list.Reverse(); return string.Join("/", list.ToArray()); } private static Transform CloneTransform(Transform sourceRoot, Transform cloneRoot, Transform source) { string text = RelativePath(sourceRoot, source); if (text != null) { if (text.Length != 0) { return cloneRoot.Find(text); } return cloneRoot; } return null; } private static T Private(object target, string name) where T : class { FieldInfo fieldInfo = ((target == null) ? null : AccessTools.Field(target.GetType(), name)); if (!(fieldInfo == null)) { return fieldInfo.GetValue(target) as T; } return null; } private static void ActivatePath(Transform child, Transform root) { Transform val = child; while ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(true); if (!((Object)(object)val == (Object)(object)root)) { val = val.parent; continue; } break; } } private static bool IsWeaponRenderer(Renderer renderer) { if (!(renderer is MeshRenderer)) { return renderer is SkinnedMeshRenderer; } return true; } private static void EnableVisuals(Transform root) { if ((Object)(object)root == (Object)null) { return; } ActivatePath(root, root); Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (IsWeaponRenderer(val)) { ActivatePath(((Component)val).transform, root); val.enabled = true; val.forceRenderingOff = false; val.lightmapIndex = -1; val.realtimeLightmapIndex = -1; } } } private void ToggleCopies(Transform sourceRoot, Transform cloneRoot, List choices, int selected) where T : Component { if (choices == null) { return; } for (int i = 0; i < choices.Count; i++) { Transform val = CloneTransform(sourceRoot, cloneRoot, ((Object)(object)choices[i] == (Object)null) ? null : ((Component)choices[i]).transform); if (!((Object)(object)val == (Object)null)) { ((Component)val).gameObject.SetActive(i == selected); if (i == selected) { ActivatePath(val, cloneRoot); EnableVisuals(val); } } } } private void BuildMountedGun(Gun gun, SavedItem state) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_092b: Unknown result type (might be due to invalid IL or missing references) //IL_07ff: Unknown result type (might be due to invalid IL or missing references) //IL_080b: Unknown result type (might be due to invalid IL or missing references) //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_0845: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_08c6: Unknown result type (might be due to invalid IL or missing references) //IL_08cb: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_08dd: Unknown result type (might be due to invalid IL or missing references) //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08f2: Unknown result type (might be due to invalid IL or missing references) //IL_08fa: Unknown result type (might be due to invalid IL or missing references) Transform val = socket.Find("MountedGun"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } mountedGun = null; mountedAnimation = null; mountedMuzzle = null; mountedFireParticle = null; mountedBarrel = null; fireSequence = (fireLastSequence = (reloadSequence = (reloadLastSequence = null))); hasLastFire = (hasLastReload = false); if (gun == null || (Object)(object)gun.prefab == (Object)null) { return; } mountedGun = new GameObject("MountedGun"); mountedGun.transform.SetParent(socket, false); bool activeSelf = ((Component)socket).gameObject.activeSelf; ((Component)socket).gameObject.SetActive(false); GameObject val2 = Object.Instantiate(((Component)gun.prefab).gameObject, mountedGun.transform, false); ((Object)val2).name = "WeaponRig"; Weapon component = val2.GetComponent(); if ((Object)(object)component != (Object)null && state != null) { try { ((Item)component).LoadFromSave(state); } catch (Exception ex) { Plugin.Log("Native visual configuration fallback for " + gun.name + ": " + ex.Message); } } MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Collider[] componentsInChildren2 = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Rigidbody[] componentsInChildren3 = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } ((Component)socket).gameObject.SetActive(activeSelf); val2.SetActive(true); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.Euler(((Item)gun.prefab).InventoryMeshRot); val2.transform.localScale = Vector3.one; Transform transform = ((Component)gun.prefab).transform; Attachments attachments = gun.prefab.Attachments; GameObject val3 = Private(gun.prefab, "_outOfHandHolder"); GameObject val4 = Private(gun.prefab, "_inHandHolder"); Transform val5 = CloneTransform(transform, val2.transform, ((Object)(object)val3 == (Object)null) ? null : val3.transform); Transform val6 = CloneTransform(transform, val2.transform, ((Object)(object)val4 == (Object)null) ? null : val4.transform); Transform val7 = (((Object)(object)val5 != (Object)null && ((Component)val5).GetComponentsInChildren(true).Any(IsWeaponRenderer)) ? val5 : (((Object)(object)val6 != (Object)null) ? val6 : val5)); if ((Object)(object)val5 != (Object)null) { ((Component)val5).gameObject.SetActive((Object)(object)val7 == (Object)(object)val5); } if ((Object)(object)val6 != (Object)null) { ((Component)val6).gameObject.SetActive((Object)(object)val7 == (Object)(object)val6); } if ((Object)(object)val7 != (Object)null) { ActivatePath(val7, val2.transform); EnableVisuals(val7); } List list = Private>(gun.prefab, "_renderers"); if (list != null) { foreach (Renderer item in list) { Transform val8 = CloneTransform(transform, val2.transform, ((Object)(object)item == (Object)null) ? null : ((Component)item).transform); if (!((Object)(object)val8 == (Object)null) && (!((Object)(object)val7 != (Object)null) || val8.IsChildOf(val7) || !((Object)(object)val8 != (Object)(object)val7))) { ActivatePath(val8, val2.transform); Renderer component2 = ((Component)val8).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.enabled = true; component2.forceRenderingOff = false; component2.lightmapIndex = -1; component2.realtimeLightmapIndex = -1; } } } } List list2 = Private>(attachments, "_sights"); List list3 = Private>(attachments, "_barrelAttachments"); int selected = Mathf.Clamp((int)(state?.Sight ?? 0), 0, (list2 != null) ? (list2.Count - 1) : 0); int num = Mathf.Clamp((int)(state?.BarrelAttachment ?? 0), 0, (list3 != null) ? (list3.Count - 1) : 0); ToggleCopies(transform, val2.transform, list2, selected); ToggleCopies(transform, val2.transform, list3, num); LaserSight val9 = Private(attachments, "_laserSight"); Transform val10 = CloneTransform(transform, val2.transform, ((Object)(object)val9 == (Object)null) ? null : ((Component)val9).transform); if ((Object)(object)val10 != (Object)null) { ((Component)val10).gameObject.SetActive(state?.LaserSight ?? false); if (state != null && state.LaserSight) { ActivatePath(val10, val2.transform); EnableVisuals(val10); } } if (list3 != null && list3.Count > 0) { mountedBarrel = list3[num]; mountedMuzzle = CloneTransform(transform, val2.transform, mountedBarrel.FirePoint); Transform val11 = CloneTransform(transform, val2.transform, ((Object)(object)mountedBarrel.FireParticle == (Object)null) ? null : ((Component)mountedBarrel.FireParticle).transform); if ((Object)(object)val11 != (Object)null) { mountedFireParticle = ((Component)val11).GetComponent(); } } Renderer[] componentsInChildren4; if (!val2.GetComponentsInChildren(false).Any(IsWeaponRenderer)) { componentsInChildren4 = val2.GetComponentsInChildren(true); foreach (Renderer val12 in componentsInChildren4) { if (IsWeaponRenderer(val12)) { ActivatePath(((Component)val12).transform, val2.transform); val12.enabled = true; val12.forceRenderingOff = false; val12.lightmapIndex = -1; val12.realtimeLightmapIndex = -1; } } } if (state != null && (Object)(object)((Item)gun.prefab).SkinPreset != (Object)null && ((Item)gun.prefab).SkinPreset.Skins.Count > 0) { int index = Mathf.Clamp((int)state.SkinIndex, 0, ((Item)gun.prefab).SkinPreset.Skins.Count - 1); componentsInChildren4 = val2.GetComponentsInChildren(false); foreach (Renderer val13 in componentsInChildren4) { if (IsWeaponRenderer(val13)) { ShaderManager.ApplyItemSkin(((Item)gun.prefab).SkinPreset.Skins[index], val13, false); } } } mountedAnimation = val2.GetComponentInChildren(true); fireSequence = Private(gun.prefab, "_fireAudioSeq"); fireLastSequence = Private(gun.prefab, "_fireLastAudioSeq"); reloadSequence = Private(gun.prefab, "_reloadAudioSeq"); reloadLastSequence = Private(gun.prefab, "_reloadLastAudioSeq"); hasLastFire = (bool)AccessTools.Field(typeof(Weapon), "_hasLastFireAnim").GetValue(gun.prefab); hasLastReload = (bool)AccessTools.Field(typeof(Weapon), "_hasLastReloadAnim").GetValue(gun.prefab); Renderer[] array = val2.GetComponentsInChildren(false).Where(IsWeaponRenderer).ToArray(); Bounds val14 = default(Bounds); bool flag = false; componentsInChildren4 = array; foreach (Renderer val15 in componentsInChildren4) { if (!flag) { val14 = val15.bounds; flag = true; } else { ((Bounds)(ref val14)).Encapsulate(val15.bounds); } } if (flag) { float num2 = 1.35f / Mathf.Max(0.001f, Mathf.Max(((Bounds)(ref val14)).size.x, Mathf.Max(((Bounds)(ref val14)).size.y, ((Bounds)(ref val14)).size.z))); mountedGun.transform.localScale = Vector3.one * num2; Renderer[] array2 = val2.GetComponentsInChildren(false).Where(IsWeaponRenderer).ToArray(); flag = false; componentsInChildren4 = array2; foreach (Renderer val16 in componentsInChildren4) { if (!flag) { val14 = val16.bounds; flag = true; } else { ((Bounds)(ref val14)).Encapsulate(val16.bounds); } } if (flag) { Vector3 val17 = socket.InverseTransformPoint(((Bounds)(ref val14)).center); mountedGun.transform.localPosition = new Vector3(0f - val17.x, -0.12f - val17.y, 0f - val17.z); } } mountedBasePosition = mountedGun.transform.localPosition; mountedBaseRotation = mountedGun.transform.localRotation; int num3 = val2.GetComponentsInChildren(false).Count(IsWeaponRenderer); Plugin.Log("Mounted visual " + gun.name + ": skin=" + (int)(state?.SkinIndex ?? 0) + ", sight=" + (int)(state?.Sight ?? 0) + ", barrel=" + (int)(state?.BarrelAttachment ?? 0) + ", active renderers=" + num3 + ", holder=" + (((Object)(object)val7 == (Object)null) ? "fallback" : ((Object)val7).name) + "."); } private static void SetLayerRecursively(GameObject root, int layer) { Transform[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = layer; } } public GameObject CreateInventoryGunPreview(Transform parent) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mountedGun == (Object)null || (Object)(object)parent == (Object)null) { return null; } GameObject val = Object.Instantiate(mountedGun, parent, false); ((Object)val).name = "DroneModInventoryGunPreview"; MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Collider[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } val.transform.localPosition = new Vector3(0f, 0.02f, 0f); val.transform.localRotation = Quaternion.Euler(-8f, 20f, 0f); val.transform.localScale = mountedGun.transform.localScale * 0.82f; SetLayerRecursively(val, ((Component)parent).gameObject.layer); val.SetActive(true); Renderer[] componentsInChildren3 = val.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren3) { if (IsWeaponRenderer(val2)) { ActivatePath(((Component)val2).transform, val.transform); val2.enabled = true; val2.lightmapIndex = -1; val2.realtimeLightmapIndex = -1; } } return val; } private static int WeaponSignature(SavedItem state) { if (state == null || !state.Exists) { return -1; } return ((((((17 * 31 + state.ItemID) * 31 + state.SkinIndex) * 31 + state.Sight) * 31 + state.BarrelAttachment) * 31 + state.AmmoType) * 31 + (state.ExtendedMag ? 1 : 0)) * 31 + (state.LaserSight ? 1 : 0); } private void PlayAnimation(string name, float duration = 0f) { if (!((Object)(object)mountedAnimation == (Object)null) && !((TrackedReference)(object)mountedAnimation[name] == (TrackedReference)null)) { AnimationState val = mountedAnimation[name]; val.speed = ((duration > 0f) ? (val.clip.length / Mathf.Max(0.05f, duration)) : 1f); mountedAnimation.Stop(); mountedAnimation.Play(name); } } private void PlaySequence(AudioSequence sequence, float speed = 1f) { if (sequence != null && sequence.Steps != null && sequence.Steps.Length != 0) { ((MonoBehaviour)this).StartCoroutine(PlaySequenceRoutine(sequence, Mathf.Max(0.05f, speed))); } } private IEnumerator PlaySequenceRoutine(AudioSequence sequence, float speed) { AudioSequenceStep[] steps = sequence.Steps; foreach (AudioSequenceStep step in steps) { if (step != null) { if (step.Timer > 0f) { yield return (object)new WaitForSeconds(step.Timer / speed); } AudioClip randomClip = step.GetRandomClip(); if ((Object)(object)randomClip != (Object)null) { AudioSource.PlayClipAtPoint(randomClip, MuzzlePosition, sequence.Volume * step.Volume); } } } } private void PlayFire(DroneData data) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) recoilUntil = Time.time + 0.12f; string name = ((data.ammo == 0 && hasLastFire) ? "FireLast" : "Fire"); PlayAnimation(name); if ((Object)(object)mountedFireParticle != (Object)null) { mountedFireParticle.Play(); } if ((Object)(object)mountedBarrel != (Object)null && !string.IsNullOrEmpty(mountedBarrel.GetFireSound())) { AudioManager.PlayRandomClipAt(mountedBarrel.GetFireSound(), 1, Mathf.Max(1, mountedBarrel.FireSoundCount), MuzzlePosition, false, (AudioDistance)(mountedBarrel.UseMediumSoundDistance ? 2 : 3), mountedBarrel.FireSoundVolume, 0.1f); } PlaySequence((data.ammo == 0 && fireLastSequence != null) ? fireLastSequence : fireSequence); } private void PlayReload(DroneData data, Gun gun) { float num = Rules.ReloadSeconds(gun.reload, data.level); reloadStarted = Time.time; reloadUntil = Time.time + num; string text = ((data.ammo == 0 && hasLastReload) ? "ReloadLast" : "Reload"); proceduralReload = (Object)(object)mountedAnimation == (Object)null || (TrackedReference)(object)mountedAnimation[text] == (TrackedReference)null; PlayAnimation(text, num); PlaySequence((data.ammo == 0 && reloadLastSequence != null) ? reloadLastSequence : reloadSequence, gun.reload / Mathf.Max(0.05f, num)); } public Mesh InventoryMesh() { //IL_0031: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown MeshFilter[] source = (from f in ((Component)this).GetComponentsInChildren(true) where ((Component)f).GetComponent().enabled select f).ToArray(); Mesh val = new Mesh { name = "DroneMod inventory mesh" }; val.CombineMeshes(source.Select(delegate(MeshFilter f) { //IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) CombineInstance result = default(CombineInstance); ((CombineInstance)(ref result)).mesh = f.sharedMesh; ((CombineInstance)(ref result)).transform = ((Component)this).transform.worldToLocalMatrix * ((Component)f).transform.localToWorldMatrix; return result; }).ToArray()); return val; } private void Awake() { item = ((Component)this).GetComponent(); head = ((Component)this).transform.Find("DroneModHead"); if ((Object)(object)head != (Object)null) { aimPivot = head.Find("DroneModGunAimPivot"); socket = (((Object)(object)aimPivot == (Object)null) ? head.Find("WeaponSocket") : aimPivot.Find("WeaponSocket")); } propellers.Clear(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "Propeller") { propellers.Add(val); } } SetupDroneAudio(); } private AudioSource NewDroneSource(string sourceName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(sourceName); val.transform.SetParent(((Component)this).transform, false); AudioSource obj = val.AddComponent(); obj.playOnAwake = false; obj.loop = false; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)0; obj.minDistance = 1.5f; obj.maxDistance = 18f; obj.dopplerLevel = 0.15f; return obj; } private void SetupDroneAudio() { if (!((Object)(object)startupSource != (Object)null)) { startupSource = NewDroneSource("Drone startup audio"); humA = NewDroneSource("Drone hum A"); humB = NewDroneSource("Drone hum B"); humFilterA = ((Component)humA).gameObject.AddComponent(); humFilterB = ((Component)humB).gameObject.AddComponent(); AudioLowPassFilter obj = humFilterA; bool enabled = (((Behaviour)humFilterB).enabled = false); ((Behaviour)obj).enabled = enabled; } } private void StartHum(float volume) { AudioClip hum = DroneSounds.Hum; if (!((Object)(object)hum == (Object)null) && !humRunning) { activeHum = 0; humA.clip = hum; humB.clip = hum; humA.volume = 0f; humB.volume = 0f; humA.Play(); humRunning = true; humCrossfading = false; humFadeStart = Time.time; humCrossfadeAt = Time.time + Mathf.Max(0.3f, hum.length - 0.25f); } } private void UpdateDroneAudio(DroneData data, bool flying) { SetupDroneAudio(); bool flag = (Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.IsFpvDrone(data.serial); float num = (flag ? 0.024f : 0.08f); float num2 = (flag ? 1150f : 5000f); AudioLowPassFilter obj = humFilterA; bool enabled = (((Behaviour)humFilterB).enabled = flag); ((Behaviour)obj).enabled = enabled; AudioLowPassFilter obj2 = humFilterA; float cutoffFrequency = (humFilterB.cutoffFrequency = num2); obj2.cutoffFrequency = cutoffFrequency; if (lastActivation == int.MinValue) { lastActivation = data.activations; } else if (data.activations != lastActivation) { lastActivation = data.activations; launchVisualUntil = Time.time + 0.75f; pendingStartup = flying; humA.Stop(); humB.Stop(); humRunning = false; } if (pendingStartup && flying && (Object)(object)DroneSounds.Startup != (Object)null) { pendingStartup = false; startupSource.clip = DroneSounds.Startup; startupSource.volume = 0.21f; startupSource.Play(); humAllowedAt = Time.time + Mathf.Max(0.1f, DroneSounds.Startup.length - 0.22f); } if (flying && !wasFlying && humAllowedAt <= 0f) { humAllowedAt = Time.time; } wasFlying = flying; if (!flying) { humA.volume = Mathf.MoveTowards(humA.volume, 0f, Time.deltaTime * 0.65f); humB.volume = Mathf.MoveTowards(humB.volume, 0f, Time.deltaTime * 0.65f); if (humA.volume <= 0.001f && humB.volume <= 0.001f) { humA.Stop(); humB.Stop(); humRunning = false; } return; } if (!humRunning && Time.time >= humAllowedAt) { StartHum(num); } if (!humRunning) { return; } AudioSource val = ((activeHum == 0) ? humA : humB); AudioSource val2 = ((activeHum == 0) ? humB : humA); if (!humCrossfading && Time.time >= humCrossfadeAt) { val2.time = 0f; val2.volume = 0f; val2.Play(); humFadeStart = Time.time; humCrossfading = true; } if (humCrossfading) { float num4 = Mathf.Clamp01((Time.time - humFadeStart) / 0.25f); val.volume = num * (1f - num4); val2.volume = num * num4; if (num4 >= 1f) { val.Stop(); activeHum = 1 - activeHum; humCrossfading = false; humCrossfadeAt = humFadeStart + Mathf.Max(0.3f, DroneSounds.Hum.length - 0.25f); } } else { val.volume = Mathf.MoveTowards(val.volume, num, Time.deltaTime * 0.6f); } } private void AimMountedWeapon(Vector3 direction, float yawDegreesPerSecond, float aimDegreesPerSecond) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00b2: 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_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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f || (Object)(object)head == (Object)null || (Object)(object)aimPivot == (Object)null) { return; } ((Vector3)(ref direction)).Normalize(); Vector3 up = ((Component)this).transform.up; Vector3 val = Vector3.ProjectOnPlane(direction, up); if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.ProjectOnPlane(((Component)this).transform.forward, up); Vector3 normalized = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.0001f) { val2 = Vector3.ProjectOnPlane(Vector3.forward, up); normalized = ((Vector3)(ref val2)).normalized; } float num = Vector3.SignedAngle(normalized, val, up); Quaternion val3 = Quaternion.Euler(0f, num, 0f); head.localRotation = ((yawDegreesPerSecond <= 0f) ? val3 : Quaternion.RotateTowards(head.localRotation, val3, yawDegreesPerSecond * Time.deltaTime)); } Quaternion val5; if ((Object)(object)mountedMuzzle != (Object)null) { Quaternion val4 = Quaternion.Inverse(aimPivot.rotation) * mountedMuzzle.rotation; val5 = Quaternion.LookRotation(direction, -up) * Quaternion.Inverse(val4); } else { val5 = Quaternion.LookRotation(direction, -up); } aimPivot.rotation = ((aimDegreesPerSecond <= 0f) ? val5 : Quaternion.RotateTowards(aimPivot.rotation, val5, aimDegreesPerSecond * Time.deltaTime)); } private void LateUpdate() { //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a3: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: 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_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0813: Unknown result type (might be due to invalid IL or missing references) //IL_0829: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_0719: Unknown result type (might be due to invalid IL or missing references) //IL_071e: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) //IL_0762: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0770: Unknown result type (might be due to invalid IL or missing references) //IL_0775: Unknown result type (might be due to invalid IL or missing references) //IL_0777: Unknown result type (might be due to invalid IL or missing references) //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_0733: Unknown result type (might be due to invalid IL or missing references) //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_0672: Unknown result type (might be due to invalid IL or missing references) //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: 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_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_086c: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_08a7: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a1a: Unknown result type (might be due to invalid IL or missing references) //IL_099d: Unknown result type (might be due to invalid IL or missing references) //IL_09a4: Expected O, but got Unknown //IL_08f2: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Unknown result type (might be due to invalid IL or missing references) //IL_08e0: Unknown result type (might be due to invalid IL or missing references) //IL_08e5: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_08fc: Unknown result type (might be due to invalid IL or missing references) //IL_0901: Unknown result type (might be due to invalid IL or missing references) //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_0918: Unknown result type (might be due to invalid IL or missing references) //IL_091d: Unknown result type (might be due to invalid IL or missing references) //IL_094c: Unknown result type (might be due to invalid IL or missing references) //IL_0951: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0b38: Unknown result type (might be due to invalid IL or missing references) //IL_0b4a: Unknown result type (might be due to invalid IL or missing references) //IL_0acd: Unknown result type (might be due to invalid IL or missing references) //IL_0ad4: Expected O, but got Unknown //IL_0b80: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || (Object)(object)Plugin.Instance == (Object)null || (Object)(object)head == (Object)null) { return; } DroneData droneData = Plugin.Instance.Find(Kit.Serial(item)); if (droneData == null) { return; } bool flag = droneData.deployed && (Object)(object)item.SyncedHolder == (Object)null; RefreshColors(droneData); if (flag) { foreach (Transform propeller in propellers) { if ((Object)(object)propeller != (Object)null) { propeller.Rotate(0f, 1080f * Time.deltaTime, 0f, (Space)1); } } } UpdateDroneAudio(droneData, flag); if (AccessTools.Field(typeof(Item), "_worldColliders").GetValue(item) is Collider[] array) { Collider[] array2 = array; foreach (Collider val in array2) { if ((Object)(object)val != (Object)null) { val.enabled = !droneData.deployed; } } } Vector3 val2; if (droneData.deployed && (Object)(object)item.SyncedHolder == (Object)null) { item.ReconcileLocalHolderWithSyncedHolder(); item.RigidbodySync.SetKinematic(true); if ((Object)(object)item.Rig != (Object)null) { item.Rig.detectCollisions = false; } Vector3 position = droneData.position; Quaternion rotation = droneData.BaseRotation; Vector3 aimDirection = Vector3.zero; bool flag2 = droneData.mode == 2 && Plugin.Instance.TryGetLocalFpvPose(droneData.serial, out position, out rotation, out aimDirection); localFpvAim = (flag2 ? aimDirection : Vector3.zero); float num = Mathf.Sin(Time.unscaledTime * 1.8f + (float)droneData.serial * 0.71f) * 0.1f; if (droneData.mode == 0) { if (!followTargetReady) { lastFollowAuthoritativePosition = droneData.position; followLastMovedAt = Time.unscaledTime; followTargetReady = true; } else { val2 = droneData.position - lastFollowAuthoritativePosition; if (((Vector3)(ref val2)).sqrMagnitude > 0.0004f) { lastFollowAuthoritativePosition = droneData.position; followLastMovedAt = Time.unscaledTime; } } bool flag3 = Time.unscaledTime - followLastMovedAt > 0.4f; followIdleHoverBlend = Mathf.MoveTowards(followIdleHoverBlend, flag3 ? 1f : 0f, Time.unscaledDeltaTime * 2.5f); position += droneData.BaseRotation * Vector3.up * (num * followIdleHoverBlend); } else { followTargetReady = false; followIdleHoverBlend = Mathf.MoveTowards(followIdleHoverBlend, 0f, Time.unscaledDeltaTime * 4f); if (droneData.mode == 1) { position += droneData.BaseRotation * Vector3.up * num; } } if (displayedPositionReady) { val2 = displayedPosition - position; if (!(((Vector3)(ref val2)).sqrMagnitude > 225f)) { displayedPosition = Vector3.SmoothDamp(displayedPosition, position, ref displayVelocity, (droneData.mode == 2) ? 0.07f : ((droneData.mode == 0) ? 0.14f : 0.24f), 35f, Time.unscaledDeltaTime); float num2 = 1f - Mathf.Exp((0f - ((droneData.mode == 2) ? 12f : 8f)) * Time.unscaledDeltaTime); displayedRotation = Quaternion.Slerp(displayedRotation, rotation, num2); goto IL_0401; } } displayedPosition = position; displayVelocity = Vector3.zero; displayedRotation = rotation; displayedPositionReady = true; goto IL_0401; } displayedPositionReady = false; displayVelocity = Vector3.zero; displayedRotation = Quaternion.identity; displayedMode = int.MinValue; localFpvAim = Vector3.zero; followTargetReady = false; followIdleHoverBlend = 0f; if ((Object)(object)item.Rig != (Object)null) { item.Rig.detectCollisions = true; } head.localRotation = Quaternion.identity; if ((Object)(object)aimPivot != (Object)null) { aimPivot.localRotation = Quaternion.identity; } goto IL_0536; IL_0401: displayedMode = droneData.mode; ((Component)this).transform.SetPositionAndRotation(displayedPosition, displayedRotation); if (Time.time < launchVisualUntil) { float num3 = Mathf.Clamp01((launchVisualUntil - Time.time) / 0.75f); float num4 = num3 * num3 * (3f - 2f * num3); ((Component)this).transform.rotation = Quaternion.Slerp(droneData.BaseRotation, droneData.BaseRotation * Quaternion.Euler(52f, 14f, -30f), num4); } goto IL_0536; IL_0536: int wanted = ((droneData.weapon != null && droneData.weapon.Exists) ? droneData.weapon.ItemID : (-1)); int num5 = WeaponSignature(droneData.weapon); if (wanted != gunId || num5 != gunStateSignature) { gunId = wanted; gunStateSignature = num5; Transform val3 = socket.Find("SocketEmpty"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(wanted < 0); } Gun gun = Plugin.Instance.Guns.FirstOrDefault((Gun g) => ((Item)g.prefab).ID == wanted); BuildMountedGun(gun, droneData.weapon); lastShot = droneData.shots; lastReload = droneData.reloads; lastAcquisition = droneData.acquisition; } if (droneData.deployed && (Object)(object)item.SyncedHolder == (Object)null && droneData.hasTarget && (Object)(object)mountedGun != (Object)null) { Vector3 direction = ((((Vector3)(ref localFpvAim)).sqrMagnitude > 0.5f) ? localFpvAim : (droneData.aim - MuzzlePosition)); if (((Vector3)(ref direction)).sqrMagnitude > 0.01f) { AimMountedWeapon(direction, 0f, 0f); } } else if (droneData.deployed && (Object)(object)item.SyncedHolder == (Object)null && (Object)(object)mountedGun != (Object)null) { float num6 = Mathf.Repeat(Time.time * 12f + (float)droneData.serial * 47f, 360f); Vector3 up = ((Component)this).transform.up; val2 = Vector3.ProjectOnPlane(((Component)this).transform.forward, up); Vector3 normalized = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.01f) { val2 = Vector3.ProjectOnPlane(Vector3.forward, up); normalized = ((Vector3)(ref val2)).normalized; } Vector3 val4 = Quaternion.AngleAxis(num6, up) * normalized; val2 = Vector3.Cross(up, val4); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; Vector3 direction2 = Quaternion.AngleAxis(-30f, normalized2) * val4; AimMountedWeapon(direction2, 20f, 45f); } else { head.localRotation = Quaternion.RotateTowards(head.localRotation, Quaternion.identity, 90f * Time.deltaTime); if ((Object)(object)aimPivot != (Object)null) { aimPivot.localRotation = Quaternion.RotateTowards(aimPivot.localRotation, Quaternion.identity, 90f * Time.deltaTime); } } if ((Object)(object)mountedGun != (Object)null) { mountedGun.transform.localPosition = mountedBasePosition; mountedGun.transform.localRotation = mountedBaseRotation; if (proceduralReload && Time.time < reloadUntil) { float num7 = Mathf.InverseLerp(reloadStarted, reloadUntil, Time.time); mountedGun.transform.localRotation = mountedBaseRotation * Quaternion.Euler(Mathf.Sin(num7 * (float)Math.PI) * 32f, 0f, Mathf.Sin(num7 * (float)Math.PI * 2f) * 8f); } else if (Time.time < recoilUntil) { val2 = socket.InverseTransformDirection(((Object)(object)mountedMuzzle != (Object)null) ? (-mountedMuzzle.forward) : (-head.forward)); Vector3 normalized3 = ((Vector3)(ref val2)).normalized; mountedGun.transform.localPosition = mountedBasePosition + normalized3 * (Mathf.Sin(Mathf.InverseLerp(recoilUntil - 0.12f, recoilUntil, Time.time) * (float)Math.PI) * 0.07f); } } if (droneData.shots != lastShot) { lastShot = droneData.shots; if (droneData.deployed) { PlayFire(droneData); if ((Object)(object)tracer == (Object)null) { GameObject val5 = new GameObject("DroneMod tracer"); val5.transform.SetParent(((Component)this).transform, false); tracer = val5.AddComponent(); ((Renderer)tracer).sharedMaterial = glow; tracer.startWidth = 0.025f; tracer.endWidth = 0.009f; tracer.positionCount = 2; } tracer.SetPosition(0, MuzzlePosition); tracer.SetPosition(1, droneData.shotAim); ((Renderer)tracer).enabled = true; tracerUntil = Time.time + 0.09f; } } if (droneData.reloads != lastReload) { lastReload = droneData.reloads; Gun gun2 = Plugin.Instance.GetGun(droneData); if (droneData.deployed && gun2 != null) { PlayReload(droneData, gun2); } } if ((Object)(object)tracer != (Object)null && Time.time > tracerUntil) { ((Renderer)tracer).enabled = false; } if (droneData.deployed && droneData.acquiring) { if ((Object)(object)lockLaser == (Object)null) { GameObject val6 = new GameObject("DroneMod target lock laser"); val6.transform.SetParent(((Component)this).transform, false); lockLaser = val6.AddComponent(); ((Renderer)lockLaser).sharedMaterial = lockGlow; lockLaser.startWidth = 0.018f; lockLaser.endWidth = 0.008f; lockLaser.positionCount = 2; } lockLaser.SetPosition(0, MuzzlePosition); lockLaser.SetPosition(1, droneData.aim); ((Renderer)lockLaser).enabled = true; if (droneData.acquisition != lastAcquisition) { lastAcquisition = droneData.acquisition; TargetSound.Play(((Component)this).transform.position); } } else if ((Object)(object)lockLaser != (Object)null) { ((Renderer)lockLaser).enabled = false; } } } [BepInPlugin("ponyfisher.howtofish.dronemod", "Drone Mod", "0.1.17")] [DefaultExecutionOrder(29000)] public sealed class Plugin : BaseUnityPlugin { private sealed class HiddenHud { public CanvasGroup group; public float alpha; public bool interactable; public bool blocks; public bool added; } private sealed class PlayerRendererState { public Renderer renderer; public bool enabled; public bool forceRenderingOff; } public const string Guid = "ponyfisher.howtofish.dronemod"; public static Plugin Instance; public List Guns = new List(); public List Current = new List(); public bool Open; public string Status = "Load a game, then buy an empty drone kit."; public int Selected; private SaveData save = new SaveData(); private WorldData world; private NetworkManager manager; private Harmony harmony; private string savePath; private bool persistenceReady = true; private bool registrationFailed; private bool catalogReady; private float nextTick; private float nextSave; private float nextState; private float nextHello; private int sequence; private readonly Dictionary lastSequence = new Dictionary(); private readonly Dictionary rateLimit = new Dictionary(); private readonly Dictionary kits = new Dictionary(); private readonly Dictionary followOwners = new Dictionary(); private readonly HashSet playedModeSounds = new HashSet(); private int fpvSerial; private int pendingFpvSerial; private float fpvYaw; private float fpvPitch; private float nextFpvSend; private float fpvRequestUntil; private float fpvBaseFov; private float fpvZoomVelocity; private float fpvTurretHoldStart; private Vector3 fpvPosition; private Vector3 fpvMoveVelocity; private bool fpvPending; private bool fpvTurretHolding; private Camera fpvCamera; private Camera playerCamera; private GameObject fpvCameraObject; private bool playerCameraEnabled; private GUIStyle fpvHelpStyle; private GUIStyle fpvRecStyle; private readonly List hiddenHud = new List(); private readonly List fpvPlayerRenderers = new List(); private Rect panel = new Rect(40f, 60f, 730f, 640f); private Vector2 droneScroll; private Vector2 gunScroll; private bool socketOpen; private string nameDraft = ""; private string confirmAction = ""; private int nameSerial; private int activeTab; private Vector3 bodyDraft; private Vector3 propellerDraft; private Vector3 accentDraft; private float distanceDraft; private CursorLockMode oldLock; private GUIStyle titleStyle; private GUIStyle bodyStyle; private GUIStyle slotStyle; private GUIStyle windowStyle; private GUIStyle buttonStyle; private GUIStyle accentButton; private GUIStyle recallButtonStyle; private GUIStyle dangerButton; private GUIStyle selectedButton; private GUIStyle inputStyle; private GUIStyle headerStyle; private GUIStyle statusStyle; private GUIStyle toggleStyle; private Texture2D steel; private Texture2D steelInset; private Texture2D steelEdge; private Texture2D cyan; private Texture2D cyanHover; private Texture2D orange; private Texture2D orangeHover; private Texture2D red; private Texture2D redHover; private float holdStart; private int holdSerial; private bool holdFired; private string holdAction; private GUIStyle droneLabelStyle; private bool audited; private float auditAfter; private readonly Dictionary missingSince = new Dictionary(); public bool FpvActive { get; private set; } public bool FreeCam { get; private set; } public static void Log(string text) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)text); } } public bool IsFpvDrone(int serial) { if (FpvActive) { return fpvSerial == serial; } return false; } private void Awake() { //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown Instance = this; savePath = Path.Combine(Paths.ConfigPath, "DroneMod-worlds.json"); try { if (File.Exists(savePath)) { save = Codec.FromJson(File.ReadAllText(savePath)); if (save == null || save.version != 1 || save.worlds == null) { throw new Exception("Unrecognized save format"); } } } catch (Exception ex) { persistenceReady = false; Status = "Drone Mod save could not be read. Purchases disabled to protect it."; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } GenericWriter.SetWrite((Action)delegate(Writer w, RequestMessage v) { w.WriteString(v.json); }); GenericReader.SetRead((Func)((Reader r) => new RequestMessage { json = r.ReadStringAllocated() })); GenericWriter.SetWrite((Action)delegate(Writer w, StateMessage v) { w.WriteString(v.json); }); GenericReader.SetRead((Func)((Reader r) => new StateMessage { json = r.ReadStringAllocated() })); GenericWriter.SetWrite((Action)delegate(Writer w, ReplyMessage v) { w.WriteString(v.json); }); GenericReader.SetRead((Func)((Reader r) => new ReplyMessage { json = r.ReadStringAllocated() })); GenericWriter.SetWrite((Action)delegate(Writer w, HitFeedbackMessage v) { w.WriteString(v.json); }); GenericReader.SetRead((Func)((Reader r) => new HitFeedbackMessage { json = r.ReadStringAllocated() })); GenericWriter.SetWrite((Action)delegate(Writer w, ModeSoundMessage v) { w.WriteString(v.json); }); GenericReader.SetRead((Func)((Reader r) => new ModeSoundMessage { json = r.ReadStringAllocated() })); harmony = new Harmony("ponyfisher.howtofish.dronemod"); harmony.PatchAll(typeof(Plugin).Assembly); ((MonoBehaviour)this).StartCoroutine(DroneSounds.Load()); Log("Drone Mod 0.1.17 loaded. Press F3 to open Drone Control."); } private void Update() { //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f3Key).wasPressedThisFrame && !FpvActive && !fpvPending) { Toggle(!Open); } UpdateLocalDroneControl(); UpdateHoldInteraction(); if ((Object)(object)manager != (Object)(object)InstanceFinder.NetworkManager) { RegisterNetwork(); } if (!registrationFailed && (Object)(object)Kit.Prefab == (Object)null) { try { Kit.Register(); } catch (Exception ex) { registrationFailed = true; Status = "Drone item registration failed; see BepInEx log."; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } if ((Object)(object)Kit.Prefab != (Object)null && !catalogReady) { BuildCatalog(); catalogReady = true; } if (InstanceFinder.IsServerStarted && SaveManager.CurServerSave != null) { string name = SaveManager.CurServerSave.Name; if (world == null || world.name != name) { world = save.worlds.FirstOrDefault((WorldData w) => w.name == name); if (world == null) { world = new WorldData { name = name }; save.worlds.Add(world); } Current = world.drones; audited = false; auditAfter = Time.unscaledTime + 5f; missingSince.Clear(); kits.Clear(); followOwners.Clear(); lastSequence.Clear(); rateLimit.Clear(); bool flag = false; foreach (DroneData item in Current) { if (item.followDefaultsVersion < 1) { item.followPosition = 2; item.followDistance = 3f; item.followDefaultsVersion = 1; flag = true; } item.nextShot = Time.time + 1f; item.reloading = false; item.lockedTarget = null; item.acquiring = false; item.hasTarget = false; } if (flag) { Persist(); } } if (Time.unscaledTime >= nextTick) { nextTick = Time.unscaledTime + 0.1f; ServerTick(); } if (Time.unscaledTime >= nextState) { nextState = Time.unscaledTime + (Current.Any((DroneData d) => d.deployed && d.mode == 2) ? 0.05f : 0.2f); Broadcast(); } if (Time.unscaledTime >= nextSave) { nextSave = Time.unscaledTime + 10f; Persist(); } } else if (!InstanceFinder.IsClientStarted) { world = null; Current = new List(); kits.Clear(); followOwners.Clear(); } if (Open && InstanceFinder.IsClientStarted && !InstanceFinder.IsServerStarted && Time.unscaledTime >= nextHello) { nextHello = Time.unscaledTime + 3f; Send("hello"); } } private void LateUpdate() { if (Open) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } UpdateFpvCamera(); } private void RegisterNetwork() { if ((Object)(object)manager != (Object)null) { manager.ServerManager.UnregisterBroadcast((Action)Receive); manager.ClientManager.UnregisterBroadcast((Action)ReceiveState); manager.ClientManager.UnregisterBroadcast((Action)ReceiveReply); manager.ClientManager.UnregisterBroadcast((Action)ReceiveHitFeedback); manager.ClientManager.UnregisterBroadcast((Action)ReceiveModeSound); } manager = InstanceFinder.NetworkManager; if (!((Object)(object)manager == (Object)null)) { manager.ServerManager.RegisterBroadcast((Action)Receive, true); manager.ClientManager.RegisterBroadcast((Action)ReceiveState); manager.ClientManager.RegisterBroadcast((Action)ReceiveReply); manager.ClientManager.RegisterBroadcast((Action)ReceiveHitFeedback); manager.ClientManager.RegisterBroadcast((Action)ReceiveModeSound); } } private static float ReadReload(Weapon weapon, GunClass kind) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Animation val = (Animation)AccessTools.Field(typeof(Tool), "_anim").GetValue(weapon); bool flag = (bool)AccessTools.Field(typeof(Weapon), "_hasLastReloadAnim").GetValue(weapon); AnimationState val2 = (((Object)(object)val == (Object)null) ? null : val[flag ? "ReloadLast" : "Reload"]); if ((TrackedReference)(object)val2 != (TrackedReference)null && val2.length > 0f) { return val2.length / Mathf.Max(0.01f, Mathf.Abs(val2.speed)); } Log("Missing reload animation for " + ((Object)weapon).name + "; using fallback timing."); return Rules.Reload(kind, 0); } private void BuildCatalog() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown Dictionary obj = (Dictionary)AccessTools.Field(typeof(GameInfo), "_idToSpawnable").GetValue(null); Guns.Clear(); foreach (Weapon item in from w in obj.Values.OfType() orderby ((Item)w).Cost select w) { WeaponInfo val = (WeaponInfo)AccessTools.Field(typeof(Weapon), "_weaponInfo").GetValue(item); if (val != null) { GunClass kind = Rules.Classify(((Object)item).name); int pellets = (int)AccessTools.Field(typeof(Weapon), "_projectileCountPerShot").GetValue(item); if (pellets > 1) { kind = GunClass.Shotgun; } else if ((Object)(object)item.Attachments != (Object)null && item.Attachments.UseSniperUi) { kind = GunClass.Sniper; } BulletUpgrade[] array = (BulletUpgrade[])AccessTools.Field(typeof(Attachments), "_bulletUpgrades").GetValue(item.Attachments); int val2 = (int)AccessTools.Field(typeof(Attachments), "_defaultAmmoPerMag").GetValue(item.Attachments); int val3 = (int)AccessTools.Field(typeof(Attachments), "_extendedAmmoPerMag").GetValue(item.Attachments); Guns.Add(new Gun { prefab = item, name = ((Object)item).name.Replace("(Clone)", ""), kind = kind, damage = Math.Max(1, val.ProjectileDamage) * Math.Max(1, pellets), ammoDamages = array?.Select((BulletUpgrade x) => Math.Max(1, x.Damage) * Math.Max(1, pellets)).ToArray(), price = Math.Max(250, ((Item)item).Cost), magazine = Math.Max(1, val2), extendedMagazine = Math.Max(Math.Max(1, val2), val3), reload = ReadReload(item, kind) }); } } foreach (Gun gun in Guns) { Log("Gun " + gun.name + ": " + gun.kind.ToString() + ", range=" + Rules.Radius(gun.kind, 0) + ", magazine=" + gun.magazine + ", reload=" + gun.reload); } Log("Loaded " + Guns.Count + " socketable base-game guns."); } public DroneData Find(int id) { return Current.FirstOrDefault((DroneData t) => t.serial == id); } public Gun GetGun(DroneData t) { if (t.weapon != null) { return Guns.FirstOrDefault((Gun g) => ((Item)g.prefab).ID == t.weapon.ItemID); } return null; } public void Persist() { if (!persistenceReady || !InstanceFinder.IsServerStarted || world == null) { return; } try { string text = savePath + ".tmp"; File.WriteAllText(text, Codec.ToJson(save, pretty: true)); if (File.Exists(savePath)) { File.Replace(text, savePath, savePath + ".bak"); } else { File.Move(text, savePath); } } catch (Exception ex) { persistenceReady = false; Status = "Drone Mod could not save; purchases paused. Check disk access."; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } public void Send(string action, int argument = 0, Vector3 position = default(Vector3), string text = null, Vector3 normal = default(Vector3)) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.LocalPlayer == (Object)null) { Status = "Load a game first."; return; } Command command = new Command { action = action, serial = Selected, argument = argument, position = position, normal = normal, text = text, sequence = ++sequence }; if (InstanceFinder.IsServerStarted) { Execute(Player.LocalPlayer, command, null); } else if ((Object)(object)manager != (Object)null && InstanceFinder.IsClientStarted) { manager.ClientManager.Broadcast(new RequestMessage { json = Codec.ToJson(command) }, (Channel)0); if (action != "hello") { Status = "Waiting for the host..."; } } } private void Receive(NetworkConnection connection, RequestMessage message, Channel channel) { if (!InstanceFinder.IsServerStarted || message.json == null || message.json.Length > 1024) { return; } try { Command command = Codec.FromJson(message.json); if (command != null && command.protocol == 4 && command.sequence > 0 && (!lastSequence.TryGetValue(connection.ClientId, out var value) || command.sequence > value) && (!rateLimit.TryGetValue(connection.ClientId, out var value2) || !(Time.unscaledTime - value2 < 0.03f))) { lastSequence[connection.ClientId] = command.sequence; rateLimit[connection.ClientId] = Time.unscaledTime; Player val = ((IEnumerable)Object.FindObjectsByType()).FirstOrDefault((Func)((Player p) => ((NetworkBehaviour)p).Owner == connection)); if ((Object)(object)val != (Object)null) { Execute(val, command, connection); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Rejected DroneMod request: " + ex.Message)); } } private void Respond(Command cmd, NetworkConnection connection, string message, int selected = 0) { Reply value = new Reply { sequence = cmd.sequence, serial = selected, message = message }; if (connection == (NetworkConnection)null || connection.IsLocalClient) { Status = message; if (selected > 0) { Selected = selected; } } else { manager.ServerManager.Broadcast(connection, new ReplyMessage { json = Codec.ToJson(value) }, true, (Channel)0); } } private void ReceiveReply(ReplyMessage message, Channel channel) { Reply reply = Codec.FromJson(message.json); Status = reply.message; if (reply.serial > 0) { Selected = reply.serial; } } private void ReceiveState(StateMessage message, Channel channel) { if (InstanceFinder.IsServerStarted || message.json == null || message.json.Length > 200000) { return; } Snapshot snapshot = Codec.FromJson(message.json); if (snapshot == null || snapshot.protocol != 4 || snapshot.drones == null) { return; } Current = snapshot.drones; foreach (DroneData item in Current) { ApplyColorsNow(item); } } private void Broadcast() { if ((Object)(object)manager != (Object)null && world != null) { manager.ServerManager.Broadcast(new StateMessage { json = Codec.ToJson(new Snapshot { world = world.name, drones = Current }) }, true, (Channel)0); } } private void ScanKits() { kits.Clear(); Item[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (Item val in array) { if (Kit.Is(val) && ((NetworkBehaviour)val).IsSpawned && !((NetworkBehaviour)val).IsDeinitializing) { int num = Kit.Serial(val); if (num > 0 && !kits.ContainsKey(num)) { kits.Add(num, val); } } } } private Item FindKit(int serial) { if (kits.TryGetValue(serial, out var value) && (Object)(object)value != (Object)null && ((NetworkBehaviour)value).IsSpawned && !((NetworkBehaviour)value).IsDeinitializing) { return value; } value = ((IEnumerable)Object.FindObjectsByType((FindObjectsInactive)1)).FirstOrDefault((Func)((Item candidate) => Kit.Is(candidate) && ((NetworkBehaviour)candidate).IsSpawned && !((NetworkBehaviour)candidate).IsDeinitializing && Kit.Serial(candidate) == serial)); if ((Object)(object)value != (Object)null) { kits[serial] = value; } return value; } private void ReceiveHitFeedback(HitFeedbackMessage message, Channel channel) { HitFeedback hitFeedback = Codec.FromJson(message.json); if (hitFeedback != null) { ShowHitFeedback(hitFeedback); } } private void ShowHitFeedback(HitFeedback feedback) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) PlayerUI.AddHitMarker(feedback.position, feedback.killed); PlayerUI.AddDamageNumber(feedback.position, feedback.damage, feedback.killed); if (feedback.killed && (Object)(object)Player.LocalPlayer != (Object)null && (Object)(object)Player.LocalPlayer.KillScore != (Object)null) { Player.LocalPlayer.KillScore.AddKillScore(feedback.creatureName, feedback.worth, new List()); PlayerSkills.OnKill(1); } } private void SendHitFeedback(Player owner, Creature creature, Vector3 position, int damage, bool killed, int worth) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)owner == (Object)null) && !((Object)(object)creature == (Object)null)) { HitFeedback hitFeedback = new HitFeedback { position = position, damage = damage, killed = killed, worth = Mathf.Max(0, worth), creatureName = ((Item)creature).GetName() }; if (((NetworkBehaviour)owner).Owner.IsLocalClient) { ShowHitFeedback(hitFeedback); } else if ((Object)(object)manager != (Object)null) { manager.ServerManager.Broadcast(((NetworkBehaviour)owner).Owner, new HitFeedbackMessage { json = Codec.ToJson(hitFeedback) }, true, (Channel)0); } } } private void ReceiveModeSound(ModeSoundMessage message, Channel channel) { ModeSoundEvent modeSoundEvent = Codec.FromJson(message.json); if (modeSoundEvent != null) { PlayModeSound(modeSoundEvent); } } private void PlayModeSound(ModeSoundEvent cue) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (cue != null) { if (playedModeSounds.Count > 256) { playedModeSounds.Clear(); } string item = cue.serial + ":" + cue.eventId; if (playedModeSounds.Add(item)) { ((MonoBehaviour)this).StartCoroutine(PlayModeSoundWhenReady(cue.mode, cue.position)); } } } private IEnumerator PlayModeSoundWhenReady(int mode, Vector3 position) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float until = Time.unscaledTime + 5f; AudioClip val = DroneSounds.Mode(mode); while ((Object)(object)val == (Object)null && Time.unscaledTime < until) { yield return null; val = DroneSounds.Mode(mode); } if ((Object)(object)val != (Object)null) { AudioSource.PlayClipAtPoint(val, position, 0.3f); } else { Log("Mode announcement was requested before its audio finished loading."); } } private void BroadcastModeSound(DroneData drone) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (drone != null) { ModeSoundEvent modeSoundEvent = new ModeSoundEvent { serial = drone.serial, mode = drone.mode, eventId = drone.modeChanges, position = drone.position }; PlayModeSound(modeSoundEvent); if ((Object)(object)manager != (Object)null) { manager.ServerManager.Broadcast(new ModeSoundMessage { json = Codec.ToJson(modeSoundEvent) }, true, (Channel)0); } } } private void ApplyColorsNow(DroneData drone) { if (drone == null) { return; } KitVisual[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (KitVisual kitVisual in array) { if (!((Object)(object)kitVisual == (Object)null)) { Item component = ((Component)kitVisual).GetComponent(); if ((Object)(object)component != (Object)null && Kit.Serial(component) == drone.serial) { kitVisual.RefreshColors(drone); } } } } private Player ResolveFollowOwner(DroneData drone, Player[] players) { if (followOwners.TryGetValue(drone.serial, out var value) && (Object)(object)value != (Object)null && ((Component)value).gameObject.activeInHierarchy && value.SteamID == drone.owner) { return value; } Player[] source = players.Where((Player p) => (Object)(object)p != (Object)null && ((Component)p).gameObject.activeInHierarchy && p.SteamID == drone.owner).ToArray(); Player val = ((IEnumerable)source).FirstOrDefault((Func)((Player p) => (Object)(object)p == (Object)(object)Player.LocalPlayer)) ?? source.OrderBy((Player p) => Vector3.Distance(LivePlayerPosition(p), drone.position)).FirstOrDefault(); if ((Object)(object)val != (Object)null) { followOwners[drone.serial] = val; } return val; } private Vector3 LivePlayerPosition(Player player) { //IL_0049: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { if (!((Object)(object)player.Transform != (Object)null)) { if (!((Object)(object)player.Rigidbody != (Object)null)) { return ((Component)player).transform.position; } return player.Rigidbody.position; } return player.Transform.position; } return Vector3.zero; } public float ManagementDistance(DroneData drone, Player player) { //IL_0036: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_00b0: 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_00d9: 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) if (drone == null || (Object)(object)player == (Object)null) { return float.PositiveInfinity; } Item val = FindKit(drone.serial); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : drone.position); Vector3 val3 = LivePlayerPosition(player); float num = Vector3.Distance(val3, val2); if ((Object)(object)player.CamObject != (Object)null) { num = Mathf.Min(num, Vector3.Distance(player.CamObject.position, val2)); } if ((Object)(object)val != (Object)null) { Collider[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Collider val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)null) && val4.enabled && !val4.isTrigger) { num = Mathf.Min(num, Vector3.Distance(val3, val4.ClosestPoint(val3))); if ((Object)(object)player.CamObject != (Object)null) { num = Mathf.Min(num, Vector3.Distance(player.CamObject.position, val4.ClosestPoint(player.CamObject.position))); } } } } return num; } private int OpenSlot(Player p) { int num = (int)AccessTools.Method(typeof(PlayerInventory), "GetTotalSlots", (Type[])null, (Type[])null).Invoke(p.Inventory, null); Item val = default(Item); for (byte b = 0; b < num; b++) { if (!p.Inventory._items.TryGetValue(b, ref val) || (Object)(object)val == (Object)null) { return b; } } return -1; } private Item SpawnForInventory(Item prefab, Player player, int slot, SavedItem data = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Item val = Object.Instantiate(prefab, LivePlayerPosition(player) + Vector3.up, Quaternion.identity, Server.Instance.DynamicObjectsHolder); if (data != null) { val.LoadFromSave(data); } InstanceFinder.ServerManager.Spawn(((Component)val).gameObject, (NetworkConnection)null, default(Scene)); if (data != null) { val.ServerSetSkin(data.SkinIndex); } val.SetSyncedHolder(player, true); player.Inventory.AddItem((byte)slot, val); if (!player.Inventory.HasItemInInventory(val)) { InstanceFinder.ServerManager.Despawn(((Component)val).gameObject, (DespawnType?)null); throw new Exception("The inventory did not accept the item; nothing was charged."); } return val; } private Vector3 FollowCenter(Player owner) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Vector3 val = LivePlayerPosition(owner); Vector3 val2 = val; val2.y = val.y + 3f; if ((Object)(object)owner.CamObject != (Object)null) { val2.y = Mathf.Max(val2.y, owner.CamObject.position.y + 1.25f); } return val2; } private Vector3 FollowPoint(DroneData drone, Player owner) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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) Vector3 val = FollowCenter(owner); Vector3 val2 = (((Object)(object)owner.CamObject != (Object)null) ? Vector3.ProjectOnPlane(owner.CamObject.forward, Vector3.up) : Vector3.ProjectOnPlane(owner.CurPlayerRot * Vector3.forward, Vector3.up)); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.Cross(Vector3.up, val2); Vector3 normalized = ((Vector3)(ref val3)).normalized; val3 = val2 + normalized; Vector3 normalized2 = ((Vector3)(ref val3)).normalized; return val + normalized2 * Mathf.Min(3f, Rules.FollowDistance(drone.followDistance)); } private float PlayerSafetyHeight(Player owner) { //IL_0002: 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) float num = LivePlayerPosition(owner).y; if ((Object)(object)owner.CamObject != (Object)null) { num = Mathf.Max(num, owner.CamObject.position.y - 2f); } return num; } private unsafe void ResetFollowDrone(DroneData drone, Item item, Vector3 target, string reason) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) drone.position = target; drone.followVelocity = Vector3.zero; drone.followStuckSince = 0f; drone.lastObservedFollowPosition = target; drone.hasObservedFollowPosition = true; drone.leashReturning = false; drone.surfaceNormal = Vector3.up; ((Component)item).gameObject.SetActive(true); item.RigidbodySync.ServerSetSyncedSimulator(((NetworkBehaviour)Server.Instance).Owner); if ((Object)(object)item.Rig != (Object)null) { if (!item.Rig.isKinematic) { item.Rig.linearVelocity = Vector3.zero; item.Rig.angularVelocity = Vector3.zero; } item.Rig.detectCollisions = false; } item.RigidbodySync.SetKinematic(true); if ((Object)(object)item.Rig != (Object)null) { item.Rig.position = target; item.Rig.rotation = drone.BaseRotation; } ((Component)item).transform.SetPositionAndRotation(target, drone.BaseRotation); Physics.SyncTransforms(); Log("Recovered following drone #" + drone.serial + " to " + ((object)(*(Vector3*)(&target))/*cast due to .constrained prefix*/).ToString() + " (" + reason + ")."); } private void ReleaseForFlight(Player player, Item kit) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) kit.SpawnFromInventory(); player.Inventory.RemoveItem(kit); if ((Object)(object)kit.Holder != (Object)null) { kit.Drop(false, default(Vector3), default(Vector3)); } kit.SetSyncedHolder((Player)null, true); kit.ReconcileLocalHolderWithSyncedHolder(); if ((Object)(object)player.Holding.HeldItem == (Object)(object)kit) { player.Hands.DropItem(false, kit); player.Holding.DropItem(false, kit); player.Holding.SetHeldItem((Item)null); } if ((Object)(object)player.Holding.UninitializedHeldItem == (Object)(object)kit) { player.Holding.SetUninitializedHeldItem((Item)null); } } private bool Ground(Player player, Vector3 requested, Vector3 requestedNormal, Item kit, out RaycastHit hit, out string reason) { //IL_0010: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_005f: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_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_00ae: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) hit = default(RaycastHit); reason = "Look at a supported surface within 8 metres."; if (!Rules.Finite(requested.x) || !Rules.Finite(requested.y) || !Rules.Finite(requested.z) || !Rules.Finite(requestedNormal.x) || !Rules.Finite(requestedNormal.y) || !Rules.Finite(requestedNormal.z)) { return false; } if (Vector3.Distance(requested, player.CamObject.position) > 8.35f || !Rules.SurfaceAllowed(requestedNormal.y)) { return false; } Vector3 normalized = ((Vector3)(ref requestedNormal)).normalized; foreach (RaycastHit item in from val in Physics.RaycastAll(requested + normalized * 0.35f, -normalized, 0.7f, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref val)).distance select val) { RaycastHit h = item; if (((Component)((RaycastHit)(ref h)).collider).gameObject.layer != LayerMask.NameToLayer("Water") && !((Object)(object)((Component)((RaycastHit)(ref h)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref h)).collider).GetComponentInParent() != (Object)null) && Rules.SurfaceAllowed(((RaycastHit)(ref h)).normal.y) && !(Vector3.Dot(((RaycastHit)(ref h)).normal, normalized) < 0.5f)) { if (Current.Any((DroneData t) => t.deployed && t.serial != Kit.Serial(kit) && Vector3.Distance(t.position, ((RaycastHit)(ref h)).point) < 0.55f)) { reason = "Another drone is too close to that point."; return false; } hit = h; return true; } } return false; } private void Execute(Player player, Command cmd, NetworkConnection connection) { //IL_0182: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_094f: Unknown result type (might be due to invalid IL or missing references) //IL_0954: Unknown result type (might be due to invalid IL or missing references) //IL_0d5b: Unknown result type (might be due to invalid IL or missing references) //IL_0d60: Unknown result type (might be due to invalid IL or missing references) //IL_0ce9: Unknown result type (might be due to invalid IL or missing references) //IL_0ceb: Unknown result type (might be due to invalid IL or missing references) //IL_0b2e: Unknown result type (might be due to invalid IL or missing references) //IL_0b34: Unknown result type (might be due to invalid IL or missing references) //IL_0b38: Unknown result type (might be due to invalid IL or missing references) //IL_0b3e: Unknown result type (might be due to invalid IL or missing references) //IL_098c: Unknown result type (might be due to invalid IL or missing references) //IL_099c: Unknown result type (might be due to invalid IL or missing references) //IL_0d0b: Unknown result type (might be due to invalid IL or missing references) //IL_0d0d: Unknown result type (might be due to invalid IL or missing references) //IL_0d01: Unknown result type (might be due to invalid IL or missing references) //IL_0d03: Unknown result type (might be due to invalid IL or missing references) //IL_1029: Unknown result type (might be due to invalid IL or missing references) //IL_0dd5: Unknown result type (might be due to invalid IL or missing references) //IL_0e24: Unknown result type (might be due to invalid IL or missing references) //IL_0e29: Unknown result type (might be due to invalid IL or missing references) //IL_0f19: Unknown result type (might be due to invalid IL or missing references) //IL_0f24: Unknown result type (might be due to invalid IL or missing references) //IL_0f88: Unknown result type (might be due to invalid IL or missing references) //IL_0f8d: Unknown result type (might be due to invalid IL or missing references) //IL_0f92: Unknown result type (might be due to invalid IL or missing references) //IL_0f97: Unknown result type (might be due to invalid IL or missing references) //IL_0fa0: Unknown result type (might be due to invalid IL or missing references) //IL_0fa5: Unknown result type (might be due to invalid IL or missing references) //IL_0fb4: Unknown result type (might be due to invalid IL or missing references) //IL_0fb9: Unknown result type (might be due to invalid IL or missing references) //IL_0fc0: Unknown result type (might be due to invalid IL or missing references) //IL_0fc5: Unknown result type (might be due to invalid IL or missing references) //IL_0fca: Unknown result type (might be due to invalid IL or missing references) //IL_1232: Unknown result type (might be due to invalid IL or missing references) //IL_1237: Unknown result type (might be due to invalid IL or missing references) //IL_123e: Unknown result type (might be due to invalid IL or missing references) //IL_1250: Unknown result type (might be due to invalid IL or missing references) //IL_125b: Unknown result type (might be due to invalid IL or missing references) //IL_126b: Expected O, but got Unknown //IL_0ff7: Unknown result type (might be due to invalid IL or missing references) if (cmd.action == "hello") { Broadcast(); return; } if (!persistenceReady || world == null || (Object)(object)Kit.Prefab == (Object)null || player.Dying.IsDead) { Respond(cmd, connection, "Drone Mod is not ready. Check the host's mod and save status."); return; } ScanKits(); try { if (cmd.action == "buykit") { int num = OpenSlot(player); if (num < 0) { Respond(cmd, connection, "Free an inventory slot first."); return; } int num2 = Current.Count((DroneData t) => t.available && t.owner == player.SteamID); if (num2 >= 1) { Respond(cmd, connection, "You already own a drone. Each player may own only one."); return; } int num3 = Rules.DronePrice(num2); if (!Wallet.CanAfford(player, num3)) { Respond(cmd, connection, "Not enough money. Your next empty drone costs $" + num3.ToString("N0") + "."); return; } if (save.nextSerial >= 16000000) { throw new Exception("Drone serial limit reached."); } int num4 = save.nextSerial++; Item val = SpawnForInventory(Kit.Prefab, player, num, new SavedItem { Exists = true, ItemID = 248, BettingMultiplier = num4 }); if (!Wallet.Charge(player, num3)) { InstanceFinder.ServerManager.Despawn(((Component)val).gameObject, (DespawnType?)null); Respond(cmd, connection, "Payment failed; purchase cancelled."); return; } Current.Add(new DroneData { serial = num4, owner = player.SteamID, ownerName = player.SteamName, purchasePrice = num3, followPosition = 2, followDistance = 3f, followDefaultsVersion = 1 }); Persist(); Broadcast(); Respond(cmd, connection, "Drone kit purchased for $" + num3.ToString("N0") + " and added to your inventory.", num4); return; } DroneData droneData = Find(cmd.serial); Item val2 = FindKit(cmd.serial); if (droneData == null || (Object)(object)val2 == (Object)null) { Respond(cmd, connection, "That drone is no longer available."); return; } bool flag = (Object)(object)val2.SyncedHolder == (Object)(object)player; bool flag2 = (Object)(object)player.Holding.HeldItem == (Object)(object)val2 || (Object)(object)player.Holding.UninitializedHeldItem == (Object)(object)val2; if (droneData.owner != player.SteamID) { Respond(cmd, connection, "This drone belongs to " + (string.IsNullOrWhiteSpace(droneData.ownerName) ? droneData.owner.ToString() : droneData.ownerName) + " and cannot be used or claimed by another player."); return; } followOwners[droneData.serial] = player; float distance = ManagementDistance(droneData, player); if (cmd.action != "recall" && cmd.action != "recallhands" && cmd.action != "fpv" && cmd.action != "fire" && cmd.action != "mode" && !flag && !Rules.InManagementRange(distance)) { Respond(cmd, connection, "Move within " + 12f.ToString("0") + " metres of the drone, or use Recall."); return; } if (cmd.action == "deploy" || cmd.action == "recall") { Vector3 val3 = FollowPoint(droneData, player); if (flag) { ReleaseForFlight(player, val2); } val2.RigidbodySync.ServerSetSyncedSimulator(((NetworkBehaviour)Server.Instance).Owner); droneData.mode = 0; droneData.surfaceNormal = Vector3.up; Quaternion curPlayerRot = player.CurPlayerRot; droneData.yaw = ((Quaternion)(ref curPlayerRot)).eulerAngles.y; if (cmd.action == "deploy") { droneData.position = val3; droneData.followVelocity = Vector3.zero; droneData.followStuckSince = 0f; droneData.hasObservedFollowPosition = false; droneData.leashReturning = false; droneData.activationUntil = Time.time + 0.75f; droneData.activations++; } else { droneData.position = val3; droneData.followVelocity = Vector3.zero; droneData.leashReturning = false; } droneData.deployed = true; droneData.aim = droneData.position + player.CurPlayerRot * Vector3.forward * 5f + Vector3.up; droneData.shotAim = droneData.aim; droneData.lockedTarget = null; droneData.acquiring = false; droneData.hasTarget = false; Gun gun = GetGun(droneData); droneData.ammo = gun?.Magazine(droneData.weapon) ?? 0; droneData.reloading = false; droneData.nextShot = Time.time; ResetFollowDrone(droneData, val2, val3, (cmd.action == "deploy") ? "live player deployment" : "recall"); droneData.activationUntil = ((cmd.action == "deploy") ? (Time.time + 0.75f) : 0f); Status = ((cmd.action == "recall") ? "Drone recalled to its saved follow position." : "Drone launched in follow mode."); Log("Launched #" + droneData.serial + " at " + ((object)Unsafe.As(ref droneData.position)/*cast due to .constrained prefix*/).ToString() + ", gun=" + ((gun == null) ? "empty" : gun.name) + ", ammo=" + droneData.ammo); } else if (cmd.action == "pickup") { if (flag) { Respond(cmd, connection, "Drone already in your inventory."); return; } int num5 = OpenSlot(player); bool emptyHands = (Object)(object)player.Holding.HeldItem == (Object)null && (Object)(object)player.Holding.UninitializedHeldItem == (Object)null && (Object)(object)player.Inventory.SyncedCurItem == (Object)null; if (!Rules.CanRecall(num5 >= 0, emptyHands)) { Respond(cmd, connection, "Free an inventory slot or empty your hands before recalling this drone."); return; } droneData.deployed = false; droneData.lockedTarget = null; droneData.acquiring = false; droneData.hasTarget = false; val2.RigidbodySync.SetKinematic(false); if ((Object)(object)val2.Rig != (Object)null) { val2.Rig.detectCollisions = true; } int value = player.Inventory._syncedCurSlot.Value; val2.SetSyncedHolder(player, true); if (num5 >= 0) { player.Inventory.AddItem((byte)num5, val2); } val2.ReconcileLocalHolderWithSyncedHolder(); if (num5 >= 0) { player.Inventory.ServerSetSyncedCurSlot(value); } string text = ((num5 >= 0) ? "inventory" : "empty hands"); Status = "Drone stored in your " + text + " with its gun and settings."; } else if (cmd.action == "recallhands") { if (flag2) { Respond(cmd, connection, "The drone is already in your hands."); return; } if (!((Object)(object)player.Holding.HeldItem == (Object)null) || !((Object)(object)player.Holding.UninitializedHeldItem == (Object)null) || !((Object)(object)player.Inventory.SyncedCurItem == (Object)null)) { Respond(cmd, connection, "Empty your hands before using Recall to Hands."); return; } if (flag) { val2.SpawnFromInventory(); player.Inventory.RemoveItem(val2); } droneData.deployed = false; droneData.mode = 0; droneData.lockedTarget = null; droneData.acquiring = false; droneData.hasTarget = false; droneData.reloading = false; droneData.followVelocity = Vector3.zero; droneData.leashReturning = false; val2.RigidbodySync.SetKinematic(false); if ((Object)(object)val2.Rig != (Object)null) { val2.Rig.detectCollisions = true; val2.Rig.linearVelocity = Vector3.zero; val2.Rig.angularVelocity = Vector3.zero; } val2.SetSyncedHolder(player, true); val2.ReconcileLocalHolderWithSyncedHolder(); Status = "Drone recalled directly to your hands with its gun and settings."; } else if (cmd.action == "friendlyfire") { droneData.friendlyFire = cmd.argument == 1; Status = (droneData.friendlyFire ? "Friendly fire enabled." : "Friendly fire disabled."); } else if (cmd.action == "sell") { if (droneData.weapon != null && droneData.weapon.Exists) { Respond(cmd, connection, "Remove the gun before selling the drone."); return; } int amount = Rules.ResaleValue(droneData.purchasePrice, droneData.level, droneData.tier); droneData.deployed = false; droneData.lockedTarget = null; droneData.acquiring = false; droneData.hasTarget = false; Player[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (Player val4 in array) { val4.Inventory.RemoveItem(val2); if ((Object)(object)val4.Holding.HeldItem == (Object)(object)val2) { val4.Hands.DropItem(false, val2); val4.Holding.DropItem(false, val2); val4.Holding.SetHeldItem((Item)null); } if ((Object)(object)val4.Holding.UninitializedHeldItem == (Object)(object)val2) { val4.Holding.SetUninitializedHeldItem((Item)null); } } if ((Object)(object)val2.Holder != (Object)null) { val2.Drop(false, default(Vector3), default(Vector3)); } val2.SpawnFromInventory(); val2.SetSyncedHolder((Player)null, true); val2.ReconcileLocalHolderWithSyncedHolder(); InstanceFinder.ServerManager.Despawn(((Component)val2).gameObject, (DespawnType?)null); Wallet.Credit(player, amount); world.retired.Add(droneData.serial); Current.Remove(droneData); kits.Remove(droneData.serial); Selected = 0; Status = "Drone sold for $" + amount.ToString("N0") + " (half of its kit, upgrade, and targeting-tier investment)."; } else if (cmd.action == "rename") { droneData.customName = Rules.CleanName(cmd.text); Status = "Drone name saved."; } else if (cmd.action == "followdistance") { droneData.followDistance = Rules.FollowDistance(cmd.position.x); Status = "Follow leash radius set to " + droneData.followDistance.ToString("0.0") + " m."; } else if (cmd.action == "color") { Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(Rules.ColorChannel(cmd.position.x), Rules.ColorChannel(cmd.position.y), Rules.ColorChannel(cmd.position.z)); if (cmd.argument == 0) { droneData.bodyColor = val5; } else if (cmd.argument == 1) { droneData.propellerColor = val5; } else { droneData.accentColor = val5; } ApplyColorsNow(droneData); Status = "Drone colors updated."; } else if (cmd.action == "mode") { bool deployed = droneData.deployed; int mode = droneData.mode; Vector3 target = FollowPoint(droneData, player); if (flag) { ReleaseForFlight(player, val2); } val2.RigidbodySync.ServerSetSyncedSimulator(((NetworkBehaviour)Server.Instance).Owner); val2.RigidbodySync.SetKinematic(true); droneData.mode = Mathf.Clamp(cmd.argument, 0, 2); if (deployed && droneData.mode != mode) { droneData.modeChanges++; BroadcastModeSound(droneData); } if (!deployed) { ResetFollowDrone(droneData, val2, target, "mode activation"); } droneData.deployed = true; droneData.lockedTarget = null; droneData.acquiring = false; droneData.hasTarget = false; if (droneData.mode == 0) { droneData.returningFromMode = deployed && mode != 0; droneData.leashReturning = droneData.returningFromMode; droneData.followVelocity = Vector3.zero; } else { droneData.returningFromMode = false; } Status = ((droneData.mode != 0) ? ((droneData.mode == 1) ? "Stationary turret mode engaged." : "FPV flight mode engaged.") : (droneData.returningFromMode ? "Flying smoothly from the current position into the Follow leash." : "Follow leash engaged.")); } else if (cmd.action == "fpv") { if (droneData.mode != 2 || !droneData.deployed || !Rules.Finite(cmd.position.x) || !Rules.Finite(cmd.position.y) || !Rules.Finite(cmd.position.z) || !Rules.Finite(cmd.normal.x) || !Rules.Finite(cmd.normal.y) || Vector3.Distance(droneData.position, cmd.position) > 3f) { return; } float num7 = Mathf.Clamp(cmd.normal.x, -85f, 85f); float num8 = Mathf.Repeat(cmd.normal.y + 180f, 360f) - 180f; Vector3 val6 = Quaternion.Euler(num7, num8, 0f) * Vector3.forward; droneData.position = cmd.position; droneData.yaw = num8; droneData.aim = droneData.position + val6 * 100f; droneData.hasTarget = true; droneData.acquiring = false; if (cmd.argument == 1) { ManualFire(droneData, val2, player, val6); } } else if (cmd.action == "fire") { ManualFire(droneData, val2, player, cmd.normal); } else if (cmd.action == "upgrade") { int num9 = Rules.UpgradePrice(droneData.level); if (num9 == 0) { Respond(cmd, connection, "Maximum upgrade level reached."); return; } if (!Wallet.Charge(player, num9)) { Respond(cmd, connection, "Not enough money for this upgrade."); return; } droneData.level++; Status = "Drone upgraded to level " + droneData.level + " / 10."; } else if (cmd.action == "tier") { int num10 = Rules.TierPrice(droneData.tier); if (num10 == 0) { Respond(cmd, connection, "Boss targeting already unlocked."); return; } if (!Wallet.Charge(player, num10)) { Respond(cmd, connection, "Not enough money for this targeting tier."); return; } droneData.tier++; Status = ((droneData.tier == 1) ? "Fish targeting unlocked; seagulls remain enabled." : "Boss targeting unlocked; all target tiers enabled."); } else if (cmd.action == "buygun") { Gun gun2 = Guns.FirstOrDefault((Gun g) => ((Item)g.prefab).ID == cmd.argument); if (gun2 == null) { return; } if (!Rules.NeedsWeaponPurchase((droneData.weapon != null && droneData.weapon.Exists) ? droneData.weapon.ItemID : (-1), ((Item)gun2.prefab).ID)) { Respond(cmd, connection, gun2.name + " is already equipped. No money was charged.", droneData.serial); return; } if (!Wallet.Charge(player, gun2.price)) { Respond(cmd, connection, "Not enough money for that weapon."); return; } droneData.weapon = new SavedItem { Exists = true, ItemID = ((Item)gun2.prefab).ID, BettingMultiplier = 1f, Weight = 1f }; droneData.ammo = gun2.Magazine(droneData.weapon); droneData.reloading = false; droneData.nextShot = Time.time + 1f; Status = gun2.name + " purchased and equipped. The previous drone gun was replaced."; } else { if (!(cmd.action == "unequip") || droneData.weapon == null || !droneData.weapon.Exists) { return; } droneData.weapon = null; droneData.ammo = 0; droneData.reloading = false; droneData.hasTarget = false; droneData.lockedTarget = null; Status = "Gun removed from the drone."; } Persist(); Broadcast(); Respond(cmd, connection, Status, droneData.serial); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); Respond(cmd, connection, "Drone Mod could not complete that action. Check the BepInEx log."); } } private void ServerTick() { //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_00f4: 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_017f: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_0899: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_06d9: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Invalid comparison between Unknown and I4 //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0739: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Unknown result type (might be due to invalid IL or missing references) //IL_0766: Unknown result type (might be due to invalid IL or missing references) //IL_0768: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_092c: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_0937: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_093e: Unknown result type (might be due to invalid IL or missing references) //IL_0940: Unknown result type (might be due to invalid IL or missing references) //IL_0945: Unknown result type (might be due to invalid IL or missing references) //IL_094a: Unknown result type (might be due to invalid IL or missing references) //IL_096f: Unknown result type (might be due to invalid IL or missing references) //IL_0971: Unknown result type (might be due to invalid IL or missing references) //IL_0973: Unknown result type (might be due to invalid IL or missing references) //IL_0978: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_099e: Unknown result type (might be due to invalid IL or missing references) //IL_09a5: Unknown result type (might be due to invalid IL or missing references) //IL_09aa: Unknown result type (might be due to invalid IL or missing references) //IL_09ac: Unknown result type (might be due to invalid IL or missing references) //IL_09ae: Unknown result type (might be due to invalid IL or missing references) //IL_09b0: Unknown result type (might be due to invalid IL or missing references) //IL_09b7: Unknown result type (might be due to invalid IL or missing references) //IL_09bc: Unknown result type (might be due to invalid IL or missing references) //IL_09c1: Unknown result type (might be due to invalid IL or missing references) //IL_09c3: Unknown result type (might be due to invalid IL or missing references) //IL_09ca: Unknown result type (might be due to invalid IL or missing references) //IL_09cf: Unknown result type (might be due to invalid IL or missing references) //IL_09d4: Unknown result type (might be due to invalid IL or missing references) //IL_095a: Unknown result type (might be due to invalid IL or missing references) //IL_095c: Unknown result type (might be due to invalid IL or missing references) //IL_0961: Unknown result type (might be due to invalid IL or missing references) //IL_0966: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_09f6: Unknown result type (might be due to invalid IL or missing references) //IL_09f8: Unknown result type (might be due to invalid IL or missing references) //IL_09ff: Unknown result type (might be due to invalid IL or missing references) //IL_09f2: Unknown result type (might be due to invalid IL or missing references) //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_0a04: Unknown result type (might be due to invalid IL or missing references) //IL_0a0c: Unknown result type (might be due to invalid IL or missing references) //IL_0a0f: Unknown result type (might be due to invalid IL or missing references) //IL_0a1b: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Unknown result type (might be due to invalid IL or missing references) //IL_0a28: Unknown result type (might be due to invalid IL or missing references) //IL_0a2a: Unknown result type (might be due to invalid IL or missing references) //IL_0a2f: Unknown result type (might be due to invalid IL or missing references) //IL_0a33: Unknown result type (might be due to invalid IL or missing references) //IL_0a70: Unknown result type (might be due to invalid IL or missing references) //IL_0a75: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0b86: Unknown result type (might be due to invalid IL or missing references) //IL_0b92: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0bce: Unknown result type (might be due to invalid IL or missing references) //IL_0bd0: Unknown result type (might be due to invalid IL or missing references) //IL_0bd2: Unknown result type (might be due to invalid IL or missing references) //IL_0bd4: Unknown result type (might be due to invalid IL or missing references) //IL_0bd9: Unknown result type (might be due to invalid IL or missing references) //IL_0bdd: Unknown result type (might be due to invalid IL or missing references) //IL_0bee: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) ScanKits(); AuditWorld(); Creature[] array = Object.FindObjectsByType(); Player[] players = Object.FindObjectsByType(); foreach (DroneData item in Current) { Item val = FindKit(item.serial); if ((Object)(object)val == (Object)null) { continue; } if ((Object)(object)val.SyncedHolder != (Object)null) { item.deployed = false; item.lockedTarget = null; item.acquiring = false; item.hasTarget = false; item.combatStatus = "Carried / stored"; continue; } if (item.deployed && val.HasPlayerHolder) { val.ReconcileLocalHolderWithSyncedHolder(); } if (!item.deployed) { item.lockedTarget = null; item.acquiring = false; item.hasTarget = false; continue; } Player val2 = ResolveFollowOwner(item, players); Vector3 val5; if (item.mode == 0 && (Object)(object)val2 != (Object)null) { Vector3 val3 = FollowCenter(val2); Vector3 position = ((Component)val).transform.position; bool flag = Rules.Finite(item.position.x) && Rules.Finite(item.position.y) && Rules.Finite(item.position.z) && Rules.Finite(position.x) && Rules.Finite(position.y) && Rules.Finite(position.z); float horizontalDistance = (flag ? Vector2.Distance(new Vector2(item.position.x, item.position.z), new Vector2(val3.x, val3.z)) : float.PositiveInfinity); bool leashReturning = item.leashReturning; if (item.returningFromMode && flag) { item.leashReturning = Rules.LeashReturning(horizontalDistance, item.followDistance, currentlyReturning: true); } else { item.leashReturning = flag && Rules.LeashReturning(horizontalDistance, item.followDistance, item.leashReturning); } if (leashReturning && !item.leashReturning && !item.returningFromMode) { item.followVelocity = Vector3.zero; } Vector3 val4 = (flag ? item.position : val3); val4.y = val3.y; if (item.leashReturning) { val4.x = val3.x; val4.z = val3.z; } float num = (flag ? Vector3.Distance(item.position, val4) : float.PositiveInfinity); float num2 = (flag ? Vector3.Distance(position, val4) : float.PositiveInfinity); if (item.returningFromMode && num < 0.05f) { item.returningFromMode = false; item.followVelocity = Vector3.zero; } float num3 = (flag ? (Mathf.Min(item.position.y, position.y) - PlayerSafetyHeight(val2)) : float.NegativeInfinity); bool flag2 = ((!item.returningFromMode) ? Rules.NeedsFollowRecovery(flag, num, num2, num3) : (!flag || num3 < -8f)); string text = ((!flag) ? "invalid coordinates" : ((num3 < -0.75f) ? "below player/map" : ((num > 12f || num2 > 12f) ? "separated from follow point" : null))); if (!item.returningFromMode && !flag2 && num > 0.75f) { if (!item.hasObservedFollowPosition) { item.lastObservedFollowPosition = position; item.hasObservedFollowPosition = true; item.followStuckSince = Time.unscaledTime; } else { val5 = position - item.lastObservedFollowPosition; if (((Vector3)(ref val5)).sqrMagnitude < 0.0025f) { if (item.followStuckSince <= 0f) { item.followStuckSince = Time.unscaledTime; } else if (Time.unscaledTime - item.followStuckSince > 1.5f) { flag2 = true; text = "follow movement stalled"; } } else { item.lastObservedFollowPosition = position; item.followStuckSince = Time.unscaledTime; } } } else if (!flag2) { item.followStuckSince = 0f; item.lastObservedFollowPosition = position; item.hasObservedFollowPosition = true; } if (flag2) { ResetFollowDrone(item, val, val3, text ?? "safety check"); } else { float num4 = ((Time.time < item.activationUntil) ? 0.22f : 0.18f); item.position = Vector3.SmoothDamp(item.position, val4, ref item.followVelocity, num4, 24f, 0.1f); val5 = item.position - val4; if (((Vector3)(ref val5)).sqrMagnitude < 0.0025f) { item.position = val4; item.followVelocity = Vector3.zero; } item.surfaceNormal = Vector3.up; Quaternion curPlayerRot = val2.CurPlayerRot; item.yaw = ((Quaternion)(ref curPlayerRot)).eulerAngles.y; if ((Object)(object)val.Rig != (Object)null) { if (!val.Rig.isKinematic) { val.Rig.linearVelocity = Vector3.zero; val.Rig.angularVelocity = Vector3.zero; } val.Rig.detectCollisions = false; } val.RigidbodySync.SetKinematic(true); if ((Object)(object)val.Rig != (Object)null) { val.Rig.position = item.position; val.Rig.rotation = item.BaseRotation; } ((Component)val).transform.SetPositionAndRotation(item.position, item.BaseRotation); Physics.SyncTransforms(); } } Gun gun = GetGun(item); if (gun == null) { item.lockedTarget = null; item.acquiring = false; item.hasTarget = false; item.combatStatus = "Empty socket - fit a gun"; continue; } if (item.reloading && Time.time >= item.nextShot) { item.ammo = gun.Magazine(item.weapon); item.reloading = false; } if (item.ammo <= 0 && !item.reloading) { item.reloading = true; item.reloads++; item.nextShot = Time.time + Rules.ReloadSeconds(gun.reload, item.level); } if (item.mode == 2) { item.combatStatus = (item.reloading ? "FPV / reloading" : "FPV manual control"); continue; } float num5 = Rules.Radius(gun.kind, item.level); KitVisual component = ((Component)val).GetComponent(); Vector3 val6 = (((Object)(object)component != (Object)null) ? component.MuzzlePosition : (item.position + Vector3.up * 1.2f)); Creature val7 = null; Vector3 val8 = Vector3.zero; float num6 = num5 * num5; int num7 = 0; Creature[] array2 = array; foreach (Creature val9 in array2) { if ((Object)(object)val9 == (Object)null || !((NetworkBehaviour)val9).IsServerInitialized || ((NetworkBehaviour)val9).IsDeinitializing) { continue; } bool flag3 = val9 is Bird; bool flag4 = val9 is Fish; if (!flag3 && !flag4) { continue; } bool boss = (int)val9.BossType > 0; bool held = ((Item)val9).HasPlayerHolder || ((Item)val9).IsInInventory || (flag4 && (Object)(object)((Item)val9)._rodAttachedTo.Value != (Object)null); if (!Rules.Eligible(item.tier, flag3, flag4, boss, val9.IsDead, held)) { continue; } Vector3 position2 = ((Component)val9).transform.position; val5 = position2 - val6; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; if (sqrMagnitude > num6) { continue; } num7++; bool flag5 = false; RaycastHit[] array3 = Physics.RaycastAll(val6, position2 - val6, Mathf.Sqrt(sqrMagnitude), LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1); for (int j = 0; j < array3.Length; j++) { RaycastHit val10 = array3[j]; Item componentInParent = ((Component)((RaycastHit)(ref val10)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)(object)val) && !((Object)(object)componentInParent == (Object)(object)val9)) { flag5 = true; break; } } if (!flag5) { val7 = val9; val8 = position2; num6 = sqrMagnitude; } } if ((Object)(object)val7 == (Object)null) { item.lockedTarget = null; item.acquiring = false; item.hasTarget = false; item.combatStatus = (item.reloading ? "Reloading" : ((num7 > 0) ? "Targets behind terrain" : ("Searching within " + num5.ToString("0") + " m"))); continue; } if ((Object)(object)item.lockedTarget != (Object)(object)val7) { item.lockedTarget = val7; item.lockUntil = Time.time + 1f; item.acquiring = true; item.acquisition++; } item.hasTarget = true; item.aim = val8; if (item.acquiring && Time.time >= item.lockUntil) { item.acquiring = false; } item.combatStatus = (item.acquiring ? ("Acquiring " + ((Object)val7).name) : (item.reloading ? "Tracking / reloading" : ("Tracking " + ((Object)val7).name))); if (item.acquiring || item.reloading || Time.time < item.nextShot) { continue; } float num8 = Mathf.Sqrt(num6); val5 = val8 - val6; Vector3 normalized = ((Vector3)(ref val5)).normalized; Vector3 val11 = Vector3.Cross(normalized, Vector3.up); if (((Vector3)(ref val11)).sqrMagnitude < 0.01f) { val11 = Vector3.Cross(normalized, Vector3.right); } ((Vector3)(ref val11)).Normalize(); val5 = Vector3.Cross(val11, normalized); Vector3 normalized2 = ((Vector3)(ref val5)).normalized; float num9 = Mathf.Tan(Rules.AccuracyCone(item.level) * ((float)Math.PI / 180f)) * num8; Vector2 val12 = Random.insideUnitCircle * num9; Vector3 val13 = val8 + val11 * val12.x + normalized2 * val12.y; bool flag6 = Random.value <= Rules.Accuracy(item.level); item.shotAim = (flag6 ? Vector3.Lerp(val8, val13, 0.15f) : val13); Player val14 = null; float num10 = Vector3.Distance(val6, item.shotAim); val5 = item.shotAim - val6; foreach (RaycastHit item2 in from h in Physics.SphereCastAll(val6, 0.12f, ((Vector3)(ref val5)).normalized, num10, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current2 = item2; Player val15 = ((Component)((RaycastHit)(ref current2)).collider).GetComponentInParent() ?? PlayerManager.GetPlayerFromBodyPart(((Component)((RaycastHit)(ref current2)).collider).transform); if ((Object)(object)val15 != (Object)null && !val15.Dying.IsDead) { val14 = val15; break; } } if ((Object)(object)val14 != (Object)null && !item.friendlyFire) { item.combatStatus = "Holding fire - player in line of fire"; continue; } item.shots++; item.ammo--; item.nextShot = Time.time + Rules.Interval(gun.kind, item.level); item.combatStatus = (flag6 ? ("Firing at " + ((Object)val7).name) : ("Missed " + ((Object)val7).name)); int num11 = Rules.Damage(gun.Damage(item.weapon), item.level); if ((Object)(object)val14 != (Object)null) { Server.Instance.HitPlayer(val14, num11, Vector3.zero, ((Component)val14).transform.position, (byte)0, val2); } else if (flag6) { int totalWorth = ((Item)val7).TotalWorth; val7.ServerChangeHp(num11); bool isDead = val7.IsDead; if ((Object)(object)val2 != (Object)null) { Creature obj = val7; Vector3 val16 = val8; val5 = val8 - val6; obj.ObserverHit(val2, val16, ((Vector3)(ref val5)).normalized, num11); SendHitFeedback(val2, val7, val8, num11, isDead, totalWorth); } } if (item.ammo <= 0) { item.reloading = true; item.reloads++; item.nextShot = Time.time + Rules.ReloadSeconds(gun.reload, item.level); } } } public int WholeDroneValue(Item item) { DroneData droneData = (((Object)(object)item == (Object)null) ? null : Find(Kit.Serial(item))); if (droneData == null) { return 5000; } long num = Rules.ResaleValue(droneData.purchasePrice, droneData.level, droneData.tier); Gun gun = GetGun(droneData); if (gun != null) { num += gun.price / 2; } return (int)Math.Min(2147483647L, num); } public void CompleteWholeDroneSale(Item item) { if (!InstanceFinder.IsServerStarted || (Object)(object)item == (Object)null) { return; } DroneData droneData = Find(Kit.Serial(item)); if (droneData == null) { return; } Current.Remove(droneData); kits.Remove(droneData.serial); if (Selected == droneData.serial) { Selected = 0; if (FpvActive) { ExitFpv(notifyHost: false); } } Status = "Drone sold to vendor."; Persist(); Broadcast(); } private void OnDestroy() { ExitFpv(notifyHost: false); Persist(); Toggle(show: false); if (harmony != null) { harmony.UnpatchSelf(); } Instance = null; } public void BeginFpv(DroneData data) { //IL_0098: 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_00a2: 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) Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || data == null || data.owner != localPlayer.SteamID || !data.deployed) { Status = "Launch your drone before entering FPV mode."; return; } if ((Object)(object)FindKit(data.serial) == (Object)null) { Status = "Drone is unavailable."; return; } Selected = data.serial; pendingFpvSerial = data.serial; fpvPending = true; fpvRequestUntil = Time.unscaledTime + 4f; Status = "Connecting to drone camera..."; Send("mode", 2); Toggle(show: false); TryCompleteFpvEntry(); } private void TryCompleteFpvEntry() { //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) if (!fpvPending || FpvActive) { return; } DroneData droneData = Find(pendingFpvSerial); Item val = FindKit(pendingFpvSerial); if (droneData == null || (Object)(object)val == (Object)null) { fpvPending = false; Status = "Drone camera connection failed."; return; } if (droneData.mode != 2 || !droneData.deployed) { if (Time.unscaledTime > fpvRequestUntil) { fpvPending = false; Status = "Drone did not confirm FPV mode. Try again."; } return; } Player localPlayer = Player.LocalPlayer; playerCamera = (((Object)(object)localPlayer == (Object)null) ? null : (((Object)(object)localPlayer.CurCam != (Object)null) ? localPlayer.CurCam : (((Object)(object)localPlayer.Camera != (Object)null) ? localPlayer.Camera.Cam : null))); if ((Object)(object)playerCamera == (Object)null) { playerCamera = (((Object)(object)GameInfo.CurCamera != (Object)null) ? GameInfo.CurCamera : Camera.main); } if ((Object)(object)playerCamera == (Object)null) { fpvPending = false; Status = "Player camera was unavailable. FPV mode cancelled."; Send("mode"); return; } fpvPending = false; fpvSerial = droneData.serial; FpvActive = true; FreeCam = false; fpvTurretHolding = false; fpvPosition = ((Component)val).transform.position; fpvMoveVelocity = Vector3.zero; fpvYaw = ((Component)val).transform.eulerAngles.y; fpvPitch = 8f; playerCameraEnabled = ((Behaviour)playerCamera).enabled; fpvCameraObject = new GameObject("Drone FPV Camera"); fpvCamera = fpvCameraObject.AddComponent(); fpvCamera.CopyFrom(playerCamera); fpvCamera.targetTexture = null; fpvCamera.depth = playerCamera.depth + 10f; Camera obj = fpvCamera; obj.cullingMask |= LayerMask.op_Implicit(GameInfo.PlayerLayers); ((Behaviour)fpvCamera).enabled = true; fpvBaseFov = fpvCamera.fieldOfView; fpvZoomVelocity = 0f; ShowLocalPlayerForFpv(localPlayer); if ((Object)(object)localPlayer != (Object)null) { localPlayer.SetCurCam(fpvCamera); } else { GameInfo.SetCam(fpvCamera); } ((Behaviour)playerCamera).enabled = false; HideNormalHud(); PlayerCamera.ToggleMouse(false); Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Rigidbody != (Object)null) { localPlayer.Rigidbody.linearVelocity = Vector3.zero; } Status = "FPV camera connected."; } public void ExitFpv(bool notifyHost = true) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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) if (FpvActive || fpvPending) { FpvActive = false; fpvPending = false; fpvTurretHolding = false; FreeCam = false; RestoreNormalHud(); RestoreLocalPlayerAfterFpv(); if ((Object)(object)playerCamera != (Object)null) { ((Behaviour)playerCamera).enabled = playerCameraEnabled; } Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)playerCamera != (Object)null) { localPlayer.SetCurCam(playerCamera); } else if ((Object)(object)playerCamera != (Object)null) { GameInfo.SetCam(playerCamera); } if ((Object)(object)fpvCameraObject != (Object)null) { Object.Destroy((Object)(object)fpvCameraObject); } fpvCamera = null; fpvCameraObject = null; PlayerCamera.ToggleMouse(false); Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; if (notifyHost) { Send("mode"); } Status = "Returned to player control. Drone resumed follow mode."; } } private void ShowLocalPlayerForFpv(Player player) { RestoreLocalPlayerAfterFpv(); if ((Object)(object)player == (Object)null || (Object)(object)player.Transform == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)player.Transform).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { fpvPlayerRenderers.Add(new PlayerRendererState { renderer = val, enabled = val.enabled, forceRenderingOff = val.forceRenderingOff }); val.enabled = true; val.forceRenderingOff = false; } } } private void RestoreLocalPlayerAfterFpv() { foreach (PlayerRendererState fpvPlayerRenderer in fpvPlayerRenderers) { if ((Object)(object)fpvPlayerRenderer.renderer != (Object)null) { fpvPlayerRenderer.renderer.enabled = fpvPlayerRenderer.enabled; fpvPlayerRenderer.renderer.forceRenderingOff = fpvPlayerRenderer.forceRenderingOff; } } fpvPlayerRenderers.Clear(); } private void HideNormalHud() { //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown RestoreNormalHud(); Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } FieldInfo fieldInfo = AccessTools.Field(typeof(Player), "_ui"); PlayerUI val = (PlayerUI)((fieldInfo == null) ? null : /*isinst with value type is only supported in some contexts*/); if ((Object)(object)val == (Object)null) { return; } HashSet roots = new HashSet(); string[] array = new string[14] { "_closeItemsUI", "_itemUI", "_onHitUI", "fishingUI", "weaponUI", "_bossUI", "_npcUI", "_voiceUI", "_moneyUI", "_deathUI", "_islandUI", "_thinkingUI", "_fxCanvas", "_bossCanvas" }; foreach (string text in array) { FieldInfo fieldInfo2 = AccessTools.Field(typeof(PlayerUI), text); Component val2 = (Component)((fieldInfo2 == null) ? null : /*isinst with value type is only supported in some contexts*/); if ((Object)(object)val2 != (Object)null) { HideHudRoot(val2.gameObject, roots); } } FieldInfo fieldInfo3 = AccessTools.Field(typeof(PlayerUI), "_mainCanvas"); FieldInfo fieldInfo4 = AccessTools.Field(typeof(PlayerUI), "_vitalsUI"); CanvasGroup val3 = (CanvasGroup)((fieldInfo3 == null) ? null : /*isinst with value type is only supported in some contexts*/); Component val4 = (Component)((fieldInfo4 == null) ? null : /*isinst with value type is only supported in some contexts*/); if ((Object)(object)val3 != (Object)null) { foreach (Transform item in ((Component)val3).transform) { Transform val5 = item; if (!((Object)(object)val4 != (Object)null) || (!((Object)(object)val4.transform == (Object)(object)val5) && !val4.transform.IsChildOf(val5))) { HideHudRoot(((Component)val5).gameObject, roots); } } } InventorySlot[] array2 = Object.FindObjectsByType((FindObjectsInactive)1); foreach (InventorySlot val6 in array2) { if ((Object)(object)val6 != (Object)null) { HideHudRoot(((Component)val6).gameObject, roots); } } } private void HideHudRoot(GameObject root, HashSet roots) { if (!((Object)(object)root == (Object)null) && roots.Add(root)) { CanvasGroup val = root.GetComponent(); bool flag = (Object)(object)val == (Object)null; if (flag) { val = root.AddComponent(); } hiddenHud.Add(new HiddenHud { group = val, alpha = val.alpha, interactable = val.interactable, blocks = val.blocksRaycasts, added = flag }); val.alpha = 0f; val.interactable = false; val.blocksRaycasts = false; } } private void RestoreNormalHud() { foreach (HiddenHud item in hiddenHud) { if (!((Object)(object)item.group == (Object)null)) { item.group.alpha = item.alpha; item.group.interactable = item.interactable; item.group.blocksRaycasts = item.blocks; if (item.added) { Object.Destroy((Object)(object)item.group); } } } hiddenHud.Clear(); } private void UpdateLocalDroneControl() { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: 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_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0231: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: 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_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: 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_03d5: Unknown result type (might be due to invalid IL or missing references) if (fpvPending) { TryCompleteFpvEntry(); if (!FpvActive) { return; } } if (!FpvActive) { return; } Keyboard current = Keyboard.current; Mouse current2 = Mouse.current; if (current == null) { return; } if (((ButtonControl)current.eKey).isPressed) { if (!fpvTurretHolding) { fpvTurretHolding = true; fpvTurretHoldStart = Time.unscaledTime; } if (Time.unscaledTime - fpvTurretHoldStart >= 2f) { Vector3 normal = default(Vector3); ((Vector3)(ref normal))..ctor(fpvPitch, fpvYaw, FreeCam ? 1f : 0f); Send("fpv", 0, fpvPosition, null, normal); Send("mode", 1); ExitFpv(notifyHost: false); Status = "Drone locked at its FPV position in Turret mode."; return; } } else { fpvTurretHolding = false; } if (((ButtonControl)current.pKey).wasPressedThisFrame) { FreeCam = !FreeCam; if (!FreeCam) { fpvPitch = 8f; } } if (current2 != null) { Vector2 val = ((InputControl)(object)((Pointer)current2).delta).ReadValue(); fpvYaw += val.x * 0.12f; fpvPitch = Mathf.Clamp(fpvPitch - val.y * 0.12f, FreeCam ? (-85f) : (-55f), FreeCam ? 85f : 55f); } Quaternion val2 = Quaternion.Euler(fpvPitch, fpvYaw, 0f); Vector3 val3 = (FreeCam ? (val2 * Vector3.forward) : (Quaternion.Euler(0f, fpvYaw, 0f) * Vector3.forward)); Vector3 val4 = (FreeCam ? (val2 * Vector3.right) : (Quaternion.Euler(0f, fpvYaw, 0f) * Vector3.right)); Vector3 val5 = Vector3.zero; if (((ButtonControl)current.wKey).isPressed) { val5 += val3; } if (((ButtonControl)current.sKey).isPressed) { val5 -= val3; } if (((ButtonControl)current.dKey).isPressed) { val5 += val4; } if (((ButtonControl)current.aKey).isPressed) { val5 -= val4; } if (((ButtonControl)current.spaceKey).isPressed) { val5 += Vector3.up; } if (((ButtonControl)current.leftCtrlKey).isPressed || ((ButtonControl)current.rightCtrlKey).isPressed) { val5 -= Vector3.up; } if (((Vector3)(ref val5)).sqrMagnitude > 1f) { ((Vector3)(ref val5)).Normalize(); } bool flag = ((ButtonControl)current.leftShiftKey).isPressed || ((ButtonControl)current.rightShiftKey).isPressed; Vector3 val6 = val5 * (flag ? 16f : 8f); float num = 1f - Mathf.Exp(-9f * Time.unscaledDeltaTime); fpvMoveVelocity = Vector3.Lerp(fpvMoveVelocity, val6, num); if (((Vector3)(ref val5)).sqrMagnitude < 0.001f && ((Vector3)(ref fpvMoveVelocity)).sqrMagnitude < 0.0004f) { fpvMoveVelocity = Vector3.zero; } fpvPosition += fpvMoveVelocity * Time.unscaledDeltaTime; if (Time.unscaledTime >= nextFpvSend) { nextFpvSend = Time.unscaledTime + 0.06f; int argument = ((current2 != null && current2.leftButton.isPressed) ? 1 : 0); Send("fpv", argument, fpvPosition, null, new Vector3(fpvPitch, fpvYaw, FreeCam ? 1f : 0f)); } } private void UpdateFpvCamera() { //IL_00ba: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if (FpvActive && !((Object)(object)fpvCamera == (Object)null)) { DroneData droneData = Find(fpvSerial); Item val = FindKit(fpvSerial); if (droneData == null || (Object)(object)val == (Object)null) { ExitFpv(notifyHost: false); return; } float num = ((Mouse.current != null && Mouse.current.rightButton.isPressed) ? Mathf.Max(18f, fpvBaseFov * 0.52f) : fpvBaseFov); fpvCamera.fieldOfView = Mathf.SmoothDamp(fpvCamera.fieldOfView, num, ref fpvZoomVelocity, 0.16f, float.PositiveInfinity, Time.unscaledDeltaTime); ((Component)fpvCamera).transform.SetPositionAndRotation(fpvPosition + Quaternion.Euler(0f, fpvYaw, 0f) * new Vector3(0f, 0.12f, 0.18f), Quaternion.Euler(fpvPitch, fpvYaw, 0f)); } } public bool TryGetLocalFpvPose(int serial, out Vector3 position, out Quaternion rotation, out Vector3 aimDirection) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) position = fpvPosition; rotation = Quaternion.Euler(0f, fpvYaw, 0f); aimDirection = Quaternion.Euler(fpvPitch, fpvYaw, 0f) * Vector3.forward; if (FpvActive) { return fpvSerial == serial; } return false; } private void DrawFpvOverlay() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00e6: 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_010a: 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_0121: 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_0139: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0067: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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) //IL_025b: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) if (FpvActive) { if (fpvHelpStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 16, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val.normal.textColor = new Color(1f, 1f, 1f, 0.9f); fpvHelpStyle = val; fpvRecStyle = new GUIStyle(fpvHelpStyle) { fontSize = 18, alignment = (TextAnchor)3 }; } Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.72f); float num = 34f; float num2 = 30f; float num3 = Screen.width - 68; float num4 = Screen.height - 60; float num5 = 78f; float num6 = 3f; Rect[] array = (Rect[])(object)new Rect[8] { new Rect(num, num2, num5, num6), new Rect(num, num2, num6, num5), new Rect(num + num3 - num5, num2, num5, num6), new Rect(num + num3 - num6, num2, num6, num5), new Rect(num, num2 + num4 - num6, num5, num6), new Rect(num, num2 + num4 - num5, num6, num5), new Rect(num + num3 - num5, num2 + num4 - num6, num5, num6), new Rect(num + num3 - num6, num2 + num4 - num5, num6, num5) }; for (int i = 0; i < array.Length; i++) { GUI.DrawTexture(array[i], (Texture)(object)Texture2D.whiteTexture); } GUI.color = Color.white; GUI.DrawTexture(new Rect((float)Screen.width * 0.5f - 2f, (float)Screen.height * 0.5f - 2f, 4f, 4f), (Texture)(object)Texture2D.whiteTexture); if (Mathf.Repeat(Time.unscaledTime, 1f) < 0.62f) { GUI.color = new Color(1f, 0.08f, 0.08f, 0.95f); GUI.DrawTexture(new Rect(55f, 51f, 12f, 12f), (Texture)(object)Texture2D.whiteTexture); } GUI.color = Color.white; GUI.Label(new Rect(74f, 42f, 160f, 30f), "REC • " + (FreeCam ? "FREECAM" : "FPV"), fpvRecStyle); string text = (fpvTurretHolding ? ("LOCKING TURRET HERE " + Mathf.Clamp01((Time.unscaledTime - fpvTurretHoldStart) / 2f).ToString("P0")) : "HOLD E FOR 2 SECONDS TO LOCK TURRET HERE"); GUI.Label(new Rect((float)Screen.width * 0.5f - 260f, (float)(Screen.height - 104), 520f, 30f), text, fpvHelpStyle); GUI.Label(new Rect((float)Screen.width * 0.5f - 310f, (float)(Screen.height - 72), 620f, 30f), "HOLD SHIFT: 2X SPEED • HOLD RMB: ZOOM • ESC: EXIT", fpvHelpStyle); GUI.color = color; } } private void ManualFire(DroneData data, Item kit, Player owner, Vector3 direction) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_010f: 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_0249: 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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025d: 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_0146: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) if (data == null || (Object)(object)kit == (Object)null || data.mode != 2 || !data.deployed || ((Vector3)(ref direction)).sqrMagnitude < 0.5f) { return; } Gun gun = GetGun(data); if (gun == null || data.reloading || Time.time < data.nextShot) { return; } if (data.ammo <= 0) { data.reloading = true; data.reloads++; data.nextShot = Time.time + Rules.ReloadSeconds(gun.reload, data.level); return; } ((Vector3)(ref direction)).Normalize(); KitVisual component = ((Component)kit).GetComponent(); Vector3 val = (((Object)(object)component == (Object)null) ? data.position : component.MuzzlePosition); float num = Rules.Radius(gun.kind, data.level); Vector3 shotAim = val + direction * num; foreach (RaycastHit item in from h in Physics.RaycastAll(val, direction, num, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current = item; if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)kit) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)owner)) { shotAim = ((RaycastHit)(ref current)).point; Creature componentInParent = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent(); Player val2 = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() ?? PlayerManager.GetPlayerFromBodyPart(((Component)((RaycastHit)(ref current)).collider).transform); int num2 = Rules.Damage(gun.Damage(data.weapon), data.level); if ((Object)(object)componentInParent != (Object)null && !componentInParent.IsDead) { int totalWorth = ((Item)componentInParent).TotalWorth; componentInParent.ServerChangeHp(num2); bool isDead = componentInParent.IsDead; componentInParent.ObserverHit(owner, ((RaycastHit)(ref current)).point, direction, num2); SendHitFeedback(owner, componentInParent, ((RaycastHit)(ref current)).point, num2, isDead, totalWorth); } else if ((Object)(object)val2 != (Object)null && !val2.Dying.IsDead && data.friendlyFire) { Server.Instance.HitPlayer(val2, num2, Vector3.zero, ((RaycastHit)(ref current)).point, (byte)0, owner); } break; } } data.aim = val + direction * num; data.shotAim = shotAim; data.hasTarget = true; data.acquiring = false; data.shots++; data.ammo--; data.nextShot = Time.time + Rules.Interval(gun.kind, data.level); data.combatStatus = "FPV manual fire"; if (data.ammo <= 0) { data.reloading = true; data.reloads++; data.nextShot = Time.time + Rules.ReloadSeconds(gun.reload, data.level); } } private Texture2D Solid(Color color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, color); val.Apply(); ((Texture)val).wrapMode = (TextureWrapMode)1; return val; } private GUIStyle ConsoleButton(Texture2D normal, Texture2D hover, Color text) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.button) { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, wordWrap = true, padding = new RectOffset(7, 7, 4, 4) }; val.normal.background = normal; val.normal.textColor = text; val.hover.background = hover; val.hover.textColor = Color.white; val.active.background = orangeHover; val.active.textColor = Color.white; val.focused.background = hover; val.focused.textColor = Color.white; val.onNormal.background = cyan; val.onNormal.textColor = new Color(0.03f, 0.09f, 0.11f); val.onHover.background = cyanHover; val.onHover.textColor = Color.white; return val; } private void InitConsoleStyles() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00fd: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_019a: Expected O, but got Unknown //IL_01a5: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_026a: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027e: 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) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Expected O, but got Unknown //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0331: 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) //IL_0340: Expected O, but got Unknown //IL_0345: Expected O, but got Unknown //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Expected O, but got Unknown //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Expected O, but got Unknown //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Expected O, but got Unknown if (titleStyle == null) { steel = Solid(new Color(0.065f, 0.055f, 0.105f, 0.98f)); steelInset = Solid(new Color(0.025f, 0.022f, 0.052f, 0.98f)); steelEdge = Solid(new Color(0.34f, 0.27f, 0.48f, 1f)); cyan = Solid(new Color(0.48f, 0.2f, 0.78f, 1f)); cyanHover = Solid(new Color(0.67f, 0.34f, 0.98f, 1f)); orange = Solid(new Color(0.12f, 0.68f, 0.43f, 1f)); orangeHover = Solid(new Color(0.2f, 0.9f, 0.57f, 1f)); red = Solid(new Color(0.64f, 0.12f, 0.28f, 1f)); redHover = Solid(new Color(0.9f, 0.2f, 0.4f, 1f)); GUIStyle val = new GUIStyle(GUI.skin.window); val.normal.background = steel; val.border = new RectOffset(2, 2, 2, 2); val.padding = new RectOffset(0, 0, 0, 0); windowStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 23, fontStyle = (FontStyle)1 }; val2.normal.textColor = new Color(0.78f, 0.52f, 1f); titleStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val3.normal.textColor = new Color(0.32f, 1f, 0.66f); headerStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 14, wordWrap = true }; val4.normal.textColor = new Color(0.84f, 0.92f, 0.93f); bodyStyle = val4; GUIStyle val5 = new GUIStyle(bodyStyle) { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val5.normal.textColor = new Color(0.42f, 1f, 0.68f); statusStyle = val5; buttonStyle = ConsoleButton(steelEdge, cyan, new Color(0.92f, 0.96f, 0.96f)); accentButton = ConsoleButton(orange, orangeHover, Color.white); dangerButton = ConsoleButton(red, redHover, Color.white); recallButtonStyle = new GUIStyle(accentButton) { fontSize = 10, wordWrap = false, padding = new RectOffset(2, 2, 3, 3) }; selectedButton = ConsoleButton(cyan, cyanHover, new Color(0.02f, 0.08f, 0.1f)); slotStyle = new GUIStyle(ConsoleButton(steelEdge, cyanHover, new Color(0.4f, 1f, 1f))) { fontSize = 15 }; GUIStyle val6 = new GUIStyle(GUI.skin.textField) { fontSize = 14, padding = new RectOffset(8, 8, 5, 5) }; val6.normal.background = steelInset; val6.normal.textColor = Color.white; val6.focused.background = steelInset; val6.focused.textColor = new Color(0.45f, 1f, 1f); inputStyle = val6; GUIStyle val7 = new GUIStyle(GUI.skin.toggle) { fontSize = 14, fontStyle = (FontStyle)1 }; val7.normal.textColor = new Color(0.84f, 0.92f, 0.93f); val7.hover.textColor = Color.white; val7.onNormal.textColor = new Color(0.35f, 1f, 0.75f); val7.onHover.textColor = new Color(0.35f, 1f, 0.75f); toggleStyle = val7; } } private void Frame(Rect rect, string label = null) { //IL_0000: 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_0084: 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) GUI.DrawTexture(rect, (Texture)(object)steelEdge); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 4f, ((Rect)(ref rect)).height - 4f), (Texture)(object)steelInset); if (!string.IsNullOrEmpty(label)) { GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 4f, 24f), (Texture)(object)steel); GUI.Label(new Rect(((Rect)(ref rect)).x + 10f, ((Rect)(ref rect)).y + 3f, ((Rect)(ref rect)).width - 20f, 22f), label, headerStyle); } } public void Toggle(bool show) { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Invalid comparison between Unknown and I4 //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Invalid comparison between Unknown and I4 //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (Open == show) { return; } if (show) { Player player = Player.LocalPlayer; Item item = (((Object)(object)player == (Object)null) ? null : player.Holding.HeldItem); if (Kit.Is(item)) { Selected = Kit.Serial(item); nameSerial = 0; } else if ((Object)(object)player != (Object)null) { DroneData droneData = (from t in Current where t.available && t.deployed && t.owner == player.SteamID && Rules.InManagementRange(ManagementDistance(t, player)) orderby ManagementDistance(t, player) select t).FirstOrDefault(); if (droneData != null) { Selected = droneData.serial; nameSerial = 0; } } oldLock = Cursor.lockState; Open = true; try { PlayerCamera.ToggleMouse(true); } catch { } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; return; } Open = false; try { PlayerCamera.ToggleMouse((int)oldLock != 1); } catch { Cursor.lockState = oldLock; Cursor.visible = (int)oldLock != 1; } } private void OnGUI() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //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) DrawInteractionHint(); DrawDroneLabel(); DrawFpvOverlay(); if (Open) { InitConsoleStyles(); GUI.depth = -11000; float num = Mathf.Min(1f, Mathf.Min((float)Screen.width / 750f, (float)Screen.height / 660f)); Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.Scale(Vector3.one * num); ((Rect)(ref panel)).x = Mathf.Clamp(((Rect)(ref panel)).x, 0f, Mathf.Max(0f, (float)Screen.width / num - ((Rect)(ref panel)).width)); ((Rect)(ref panel)).y = Mathf.Clamp(((Rect)(ref panel)).y, 0f, Mathf.Max(0f, (float)Screen.height / num - ((Rect)(ref panel)).height)); panel = GUI.Window(1094800195, panel, new WindowFunction(DrawPanel), "", windowStyle); GUI.matrix = matrix; } } private void DrawPanel(int id) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0136: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(0f, 0f, 730f, 44f), (Texture)(object)steelInset); GUI.DrawTexture(new Rect(0f, 42f, 730f, 2f), (Texture)(object)cyan); GUI.Label(new Rect(18f, 6f, 430f, 32f), "DRONE CONTROL CENTER", titleStyle); GUI.Label(new Rect(446f, 11f, 210f, 22f), "DroneMod // SYSTEM ONLINE", headerStyle); if (GUI.Button(new Rect(680f, 8f, 30f, 28f), "X", dangerButton)) { Toggle(show: false); } Frame(new Rect(12f, 74f, 226f, 480f), "DRONE NETWORK"); Frame(new Rect(244f, 48f, 466f, 506f), "SELECTED UNIT"); Frame(new Rect(12f, 562f, 698f, 62f), "STATUS FEED"); Player player = Player.LocalPlayer; if ((Object)(object)player == (Object)null) { GUI.Label(new Rect(20f, 65f, 680f, 80f), "Load into a game to buy and manage your drones.", bodyStyle); GUI.DragWindow(new Rect(0f, 0f, 660f, 45f)); return; } GUI.Label(new Rect(20f, 49f, 210f, 22f), "F3 / ESC CLOSE CONSOLE", headerStyle); List list = (from t in Current where t.available && t.owner == player.SteamID orderby t.serial select t).ToList(); int num = Rules.DronePrice(list.Count); GUI.enabled = (Object)(object)Kit.Prefab != (Object)null && list.Count < 1; if (GUI.Button(new Rect(20f, 106f, 210f, 37f), (list.Count < 1) ? ("BUY DRONE // $" + num.ToString("N0")) : "ONE DRONE OWNED", accentButton)) { Send("buykit"); } GUI.enabled = true; Item held = player.Holding.HeldItem; if (Kit.Is(held)) { Current.FirstOrDefault((DroneData t) => t.available && t.serial == Kit.Serial(held)); } List list2 = list.ToList(); if (!list2.Any((DroneData t) => t.serial == Selected) && list2.Count > 0) { Selected = list2[0].serial; } GUI.Label(new Rect(20f, 78f, 210f, 24f), "LINKED UNITS [" + list.Count + "]", headerStyle); droneScroll = GUI.BeginScrollView(new Rect(20f, 151f, 210f, 393f), droneScroll, new Rect(0f, 0f, 188f, (float)Mathf.Max(393, list2.Count * 62))); for (int num2 = 0; num2 < list2.Count; num2++) { DroneData droneData = list2[num2]; string text = ((droneData.owner == player.SteamID) ? "" : " • Other owner"); if (GUI.Button(new Rect(0f, (float)(num2 * 62), 184f, 56f), droneData.DisplayName + "\n" + (droneData.deployed ? "DEPLOYED" : "PORTABLE") + text, (droneData.serial == Selected) ? selectedButton : buttonStyle)) { Selected = droneData.serial; } } GUI.EndScrollView(); DroneData droneData2 = list2.FirstOrDefault((DroneData x) => x.serial == Selected); if (droneData2 == null) { GUI.Label(new Rect(255f, 95f, 450f, 90f), "Buy your personal sentry drone to begin. Each player may own one drone.", bodyStyle); } else { DrawDrone(droneData2, player); } GUI.Label(new Rect(28f, 580f, 670f, 34f), "> " + Status, statusStyle); GUI.DragWindow(new Rect(0f, 0f, 660f, 45f)); } private void DrawDrone(DroneData t, Player player) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01c7: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_075d: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_0768: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_07f9: Unknown result type (might be due to invalid IL or missing references) //IL_07c2: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_08a7: Unknown result type (might be due to invalid IL or missing references) //IL_08e5: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_093c: Unknown result type (might be due to invalid IL or missing references) //IL_0989: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_091b: Unknown result type (might be due to invalid IL or missing references) //IL_0921: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06b0: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_0a2e: Unknown result type (might be due to invalid IL or missing references) //IL_09ee: Unknown result type (might be due to invalid IL or missing references) //IL_09f4: Unknown result type (might be due to invalid IL or missing references) //IL_09f9: Unknown result type (might be due to invalid IL or missing references) //IL_09ff: Unknown result type (might be due to invalid IL or missing references) //IL_0a9f: Unknown result type (might be due to invalid IL or missing references) //IL_0a6d: Unknown result type (might be due to invalid IL or missing references) //IL_0a73: Unknown result type (might be due to invalid IL or missing references) //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a7e: Unknown result type (might be due to invalid IL or missing references) //IL_0b31: Unknown result type (might be due to invalid IL or missing references) //IL_0ad6: Unknown result type (might be due to invalid IL or missing references) //IL_0adc: Unknown result type (might be due to invalid IL or missing references) //IL_0ae1: Unknown result type (might be due to invalid IL or missing references) //IL_0ae7: Unknown result type (might be due to invalid IL or missing references) //IL_0b9d: Unknown result type (might be due to invalid IL or missing references) //IL_0bdf: Unknown result type (might be due to invalid IL or missing references) //IL_0c49: Unknown result type (might be due to invalid IL or missing references) //IL_0c12: Unknown result type (might be due to invalid IL or missing references) //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c1d: Unknown result type (might be due to invalid IL or missing references) //IL_0c23: Unknown result type (might be due to invalid IL or missing references) Gun gun = GetGun(t); bool flag = t.weapon != null && t.weapon.Exists; if (!string.IsNullOrWhiteSpace(t.ownerName)) { _ = t.ownerName; } else { t.owner.ToString(); } float num = ManagementDistance(t, player); string text = ((!t.deployed) ? "PORTABLE" : ((t.mode == 0) ? "FOLLOW" : ((t.mode == 1) ? "TURRET" : "FPV"))); GUI.Label(new Rect(255f, 50f, 440f, 24f), t.DisplayName + " • " + text + " • " + num.ToString("0.0") + " m away", bodyStyle); if (nameSerial != t.serial) { nameSerial = t.serial; nameDraft = t.DisplayName; confirmAction = ""; bodyDraft = t.bodyColor; propellerDraft = t.propellerColor; accentDraft = t.accentColor; distanceDraft = Rules.FollowDistance(t.followDistance); } nameDraft = GUI.TextField(new Rect(255f, 82f, 345f, 27f), nameDraft, 32, inputStyle); if (GUI.Button(new Rect(605f, 82f, 90f, 27f), "SAVE NAME", buttonStyle)) { string text2 = nameDraft; Send("rename", 0, default(Vector3), text2); } if (GUI.Button(new Rect(255f, 114f, 215f, 28f), "MAIN", (activeTab == 0) ? selectedButton : buttonStyle)) { activeTab = 0; } if (GUI.Button(new Rect(480f, 114f, 215f, 28f), "COLORS", (activeTab == 1) ? selectedButton : buttonStyle)) { activeTab = 1; } if (activeTab == 1) { DrawColors(t); return; } string text3 = ((!flag) ? "+\nEMPTY WEAPON\nSOCKET" : ((gun != null) ? (gun.name + "\n[ weapon slot ]") : ("ITEM #" + t.weapon.ItemID + "\n[ weapon slot ]"))); if (GUI.Button(new Rect(255f, 150f, 135f, 86f), text3, slotStyle)) { socketOpen = !socketOpen; } GUI.Label(new Rect(410f, 150f, 285f, 86f), (!flag) ? "Click the socket to buy a gun." : ((gun == null) ? "The equipped gun prefab is unavailable." : ("Range: " + Rules.Radius(gun.kind, t.level).ToString("0.0") + " m • Damage: " + Rules.Damage(gun.Damage(t.weapon), t.level) + " / shot\nReload: " + Rules.ReloadSeconds(gun.reload, t.level).ToString("0.00") + " s • Fire rate: " + (1f / Rules.Interval(gun.kind, t.level)).ToString("0.00") + " / s\nMagazine: " + gun.Magazine(t.weapon))), bodyStyle); if (flag && GUI.Button(new Rect(255f, 241f, 135f, 26f), "REMOVE GUN", dangerButton)) { Send("unequip"); } if (GUI.Button(new Rect(410f, 241f, 138f, 26f), "RECALL TO LEASH", recallButtonStyle)) { Send("recall"); } if (GUI.Button(new Rect(557f, 241f, 138f, 26f), "RECALL TO HANDS", recallButtonStyle)) { Send("recallhands"); } if (socketOpen) { GUI.Label(new Rect(255f, 274f, 440f, 28f), flag ? "BUY A REPLACEMENT GUN" : "BUY A GUN", bodyStyle); gunScroll = GUI.BeginScrollView(new Rect(255f, 302f, 440f, 242f), gunScroll, new Rect(0f, 0f, 416f, (float)Mathf.Max(238, Guns.Count * 47))); if (Guns.Count == 0) { GUI.Label(new Rect(0f, 0f, 400f, 60f), "No supported guns found.", bodyStyle); } for (int i = 0; i < Guns.Count; i++) { Gun gun2 = Guns[i]; bool flag2 = flag && t.weapon.ItemID == ((Item)gun2.prefab).ID; GUI.enabled = !flag2; string text4 = gun2.name + " • " + Rules.Radius(gun2.kind, t.level).ToString("0") + " m • " + (flag2 ? "EQUIPPED — no charge" : ("$" + gun2.price.ToString("N0"))); if (GUI.Button(new Rect(0f, (float)(i * 47), 412f, 41f), text4, flag2 ? selectedButton : accentButton)) { Send("buygun", ((Item)gun2.prefab).ID); socketOpen = false; } } GUI.enabled = true; GUI.EndScrollView(); return; } GUI.Label(new Rect(255f, 275f, 440f, 22f), "FLIGHT MODE", headerStyle); if (GUI.Button(new Rect(255f, 298f, 138f, 28f), "FOLLOW", (t.deployed && t.mode == 0) ? selectedButton : buttonStyle)) { Send("mode"); } if (GUI.Button(new Rect(402f, 298f, 138f, 28f), "TURRET", (t.deployed && t.mode == 1) ? selectedButton : buttonStyle)) { Send("mode", 1); } GUI.enabled = t.deployed; if (GUI.Button(new Rect(549f, 298f, 146f, 28f), "ENTER FPV", (t.deployed && t.mode == 2) ? selectedButton : accentButton)) { BeginFpv(t); } GUI.enabled = true; GUI.Label(new Rect(255f, 332f, 440f, 20f), "FOLLOW LEASH RADIUS", headerStyle); distanceDraft = GUI.HorizontalSlider(new Rect(255f, 359f, 330f, 20f), distanceDraft, 1f, 5f); GUI.Label(new Rect(594f, 350f, 101f, 24f), distanceDraft.ToString("0.0") + " m", bodyStyle); if (GUI.Button(new Rect(594f, 374f, 101f, 24f), "SET LEASH", buttonStyle)) { Send("followdistance", 0, new Vector3(distanceDraft, 0f, 0f)); } GUI.Label(new Rect(255f, 405f, 210f, 24f), "UPGRADES " + t.level + " / 10", bodyStyle); GUI.enabled = t.level < 10; if (GUI.Button(new Rect(255f, 430f, 215f, 30f), (t.level < 10) ? ("LEVEL " + (t.level + 1) + " $" + Rules.UpgradePrice(t.level).ToString("N0")) : "MAX LEVEL", accentButton)) { Send("upgrade"); } GUI.enabled = true; GUI.enabled = t.tier < 2; if (GUI.Button(new Rect(480f, 430f, 215f, 30f), (t.tier == 0) ? "FISH AI $20,000" : ((t.tier == 1) ? "BOSS AI $100,000" : "ALL TARGETS"), accentButton)) { Send("tier"); } GUI.enabled = true; bool flag3 = GUI.Toggle(new Rect(255f, 468f, 300f, 24f), !t.friendlyFire, "FRIENDLY-FIRE SAFETY", toggleStyle); if (flag3 == t.friendlyFire) { if (flag3) { Send("friendlyfire"); } else { confirmAction = "friendlyfire"; } } int num2 = Rules.ResaleValue(t.purchasePrice, t.level, t.tier); GUI.enabled = !flag; if (GUI.Button(new Rect(565f, 468f, 130f, 24f), flag ? "REMOVE GUN" : ("SELL $" + num2.ToString("N0")), dangerButton)) { confirmAction = "sell"; } GUI.enabled = true; if (confirmAction != "") { GUI.Label(new Rect(255f, 500f, 220f, 22f), (confirmAction == "friendlyfire") ? "Enable friendly fire?" : "Confirm sale?", bodyStyle); if (GUI.Button(new Rect(480f, 500f, 100f, 22f), "YES", dangerButton)) { Send(confirmAction, (confirmAction == "friendlyfire") ? 1 : 0); confirmAction = ""; } if (GUI.Button(new Rect(590f, 500f, 105f, 22f), "NO", buttonStyle)) { confirmAction = ""; } } } private void DrawColors(DroneData drone) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(255f, 150f, 440f, 32f), "Choose colors for each visible drone group.", bodyStyle); DrawColorGroup(drone, "MAIN BODY", ref bodyDraft, 0, 190); DrawColorGroup(drone, "PROPELLERS", ref propellerDraft, 1, 295); DrawColorGroup(drone, "ACCENTS / LIGHTS", ref accentDraft, 2, 400); } private void DrawColorGroup(DroneData drone, string label, ref Vector3 value, int group, int y) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(255f, (float)y, 180f, 24f), label, headerStyle); Color color = GUI.color; GUI.color = new Color(value.x, value.y, value.z); GUI.DrawTexture(new Rect(645f, (float)y, 50f, 24f), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; GUI.Label(new Rect(255f, (float)(y + 27), 18f, 18f), "R", bodyStyle); value.x = GUI.HorizontalSlider(new Rect(278f, (float)(y + 31), 250f, 18f), value.x, 0f, 1f); GUI.Label(new Rect(535f, (float)(y + 27), 18f, 18f), "G", bodyStyle); value.y = GUI.HorizontalSlider(new Rect(555f, (float)(y + 31), 85f, 18f), value.y, 0f, 1f); GUI.Label(new Rect(255f, (float)(y + 51), 18f, 18f), "B", bodyStyle); value.z = GUI.HorizontalSlider(new Rect(278f, (float)(y + 55), 250f, 18f), value.z, 0f, 1f); if (GUI.Button(new Rect(535f, (float)(y + 51), 160f, 24f), "APPLY COLOR", accentButton)) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Rules.ColorChannel(value.x), Rules.ColorChannel(value.y), Rules.ColorChannel(value.z)); switch (group) { case 0: drone.bodyColor = val; break; case 1: drone.propellerColor = val; break; default: drone.accentColor = val; break; } ApplyColorsNow(drone); Send("color", group, val); } } private float DistanceToDrone(Player player, Item drone) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)drone == (Object)null) { return float.PositiveInfinity; } Vector3 val = (((Object)(object)player.Transform != (Object)null) ? player.Transform.position : ((Component)player).transform.position); float num = Vector3.Distance(val, ((Component)drone).transform.position); Collider[] componentsInChildren = ((Component)drone).GetComponentsInChildren(true); foreach (Collider val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && val2.enabled) { num = Mathf.Min(num, Vector3.Distance(val, val2.ClosestPoint(val))); } } return num; } private Item FocusedDrone(float range) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d2: 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) Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.CamObject == (Object)null) { return null; } Item result = null; float num = 0.7f; float num2 = float.PositiveInfinity; KitVisual[] array = Object.FindObjectsByType(); foreach (KitVisual kitVisual in array) { if ((Object)(object)kitVisual == (Object)null) { continue; } Item component = ((Component)kitVisual).GetComponent(); if ((Object)(object)component == (Object)null || !IsDeployed(component)) { continue; } float num3 = DistanceToDrone(localPlayer, component); if (num3 > range) { continue; } Vector3 val = ((Component)component).transform.position + ((Component)component).transform.up * 0.35f - localPlayer.CamObject.position; if (!(((Vector3)(ref val)).sqrMagnitude < 0.001f)) { float num4 = Vector3.Dot(localPlayer.CamObject.forward, ((Vector3)(ref val)).normalized); if (!(num4 < num) && (!(Mathf.Abs(num4 - num) < 0.001f) || !(num3 >= num2))) { result = component; num = num4; num2 = num3; } } } return result; } private void DrawDroneLabel() { //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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_009b: 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) Player localPlayer = Player.LocalPlayer; if (Open || FpvActive || (Object)(object)localPlayer == (Object)null || localPlayer.Dying.IsDead) { return; } Item val = FocusedDrone(8f); DroneData droneData = (((Object)(object)val == (Object)null) ? null : Find(Kit.Serial(val))); if (droneData != null) { if (droneLabelStyle == null) { droneLabelStyle = new GUIStyle(GUI.skin.box) { fontSize = 15, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, wordWrap = false }; droneLabelStyle.normal.textColor = Color.white; } string text = ((!string.IsNullOrWhiteSpace(droneData.ownerName)) ? droneData.ownerName : ((droneData.owner == 0L) ? "Unclaimed" : droneData.owner.ToString())); string text2 = ((!droneData.deployed) ? "Portable" : ((droneData.mode == 0) ? "Follow" : ((droneData.mode == 1) ? "Turret" : "FPV"))); string text3 = droneData.DisplayName + " | Owner: " + text + "\nMode: " + text2; GUI.Box(new Rect((float)Screen.width / 2f - 260f, (float)Screen.height * 0.72f - 64f, 520f, 56f), text3, droneLabelStyle); } } public static bool IsDeployed(Item item) { if ((Object)(object)Instance != (Object)null && Kit.Is(item) && (Object)(object)item.SyncedHolder == (Object)null) { return Instance.Find(Kit.Serial(item))?.deployed ?? false; } return false; } private Item InteractionTarget(out bool deploy) { deploy = false; Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || Open || localPlayer.BlockInputs || localPlayer.Dying.IsDead) { return null; } Item heldItem = localPlayer.Holding.HeldItem; if (Kit.Is(heldItem)) { deploy = true; return heldItem; } Item val = FocusedDrone(8f); DroneData droneData = (((Object)(object)val == (Object)null) ? null : Find(Kit.Serial(val))); if (droneData == null || droneData.owner != localPlayer.SteamID) { return null; } return val; } public bool CapturesInteract() { if (!((Object)(object)InteractionTarget(out var _) != (Object)null)) { return holdFired; } return true; } public void DeploySelected() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) Player localPlayer = Player.LocalPlayer; Item item = (((Object)(object)localPlayer == (Object)null) ? null : localPlayer.Holding.HeldItem); if (!Kit.Is(item) || Kit.Serial(item) != Selected) { Status = "Hold the selected drone before launching it."; } else { Send("deploy"); } } private void UpdateHoldInteraction() { //IL_00da: 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_00e5: 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) bool deploy; Item item = InteractionTarget(out deploy); Keyboard current = Keyboard.current; if (current == null || !((ButtonControl)current.eKey).isPressed) { holdSerial = 0; holdFired = false; holdAction = null; } else { if (holdFired) { return; } int num = Kit.Serial(item); Find(num); string text = (deploy ? "deploy" : "pickup"); if (num == 0) { holdSerial = 0; holdAction = null; return; } if (num != holdSerial || text != holdAction) { holdSerial = num; holdAction = text; holdStart = Time.unscaledTime; } if (!(Time.unscaledTime - holdStart < 1f)) { holdFired = true; Selected = num; _ = Player.LocalPlayer; if (deploy) { DeploySelected(); } else { Send(text); } } } } private void DrawInteractionHint() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!Open && (!((Object)(object)InteractionTarget(out var deploy) == (Object)null) || holdFired)) { string text = (holdFired ? Status : ("Hold E to " + (deploy ? "launch drone in follow mode" : "store drone in inventory"))); if (!holdFired && holdSerial != 0) { text = text + " " + Mathf.Clamp01(Time.unscaledTime - holdStart).ToString("P0"); } GUI.Box(new Rect((float)Screen.width / 2f - 220f, (float)Screen.height * 0.72f, 440f, 40f), text); } } private void RecoverSavedKit(SavedItem item, ulong owner, string ownerName) { if (item == null || !item.Exists || item.ItemID != 248) { return; } int num = Mathf.RoundToInt(item.BettingMultiplier); if (num > 0 && !world.retired.Contains(num)) { save.nextSerial = Math.Max(save.nextSerial, num + 1); if (Find(num) == null && owner != 0L) { Current.Add(new DroneData { serial = num, owner = owner, ownerName = ownerName }); Log("Recovered kit #" + num + " from inventory; old missing weapon/upgrade data cannot be reconstructed."); } } } private void AuditWorld() { //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Expected O, but got Unknown if (world == null || Time.unscaledTime < auditAfter || IslandManager.IsLoading) { return; } ServerSaveObject curServerSave = SaveManager.CurServerSave; if (curServerSave == null || !(bool)AccessTools.Field(typeof(SaveManager), "_worldItemsLoaded").GetValue(null)) { return; } Player[] source = Object.FindObjectsByType(); HashSet savedIds = new HashSet(); HashSet hashSet = new HashSet(); Action action = delegate(SavedItem item) { if (item != null && item.Exists && item.ItemID == 248) { savedIds.Add(Mathf.RoundToInt(item.BettingMultiplier)); } }; foreach (SavedPlayer p in curServerSave.Players) { if (!source.Any((Player x) => x.SteamID == p.SteamID)) { if (p.HeldItem != null && p.HeldItem.Exists && p.HeldItem.ItemID == 248) { hashSet.Add(Mathf.RoundToInt(p.HeldItem.BettingMultiplier)); } if (p.InventoryItems != null) { foreach (SavedItem inventoryItem in p.InventoryItems) { if (inventoryItem != null && inventoryItem.Exists && inventoryItem.ItemID == 248) { hashSet.Add(Mathf.RoundToInt(inventoryItem.BettingMultiplier)); } } } } action(p.HeldItem); SavedItem heldItem = p.HeldItem; ulong steamID = p.SteamID; Player? obj = ((IEnumerable)source).FirstOrDefault((Func)((Player x) => x.SteamID == p.SteamID)); RecoverSavedKit(heldItem, steamID, (obj != null) ? obj.SteamName : null); if (p.InventoryItems == null) { continue; } foreach (SavedItem inventoryItem2 in p.InventoryItems) { action(inventoryItem2); RecoverSavedKit(inventoryItem2, p.SteamID, null); } } foreach (SavedWorldItem worldItem in curServerSave.WorldItems) { action(worldItem.Item); } foreach (KeyValuePair kit in kits) { if (world.retired.Contains(kit.Key)) { if (((NetworkBehaviour)kit.Value).IsSpawned && !((NetworkBehaviour)kit.Value).IsDeinitializing) { InstanceFinder.ServerManager.Despawn(((Component)kit.Value).gameObject, (DespawnType?)null); } continue; } Player syncedHolder = kit.Value.SyncedHolder; if ((Object)(object)syncedHolder != (Object)null) { RecoverSavedKit(new SavedItem { Exists = true, ItemID = 248, BettingMultiplier = kit.Key }, syncedHolder.SteamID, syncedHolder.SteamName); } } foreach (DroneData t in Current) { Item val = FindKit(t.serial); t.available = (Object)(object)val != (Object)null || hashSet.Contains(t.serial); if ((Object)(object)val != (Object)null) { missingSince.Remove(t.serial); if ((Object)(object)val.SyncedHolder != (Object)null) { t.deployed = false; } Player val2 = ((IEnumerable)source).FirstOrDefault((Func)((Player val3) => val3.SteamID == t.owner)); if ((Object)(object)val2 != (Object)null) { t.ownerName = val2.SteamName; } } else if (!t.available) { if (!missingSince.TryGetValue(t.serial, out var value)) { missingSince[t.serial] = Time.unscaledTime; } else if (Time.unscaledTime - value > 10f) { t.deployed = false; } } } if (!audited) { audited = true; Log("Startup audit: " + Current.Count((DroneData droneData) => droneData.available) + " existing drone records; " + Current.Count((DroneData droneData) => !droneData.available) + " missing records retained for recovery and hidden from management."); } auditAfter = Time.unscaledTime + 2f; } } internal static class Wallet { private static Type WalletType => Type.GetType("NoSharedMoney.Wallets, NoSharedMoney", throwOnError: false); public static bool CanAfford(Player p, int cost) { if (cost < 0) { return false; } Type walletType = WalletType; if (walletType != null) { return (int)AccessTools.Method(walletType, "Get", new Type[1] { typeof(Player) }, (Type[])null).Invoke(null, new object[1] { p }) >= cost; } if ((Object)(object)MoneyManager.Instance != (Object)null) { return MoneyManager.CanAfford(cost); } return false; } public static void Credit(Player p, int amount) { Type walletType = WalletType; if (walletType != null) { AccessTools.Method(walletType, "Add", new Type[2] { typeof(Player), typeof(int) }, (Type[])null).Invoke(null, new object[2] { p, amount }); } else { MoneyManager.AddMoney(amount, p); } } public static bool Charge(Player p, int cost) { if (!CanAfford(p, cost)) { return false; } Type walletType = WalletType; if (walletType != null) { AccessTools.Method(walletType, "Remove", new Type[2] { typeof(Player), typeof(int) }, (Type[])null).Invoke(null, new object[2] { p, cost }); } else { MoneyManager.RemoveMoney(cost, p); } return true; } } [HarmonyPatch(typeof(GameInfo), "Awake")] internal static class RegisterKit { private static void Postfix() { try { Kit.Register(); } catch (Exception ex) { Plugin.Log("Kit registration deferred: " + ex.Message); } } } [HarmonyPatch(typeof(Item), "GetName")] internal static class KitName { private static bool Prefix(Item __instance, ref string __result) { if (!Kit.Is(__instance)) { return true; } DroneData droneData = (((Object)(object)Plugin.Instance == (Object)null) ? null : Plugin.Instance.Find(Kit.Serial(__instance))); __result = ((droneData == null) ? "Drone Mod Kit" : droneData.DisplayName); return false; } } [HarmonyPatch(typeof(Item), "SetSyncedHolder")] internal static class KitPickup { private static bool Prefix(Item __instance, Player newHolder) { if (!Kit.Is(__instance) || (Object)(object)newHolder == (Object)null || (Object)(object)Plugin.Instance == (Object)null) { return true; } DroneData droneData = Plugin.Instance.Find(Kit.Serial(__instance)); if (droneData != null) { if (!droneData.deployed) { return droneData.owner == newHolder.SteamID; } return false; } return true; } private static void Postfix(Item __instance) { if (Kit.Is(__instance) && !((Object)(object)__instance.SyncedHolder == (Object)null) && !((Object)(object)Plugin.Instance == (Object)null)) { DroneData droneData = Plugin.Instance.Find(Kit.Serial(__instance)); if (droneData != null) { droneData.deployed = false; } } } } [HarmonyPatch(typeof(Item), "get_TotalWorth")] internal static class DroneTotalWorth { private static void Postfix(Item __instance, ref int __result) { if (Kit.Is(__instance) && (Object)(object)Plugin.Instance != (Object)null) { __result = Plugin.Instance.WholeDroneValue(__instance); } } } [HarmonyPatch(typeof(MoneyManager), "SellItem")] internal static class DroneWholeSale { private static void Postfix(Item item) { if (Kit.Is(item) && (Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.CompleteWholeDroneSale(item); } } } [HarmonyPatch(typeof(SaveManager), "SaveServer")] internal static class SaveDrones { private static void Postfix() { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.Persist(); } } } [HarmonyPatch(typeof(SaveManager), "GetWorldItemSavePriority")] internal static class SaveKitPriority { private static bool Prefix(Item item, ref int __result) { if (!Kit.Is(item)) { return true; } __result = 0; return false; } } [HarmonyPatch(typeof(ItemManager), "RemoveItemsFarAwar")] internal static class KeepIslandDrones { private static void Prefix(List toRemove) { toRemove.RemoveAll((Item item) => Kit.Is(item)); } } [HarmonyPatch(typeof(Player), "get_BlockInputs")] internal static class BlockInput { private static void Postfix(Player __instance, ref bool __result) { if ((Object)(object)Plugin.Instance != (Object)null && (Plugin.Instance.Open || Plugin.Instance.FpvActive) && (Object)(object)__instance == (Object)(object)Player.LocalPlayer) { __result = true; } } } [HarmonyPatch] internal static class BlockCamera { private static IEnumerable TargetMethods() { string[] array = new string[4] { "MouseClick", "MouseInput", "ControllerRotation", "ApplyAimAssist" }; foreach (string text in array) { yield return AccessTools.Method(typeof(PlayerCamera), text, (Type[])null, (Type[])null); } } private static bool Prefix() { if (!((Object)(object)Plugin.Instance == (Object)null)) { if (!Plugin.Instance.Open) { return !Plugin.Instance.FpvActive; } return false; } return true; } } [HarmonyPatch(typeof(PauseManager), "PauseInput")] internal static class ClosePanel { private static bool Prefix(CallbackContext context) { if ((Object)(object)Plugin.Instance == (Object)null || (!Plugin.Instance.Open && !Plugin.Instance.FpvActive)) { return true; } if (((CallbackContext)(ref context)).performed) { if (Plugin.Instance.FpvActive) { Plugin.Instance.ExitFpv(); } else { Plugin.Instance.Toggle(show: false); } } return false; } } public sealed class SlotIcon : MonoBehaviour { private static Texture2D icon; private static readonly Dictionary colored = new Dictionary(); private InventorySlot slot; private RawImage image; private RawImage baseImage; private MeshFilter filter; private Renderer previewRenderer; private bool previousRendererEnabled; private GameObject gunPreview; private Texture previous; private Rect previousUV; private Color previousColor; private int signature = int.MinValue; private bool applied; public void Restore() { //IL_004c: 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_0102: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) if (!applied || (Object)(object)image == (Object)null) { return; } Item val = (((Object)(object)slot == (Object)null) ? null : slot.Item); image.texture = previous; image.uvRect = previousUV; ((Graphic)image).color = previousColor; if ((Object)(object)baseImage != (Object)null) { Object.Destroy((Object)(object)((Component)baseImage).gameObject); } if ((Object)(object)gunPreview != (Object)null) { Object.Destroy((Object)(object)gunPreview); } if ((Object)(object)previewRenderer != (Object)null) { previewRenderer.enabled = previousRendererEnabled; } if ((Object)(object)val != (Object)null && !Kit.Is(val) && (Object)(object)filter != (Object)null) { filter.mesh = val.Mesh; ((Component)filter).transform.localPosition = val.InventoryMeshPos; ((Component)filter).transform.localEulerAngles = val.InventoryMeshRot; ((Component)filter).transform.localScale = Vector3.one * val.InventoryMeshScale; if ((Object)(object)previewRenderer != (Object)null) { previewRenderer.enabled = true; } try { AccessTools.Method(typeof(InventorySlot), "ApplyCookness", (Type[])null, (Type[])null).Invoke(slot, new object[1] { val }); AccessTools.Method(typeof(InventorySlot), "ApplySkin", (Type[])null, (Type[])null).Invoke(slot, new object[1] { val }); } catch { } } baseImage = null; gunPreview = null; signature = int.MinValue; applied = false; slot = null; } private static int ColorKey(DroneData data) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0074: Unknown result type (might be due to invalid IL or missing references) if (data == null) { return 0; } int num = 17; Vector3[] array = (Vector3[])(object)new Vector3[3] { data.bodyColor, data.propellerColor, data.accentColor }; foreach (Vector3 val in array) { num = num * 31 + Mathf.RoundToInt(val.x * 15f); num = num * 31 + Mathf.RoundToInt(val.y * 15f); num = num * 31 + Mathf.RoundToInt(val.z * 15f); } return num; } private static Texture2D ColoredIcon(DroneData data) { //IL_00f2: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_01ad: 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_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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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) int key = ColorKey(data); if (colored.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } if ((Object)(object)icon == (Object)null || data == null) { return icon; } Color32[] pixels = icon.GetPixels32(); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Rules.ColorChannel(data.bodyColor.x), Rules.ColorChannel(data.bodyColor.y), Rules.ColorChannel(data.bodyColor.z)); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Rules.ColorChannel(data.propellerColor.x), Rules.ColorChannel(data.propellerColor.y), Rules.ColorChannel(data.propellerColor.z)); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Rules.ColorChannel(data.accentColor.x), Rules.ColorChannel(data.accentColor.y), Rules.ColorChannel(data.accentColor.z)); for (int i = 0; i < pixels.Length; i++) { Color32 val4 = pixels[i]; if (val4.a != 0) { float num = (float)(int)val4.r / 255f; float num2 = (float)(int)val4.g / 255f; float num3 = (float)(int)val4.b / 255f; float num4 = Mathf.Max(num, Mathf.Max(num2, num3)); Vector3 val5 = ((num2 > 0.42f && num3 > 0.48f && num2 > num * 1.35f) ? val3 : ((num > 0.55f && num2 > 0.55f && num3 < 0.38f) ? val2 : val)); float num5 = Mathf.Clamp(0.35f + num4 * 0.9f, 0.25f, 1.2f); pixels[i] = Color32.op_Implicit(new Color(val5.x * num5, val5.y * num5, val5.z * num5, (float)(int)val4.a / 255f)); } } value = new Texture2D(((Texture)icon).width, ((Texture)icon).height, (TextureFormat)4, false); value.SetPixels32(pixels); value.Apply(); ((Texture)value).wrapMode = (TextureWrapMode)1; colored[key] = value; return value; } private static void Stretch(RectTransform rect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0022: 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) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; ((Transform)rect).localScale = Vector3.one; } private void EnsureIcon() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if (!((Object)(object)icon == (Object)null)) { return; } using Stream stream = typeof(SlotIcon).Assembly.GetManifestResourceStream("DroneMod.drone-icon.png"); if (stream == null) { return; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); icon = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(icon, memoryStream.ToArray()); ((Texture)icon).wrapMode = (TextureWrapMode)1; } public void Apply(InventorySlot target) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) slot = target; if (!Kit.Is(slot.Item)) { return; } EnsureIcon(); if ((Object)(object)icon == (Object)null) { return; } image = (RawImage)AccessTools.Field(typeof(InventorySlot), "_itemImage").GetValue(slot); if (!((Object)(object)image == (Object)null)) { filter = (MeshFilter)AccessTools.Field(typeof(InventorySlot), "_filter").GetValue(slot); previewRenderer = (Renderer)AccessTools.Field(typeof(InventorySlot), "_renderer").GetValue(slot); if (!applied) { previous = image.texture; previousUV = image.uvRect; previousColor = ((Graphic)image).color; previousRendererEnabled = (Object)(object)previewRenderer == (Object)null || previewRenderer.enabled; GameObject val = new GameObject("DroneMod drone icon background", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(RawImage) }); val.transform.SetParent(((Component)image).transform.parent, false); val.transform.SetSiblingIndex(((Component)image).transform.GetSiblingIndex()); baseImage = val.GetComponent(); Stretch(((Graphic)baseImage).rectTransform); baseImage.texture = (Texture)(object)icon; baseImage.uvRect = new Rect(0f, 0f, 1f, 1f); ((Graphic)baseImage).color = Color.white; ((Graphic)baseImage).raycastTarget = false; image.texture = previous; image.uvRect = previousUV; ((Graphic)image).color = Color.white; applied = true; } RefreshWeapon(); } } private void LateUpdate() { if (applied && (Object)(object)slot != (Object)null && Kit.Is(slot.Item)) { RefreshWeapon(); } } private void RefreshWeapon() { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)slot == (Object)null || (Object)(object)filter == (Object)null) { return; } KitVisual kitVisual = (((Object)(object)slot.Item == (Object)null) ? null : ((Component)slot.Item).GetComponent()); DroneData data = (((Object)(object)Plugin.Instance == (Object)null || (Object)(object)slot.Item == (Object)null) ? null : Plugin.Instance.Find(Kit.Serial(slot.Item))); int num = (((Object)(object)kitVisual == (Object)null) ? (-1) : kitVisual.InventoryGunSignature); int num2 = (num * 397) ^ ColorKey(data); if (num2 != signature) { signature = num2; if ((Object)(object)baseImage != (Object)null) { baseImage.texture = (Texture)(object)ColoredIcon(data); } if ((Object)(object)gunPreview != (Object)null) { Object.Destroy((Object)(object)gunPreview); } gunPreview = null; filter.mesh = null; if ((Object)(object)previewRenderer != (Object)null) { previewRenderer.enabled = false; } if (num >= 0 && (Object)(object)kitVisual != (Object)null) { gunPreview = kitVisual.CreateInventoryGunPreview(((Component)filter).transform); } ((Graphic)image).color = (((Object)(object)gunPreview == (Object)null) ? Color.clear : Color.white); } } } [HarmonyPatch(typeof(InventorySlot), "SetItem")] internal static class InventoryIcon { private static void Prefix(InventorySlot __instance, Item item) { if ((Object)(object)__instance.Item != (Object)(object)item) { ((Component)__instance).GetComponent()?.Restore(); } } private static void Postfix(InventorySlot __instance) { if (Kit.Is(__instance.Item)) { (((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent()).Apply(__instance); } } } [HarmonyPatch(typeof(PlayerHolding), "PickUpInput")] internal static class HoldInsteadOfTap { private static bool Prefix() { if (!((Object)(object)Plugin.Instance == (Object)null)) { return !Plugin.Instance.CapturesInteract(); } return true; } } [HarmonyPatch(typeof(Item), "PickUp")] internal static class NoDirectDeployedPickup { private static bool Prefix(Item __instance, bool calledFromLocal, bool sendToServer) { if (calledFromLocal || sendToServer) { return !Plugin.IsDeployed(__instance); } return true; } } [HarmonyPatch(typeof(Item), "PickUp")] internal static class RecallKeepsHeldItem { private static void Prefix(Item __instance, Player player, bool calledFromLocal, out Item __state) { __state = ((Kit.Is(__instance) && !calledFromLocal && ((IEnumerable>)player.Inventory._items).Any((KeyValuePair e) => (Object)(object)e.Value == (Object)(object)__instance && e.Key != player.Inventory._syncedCurSlot.Value)) ? player.Holding.HeldItem : null); } private static void Postfix(Item __instance, Player player, bool calledFromLocal, Item __state) { if (!(!Kit.Is(__instance) || calledFromLocal) && ((IEnumerable>)player.Inventory._items).Any((KeyValuePair e) => (Object)(object)e.Value == (Object)(object)__instance && e.Key != player.Inventory._syncedCurSlot.Value)) { __instance.PutInInventory(); if ((Object)(object)__state != (Object)null && (Object)(object)__state != (Object)(object)__instance && (Object)(object)__state.SyncedHolder == (Object)(object)player) { __state.SpawnFromInventory(); player.Holding.PickUpItem(__state, false); } else if ((Object)(object)player.Holding.HeldItem == (Object)(object)__instance) { player.Hands.DropItem(true, __instance); player.Holding.SetHeldItem((Item)null); } } } } [HarmonyPatch(typeof(Item), "get_CanPickUp")] internal static class DeployedPickupPrompt { private static void Postfix(Item __instance, ref bool __result) { if (Plugin.IsDeployed(__instance)) { __result = false; } } } [HarmonyPatch(typeof(Item), "DestroyItem")] internal static class ProtectDeployedDrone { private static bool Prefix(Item __instance) { return !Plugin.IsDeployed(__instance); } } [HarmonyPatch(typeof(RigidbodySync), "SetKinematic")] internal static class AnchorDeployedDrone { private static void Prefix(RigidbodySync __instance, ref bool kinematic) { if (Plugin.IsDeployed(((Component)__instance).GetComponent())) { kinematic = true; } } } [HarmonyPatch(typeof(RigidbodySync), "StartSimulateLocal")] internal static class PreventExplosionSimulation { private static bool Prefix(RigidbodySync __instance) { return !Plugin.IsDeployed(((Component)__instance).GetComponent()); } } [HarmonyPatch(typeof(Item), "UpdateLayer")] internal static class SolidDeployedDrone { private static void Prefix(Item __instance, ref bool ____disablePlayerColOnGround) { if (Plugin.IsDeployed(__instance)) { ____disablePlayerColOnGround = true; } } } public static class Codec { private sealed class Fields : DefaultContractResolver { protected override IList CreateProperties(Type type, MemberSerialization mode) { return (from f in type.GetFields(BindingFlags.Instance | BindingFlags.Public) where !f.IsNotSerialized select ((DefaultContractResolver)this).CreateProperty((MemberInfo)f, (MemberSerialization)2)).ToList(); } } private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings { ContractResolver = (IContractResolver)(object)new Fields(), TypeNameHandling = (TypeNameHandling)0, ObjectCreationHandling = (ObjectCreationHandling)2, MaxDepth = 32 }; public static string ToJson(object value, bool pretty = false) { return JsonConvert.SerializeObject(value, (Formatting)(pretty ? 1 : 0), Settings); } public static T FromJson(string json) { return JsonConvert.DeserializeObject(json, Settings); } } public static class DroneSounds { private static bool loading; public static AudioClip Startup { get; private set; } public static AudioClip Hum { get; private set; } public static AudioClip FollowMode { get; private set; } public static AudioClip TurretMode { get; private set; } public static AudioClip FpvMode { get; private set; } public static AudioClip Mode(int mode) { return (AudioClip)(mode switch { 1 => TurretMode, 0 => FollowMode, _ => FpvMode, }); } public static IEnumerator Load() { if (!loading && (!((Object)(object)Startup != (Object)null) || !((Object)(object)Hum != (Object)null) || !((Object)(object)FollowMode != (Object)null) || !((Object)(object)TurretMode != (Object)null) || !((Object)(object)FpvMode != (Object)null))) { loading = true; string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = Find(directoryName, "drone-startup.mp3"); string hum = Find(directoryName, "drone-loop.mp3"); string follow = Find(directoryName, "drone-mode-follow.wav"); string turret = Find(directoryName, "drone-mode-turret.wav"); string fpv = Find(directoryName, "drone-mode-fpv.wav"); yield return LoadClip(path, "Drone startup", delegate(AudioClip clip) { Startup = clip; }); yield return LoadClip(hum, "Drone proximity hum", delegate(AudioClip clip) { Hum = clip; }); yield return LoadClip(follow, "Drone Follow mode", delegate(AudioClip clip) { FollowMode = clip; }); yield return LoadClip(turret, "Drone Turret mode", delegate(AudioClip clip) { TurretMode = clip; }); yield return LoadClip(fpv, "Drone FPV mode", delegate(AudioClip clip) { FpvMode = clip; }); loading = false; } } private static string Find(string folder, string name) { string text = Path.Combine(folder, name); if (File.Exists(text)) { return text; } string text2 = Path.Combine(folder, "artwork", name); if (!File.Exists(text2)) { return null; } return text2; } private static IEnumerator LoadClip(string path, string name, Action receive) { if (string.IsNullOrEmpty(path)) { Plugin.Log(name + " audio is missing from the plugin folder."); yield break; } AudioType val = (AudioType)(string.Equals(Path.GetExtension(path), ".wav", StringComparison.OrdinalIgnoreCase) ? 20 : 13); UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, val); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { Plugin.Log(name + " audio could not load: " + request.error); yield break; } AudioClip content = DownloadHandlerAudioClip.GetContent(request); if ((Object)(object)content != (Object)null) { ((Object)content).name = name; receive(content); } else { Plugin.Log(name + " audio decoded to an empty clip."); } } finally { ((IDisposable)request)?.Dispose(); } } } public static class TargetSound { private static AudioClip clip; private static bool attempted; public static void Play(Vector3 position) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!attempted) { Load(); } if ((Object)(object)clip != (Object)null) { AudioSource.PlayClipAtPoint(clip, position, 0.3f); } } private static void Load() { attempted = true; try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DroneMod.target-acquired.wav"); using BinaryReader binaryReader = new BinaryReader(stream); if (stream == null || new string(binaryReader.ReadChars(4)) != "RIFF") { throw new InvalidDataException("Missing RIFF audio data."); } binaryReader.ReadInt32(); if (new string(binaryReader.ReadChars(4)) != "WAVE") { throw new InvalidDataException("Target sound is not WAV."); } int num = 0; int num2 = 0; int num3 = 0; byte[] array = null; while (stream.Position + 8 <= stream.Length) { string text = new string(binaryReader.ReadChars(4)); int num4 = binaryReader.ReadInt32(); long val = stream.Position + num4 + (num4 & 1); if (text == "fmt ") { short num5 = binaryReader.ReadInt16(); num = binaryReader.ReadInt16(); num2 = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt16(); num3 = binaryReader.ReadInt16(); if (num5 != 1) { throw new InvalidDataException("Target sound must use PCM."); } } else if (text == "data") { array = binaryReader.ReadBytes(num4); } stream.Position = Math.Min(val, stream.Length); } if (array == null || num < 1 || num2 < 1 || num3 != 16) { throw new InvalidDataException("Unsupported target sound format."); } float[] array2 = new float[array.Length / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = (float)BitConverter.ToInt16(array, i * 2) / 32768f; } clip = AudioClip.Create("Drone target acquired", array2.Length / num, num, num2, false); clip.SetData(array2, 0); } catch (Exception ex) { Plugin.Log("Target sound could not load: " + ex.Message); } } } }