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.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 AASC { public enum GunClass { Shotgun, Pistol, SMG, Rifle, Sniper } public static class Rules { public const int KitPrice = 5000; public const int FishPrice = 20000; public const int BossPrice = 100000; public const int MaxLevel = 10; 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 TurretPrice(int ownedTurrets) { return 5000 * (1 << Math.Min(7, Math.Max(0, ownedTurrets))); } 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(5000, purchasePrice) + UpgradeInvestment(level) + TierInvestment(tier)) / 2; } public static int ResaleValue(int level, int tier) { return ResaleValue(5000, 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; } } [Serializable] public sealed class TurretData { public int serial; public int level; public int tier; public int ammo; public int shots; public int reloads; public int acquisition; public int purchasePrice; public ulong owner; public string ownerName; public string customName; public bool deployed; public bool friendlyFire; public bool acquiring; public bool hasTarget; 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; public string DisplayName { get { if (!string.IsNullOrEmpty(customName)) { return customName; } return "Turret #" + 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 turrets = 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 = 3; 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 = 3; public string world; public List turrets = new List(); } [Serializable] public sealed class Reply { public int sequence; public int serial; public string message; } public struct RequestMessage : IBroadcast { public string json; } public struct StateMessage : IBroadcast { public string json; } public struct ReplyMessage : 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 = 250; public const ushort Collection = 42420; public static Item Prefab; private static GameObject storage; public static bool Is(Item item) { if ((Object)(object)item != (Object)null && item.ID == 250) { 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_01f0: 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_0264: 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_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0370: 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(250)) { throw new Exception("AASC item ID 250 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("AASC prefab storage"); storage.SetActive(false); Object.DontDestroyOnLoad((Object)(object)storage); Item val2 = Object.Instantiate(val, storage.transform); ((Object)val2).name = "Turret Mod Kit"; AccessTools.Field(typeof(Item), "_id").SetValue(val2, (byte)250); AccessTools.Field(typeof(Item), "_cost").SetValue(val2, 5000); AccessTools.Field(typeof(Item), "_worth").SetValue(val2, 0); AccessTools.Field(typeof(Item), "_ignoredBySeagulls").SetValue(val2, true); AccessTools.Field(typeof(Item), "_ignoredByMoneyNPC").SetValue(val2, true); AccessTools.Field(typeof(Item), "_ignoredByCloseDots").SetValue(val2, false); AccessTools.Field(typeof(Item), "_heldPos").SetValue(val2, (object)new Vector3(0.25f, -0.45f, 0.75f)); 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("AASCBodyCollider"); val4.transform.SetParent(((Component)val2).transform, false); BoxCollider val5 = val4.AddComponent(); val5.center = new Vector3(0f, 0.35f, 0f); val5.size = new Vector3(0.85f, 0.7f, 0.85f); AccessTools.Field(typeof(Item), "_worldColliders").SetValue(val2, new Collider[1] { (Collider)val5 }); Collider val6 = (Collider)AccessTools.Field(typeof(Item), "_pickUpCollider").GetValue(val2); if (val6 is SphereCollider) { ((SphereCollider)val6).radius = 0.65f; ((SphereCollider)val6).center = new Vector3(0f, 0.35f, 0f); } else if (val6 is BoxCollider) { ((BoxCollider)val6).size = new Vector3(1.2f, 1f, 1.2f); ((BoxCollider)val6).center = new Vector3(0f, 0.35f, 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.7f); 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)42420, true); if (prefabObjects.GetObjectCount() != 0) { throw new Exception("AASC network prefab collection 42420 is already occupied."); } prefabObjects.AddObject(component, false, true); dictionary.Add(250, val2); ((Dictionary)AccessTools.Field(typeof(GameInfo), "_allItems").GetValue(null)).Add(250, val2); ((Dictionary)AccessTools.Field(typeof(GameInfo), "_nameToSpawnable").GetValue(null)).Add("aascturretkit", val2); Prefab = val2; Plugin.Log("Inventory kit registered using " + ((Object)val).name + "; dedicated network collection " + (ushort)42420 + "."); } } 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 LineRenderer tracer; private LineRenderer lockLaser; private float tracerUntil; private GameObject mountedGun; 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 static Material metal; private static Material orange; private static Material glow; private static Material lockGlow; 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_00e3: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: 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_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: 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) if (!((Object)(object)((Component)this).transform.Find("AASCBase") != (Object)null)) { if ((Object)(object)metal == (Object)null) { Shader obj = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); metal = new Material(obj) { color = new Color(0.13f, 0.18f, 0.21f) }; orange = new Material(obj) { color = new Color(0.98f, 0.46f, 0.08f) }; glow = new Material(Shader.Find("Sprites/Default")) { color = Color.cyan }; lockGlow = new Material(Shader.Find("Sprites/Default")) { color = Color.red }; } Part("AASCBase", ((Component)this).transform, (PrimitiveType)2, new Vector3(0f, 0.09f, 0f), new Vector3(0.7f, 0.09f, 0.7f), metal); for (int i = 0; i < 3; i++) { float num = (float)(i * 120) * ((float)Math.PI / 180f); Part("Stabilizer", ((Component)this).transform, (PrimitiveType)3, new Vector3(Mathf.Sin(num) * 0.37f, 0.06f, Mathf.Cos(num) * 0.37f), new Vector3(0.18f, 0.12f, 0.42f), orange).localEulerAngles = new Vector3(0f, (float)(i * 120), 0f); } Part("Pedestal", ((Component)this).transform, (PrimitiveType)2, new Vector3(0f, 0.32f, 0f), new Vector3(0.2f, 0.25f, 0.2f), metal); head = new GameObject("AASCHead").transform; head.SetParent(((Component)this).transform, false); head.localPosition = new Vector3(0f, 0.65f, 0f); Part("Cradle", head, (PrimitiveType)3, Vector3.zero, new Vector3(0.48f, 0.2f, 0.4f), orange); aimPivot = new GameObject("AASCGunAimPivot").transform; aimPivot.SetParent(head, false); aimPivot.localPosition = new Vector3(0f, 0.13f, 0f); socket = new GameObject("WeaponSocket").transform; socket.SetParent(aimPivot, false); socket.localPosition = Vector3.zero; Part("SocketEmpty", socket, (PrimitiveType)3, Vector3.zero, new Vector3(0.25f, 0.08f, 0.28f), metal); } } 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 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.18f - 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 = "AASCInventoryGunPreview"; 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(TurretData 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(TurretData 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 = "AASC 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("AASCHead"); if ((Object)(object)head != (Object)null) { aimPivot = head.Find("AASCGunAimPivot"); socket = (((Object)(object)aimPivot == (Object)null) ? head.Find("WeaponSocket") : aimPivot.Find("WeaponSocket")); } } 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_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_0122: 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_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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: 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_0349: 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_035e: 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_039b: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: 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_01df: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: 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_02e2: 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_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: 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_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: 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_03de: 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_0419: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Expected O, but got Unknown //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: 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_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: 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_048a: 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_04be: 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_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Expected O, but got Unknown //IL_06f2: 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; } TurretData turretData = Plugin.Instance.Find(Kit.Serial(item)); if (turretData == null) { return; } if (turretData.deployed && (Object)(object)item.SyncedHolder == (Object)null) { item.ReconcileLocalHolderWithSyncedHolder(); item.RigidbodySync.SetKinematic(true); ((Component)this).transform.SetPositionAndRotation(turretData.position, turretData.BaseRotation); } else { head.localRotation = Quaternion.identity; if ((Object)(object)aimPivot != (Object)null) { aimPivot.localRotation = Quaternion.identity; } } int wanted = ((turretData.weapon != null && turretData.weapon.Exists) ? turretData.weapon.ItemID : (-1)); int num = WeaponSignature(turretData.weapon); if (wanted != gunId || num != gunStateSignature) { gunId = wanted; gunStateSignature = num; Transform val = socket.Find("SocketEmpty"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(wanted < 0); } Gun gun = Plugin.Instance.Guns.FirstOrDefault((Gun g) => ((Item)g.prefab).ID == wanted); BuildMountedGun(gun, turretData.weapon); lastShot = turretData.shots; lastReload = turretData.reloads; lastAcquisition = turretData.acquisition; } Vector3 val2; if (turretData.deployed && (Object)(object)item.SyncedHolder == (Object)null && turretData.hasTarget && (Object)(object)mountedGun != (Object)null) { Vector3 direction = turretData.aim - MuzzlePosition; if (((Vector3)(ref direction)).sqrMagnitude > 0.01f) { AimMountedWeapon(direction, 0f, 0f); } } else if (turretData.deployed && (Object)(object)item.SyncedHolder == (Object)null && (Object)(object)mountedGun != (Object)null) { float num2 = Mathf.Repeat(Time.time * 12f + (float)turretData.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 val3 = Quaternion.AngleAxis(num2, up) * normalized; val2 = Vector3.Cross(up, val3); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; Vector3 direction2 = Quaternion.AngleAxis(-30f, normalized2) * val3; 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 num3 = Mathf.InverseLerp(reloadStarted, reloadUntil, Time.time); mountedGun.transform.localRotation = mountedBaseRotation * Quaternion.Euler(Mathf.Sin(num3 * (float)Math.PI) * 32f, 0f, Mathf.Sin(num3 * (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 (turretData.shots != lastShot) { lastShot = turretData.shots; if (turretData.deployed) { PlayFire(turretData); if ((Object)(object)tracer == (Object)null) { GameObject val4 = new GameObject("AASC tracer"); val4.transform.SetParent(((Component)this).transform, false); tracer = val4.AddComponent(); ((Renderer)tracer).sharedMaterial = glow; tracer.startWidth = 0.025f; tracer.endWidth = 0.009f; tracer.positionCount = 2; } tracer.SetPosition(0, MuzzlePosition); tracer.SetPosition(1, turretData.shotAim); ((Renderer)tracer).enabled = true; tracerUntil = Time.time + 0.09f; } } if (turretData.reloads != lastReload) { lastReload = turretData.reloads; Gun gun2 = Plugin.Instance.GetGun(turretData); if (turretData.deployed && gun2 != null) { PlayReload(turretData, gun2); } } if ((Object)(object)tracer != (Object)null && Time.time > tracerUntil) { ((Renderer)tracer).enabled = false; } if (turretData.deployed && turretData.acquiring) { if ((Object)(object)lockLaser == (Object)null) { GameObject val5 = new GameObject("AASC target lock laser"); val5.transform.SetParent(((Component)this).transform, false); lockLaser = val5.AddComponent(); ((Renderer)lockLaser).sharedMaterial = lockGlow; lockLaser.startWidth = 0.018f; lockLaser.endWidth = 0.008f; lockLaser.positionCount = 2; } lockLaser.SetPosition(0, MuzzlePosition); lockLaser.SetPosition(1, turretData.aim); ((Renderer)lockLaser).enabled = true; if (turretData.acquisition != lastAcquisition) { lastAcquisition = turretData.acquisition; TargetSound.Play(((Component)this).transform.position); } } else if ((Object)(object)lockLaser != (Object)null) { ((Renderer)lockLaser).enabled = false; } } } [BepInPlugin("ponyfisher.howtofish.aasc", "TURRET MOD", "0.1.18")] [DefaultExecutionOrder(29000)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "ponyfisher.howtofish.aasc"; 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 turret 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 Rect panel = new Rect(40f, 60f, 730f, 640f); private Vector2 turretScroll; private Vector2 gunScroll; private bool socketOpen; private string nameDraft = ""; private string confirmAction = ""; private int nameSerial; private CursorLockMode oldLock; private GUIStyle titleStyle; private GUIStyle bodyStyle; private GUIStyle slotStyle; private GUIStyle windowStyle; private GUIStyle buttonStyle; private GUIStyle accentButton; 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 turretLabelStyle; private bool audited; private float auditAfter; private readonly Dictionary missingSince = new Dictionary(); public static void Log(string text) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)text); } } private void Awake() { //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown Instance = this; savePath = Path.Combine(Paths.ConfigPath, "AASC-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 = "Turret 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() })); harmony = new Harmony("ponyfisher.howtofish.aasc"); harmony.PatchAll(typeof(Plugin).Assembly); Log("TURRET MOD 0.1.18 loaded. Compound upgrades and progressive turret pricing enabled."); } private void Update() { //IL_02c6: 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_02d0: 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) if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f2Key).wasPressedThisFrame) { Toggle(!Open); } 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 = "Turret 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.turrets; audited = false; auditAfter = Time.unscaledTime + 5f; missingSince.Clear(); kits.Clear(); lastSequence.Clear(); rateLimit.Clear(); foreach (TurretData item in Current) { item.nextShot = Time.time + 1f; item.reloading = false; item.lockedTarget = null; item.acquiring = false; item.hasTarget = false; } } if (Time.unscaledTime >= nextTick) { nextTick = Time.unscaledTime + 0.1f; ServerTick(); } if (Time.unscaledTime >= nextState) { nextState = Time.unscaledTime + 0.25f; Broadcast(); } if (Time.unscaledTime >= nextSave) { nextSave = Time.unscaledTime + 10f; Persist(); } } else if (!InstanceFinder.IsClientStarted) { world = null; Current = new List(); kits.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; } } 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 = InstanceFinder.NetworkManager; if (!((Object)(object)manager == (Object)null)) { manager.ServerManager.RegisterBroadcast((Action)Receive, true); manager.ClientManager.RegisterBroadcast((Action)ReceiveState); manager.ClientManager.RegisterBroadcast((Action)ReceiveReply); } } 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 TurretData Find(int id) { return Current.FirstOrDefault((TurretData t) => t.serial == id); } public Gun GetGun(TurretData 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 = "Turret 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 == 3 && command.sequence > 0 && (!lastSequence.TryGetValue(connection.ClientId, out var value) || command.sequence > value) && (!rateLimit.TryGetValue(connection.ClientId, out var value2) || !(Time.unscaledTime - value2 < 0.12f))) { 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 AASC 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) { Snapshot snapshot = Codec.FromJson(message.json); if (snapshot != null && snapshot.protocol == 3 && snapshot.turrets != null) { Current = snapshot.turrets; } } } private void Broadcast() { if ((Object)(object)manager != (Object)null && world != null) { manager.ServerManager.Broadcast(new StateMessage { json = Codec.ToJson(new Snapshot { world = world.name, turrets = 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; } public float ManagementDistance(TurretData turret, 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00f0: 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) if (turret == null || (Object)(object)player == (Object)null) { return float.PositiveInfinity; } Item val = FindKit(turret.serial); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : turret.position); float num = Vector3.Distance(((Component)player).transform.position, 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 val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null) && val3.enabled && !val3.isTrigger) { num = Mathf.Min(num, Vector3.Distance(((Component)player).transform.position, val3.ClosestPoint(((Component)player).transform.position))); if ((Object)(object)player.CamObject != (Object)null) { num = Mathf.Min(num, Vector3.Distance(player.CamObject.position, val3.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_0007: 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_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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Item val = Object.Instantiate(prefab, ((Component)player).transform.position + 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 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((TurretData t) => t.deployed && t.serial != Kit.Serial(kit) && Vector3.Distance(t.position, ((RaycastHit)(ref h)).point) < 0.55f)) { reason = "Another turret is too close to that point."; return false; } hit = h; return true; } } return false; } private void Execute(Player player, Command cmd, NetworkConnection connection) { //IL_01b0: 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_01bc: 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_01d5: Expected O, but got Unknown //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0474: 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_04c9: 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_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: 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_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0605: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0b63: Unknown result type (might be due to invalid IL or missing references) //IL_0b69: Unknown result type (might be due to invalid IL or missing references) //IL_0b6d: Unknown result type (might be due to invalid IL or missing references) //IL_0b73: Unknown result type (might be due to invalid IL or missing references) //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_0e4e: Unknown result type (might be due to invalid IL or missing references) //IL_0e53: Unknown result type (might be due to invalid IL or missing references) //IL_0e5a: Unknown result type (might be due to invalid IL or missing references) //IL_0e6c: Unknown result type (might be due to invalid IL or missing references) //IL_0e77: Unknown result type (might be due to invalid IL or missing references) //IL_0e87: Expected O, but got Unknown if (cmd.action == "hello") { Broadcast(); return; } if (!persistenceReady || world == null || (Object)(object)Kit.Prefab == (Object)null || player.Dying.IsDead) { Respond(cmd, connection, "Turret 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((TurretData t) => t.available && t.owner == player.SteamID); if (num2 >= 8 || Current.Count((TurretData t) => t.available) >= 32) { Respond(cmd, connection, "Turret limit reached (8 per player, 32 per world)."); return; } int num3 = Rules.TurretPrice(num2); if (!Wallet.CanAfford(player, num3)) { Respond(cmd, connection, "Not enough money. Your next empty turret costs $" + num3.ToString("N0") + "."); return; } if (save.nextSerial >= 16000000) { throw new Exception("Turret serial limit reached."); } int num4 = save.nextSerial++; Item val = SpawnForInventory(Kit.Prefab, player, num, new SavedItem { Exists = true, ItemID = 250, 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 TurretData { serial = num4, owner = player.SteamID, ownerName = player.SteamName, purchasePrice = num3 }); Persist(); Broadcast(); Respond(cmd, connection, "Turret kit purchased for $" + num3.ToString("N0") + " and added to your inventory.", num4); return; } TurretData turretData = Find(cmd.serial); Item val2 = FindKit(cmd.serial); if (turretData == null || (Object)(object)val2 == (Object)null) { Respond(cmd, connection, "That turret 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; bool flag3 = turretData.owner == player.SteamID; bool flag4 = cmd.action == "pickup" && turretData.deployed; if (!flag3 && !flag4 && cmd.action != "takeownership") { Respond(cmd, connection, "This turret belongs to " + (string.IsNullOrWhiteSpace(turretData.ownerName) ? turretData.owner.ToString() : turretData.ownerName) + ". Pick it up and use Take ownership in F2 first."); return; } float distance = ManagementDistance(turretData, player); if (cmd.action != "recall" && !flag && !Rules.InManagementRange(distance)) { Respond(cmd, connection, "Move within " + 12f.ToString("0") + " metres of the turret."); return; } if (cmd.action == "deploy") { if (turretData.deployed) { Respond(cmd, connection, "This turret is already deployed."); return; } if (!Ground(player, cmd.position, cmd.normal, val2, out var hit, out var reason)) { Respond(cmd, connection, reason); return; } val2.SpawnFromInventory(); player.Inventory.RemoveItem(val2); if ((Object)(object)val2.Holder != (Object)null) { val2.Drop(false, default(Vector3), default(Vector3)); } val2.SetSyncedHolder((Player)null, true); val2.ReconcileLocalHolderWithSyncedHolder(); if ((Object)(object)player.Holding.HeldItem == (Object)(object)val2) { player.Hands.DropItem(false, val2); player.Holding.DropItem(false, val2); } if ((Object)(object)player.Holding.UninitializedHeldItem == (Object)(object)val2) { player.Holding.SetUninitializedHeldItem((Item)null); } if ((Object)(object)val2.SyncedHolder != (Object)null || (Object)(object)val2.Holder != (Object)null) { throw new Exception("Turret holder did not release; deployment cancelled."); } val2.RigidbodySync.ServerSetSyncedSimulator(((NetworkBehaviour)Server.Instance).Owner); turretData.position = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.01f; turretData.surfaceNormal = ((RaycastHit)(ref hit)).normal; Quaternion curPlayerRot = player.CurPlayerRot; turretData.yaw = ((Quaternion)(ref curPlayerRot)).eulerAngles.y; turretData.deployed = true; turretData.aim = turretData.position + player.CurPlayerRot * Vector3.forward * 5f + Vector3.up; turretData.shotAim = turretData.aim; turretData.lockedTarget = null; turretData.acquiring = false; turretData.hasTarget = false; Gun gun = GetGun(turretData); turretData.ammo = gun?.Magazine(turretData.weapon) ?? 0; turretData.reloading = false; turretData.nextShot = Time.time; ((Component)val2).gameObject.SetActive(true); val2.RigidbodySync.TeleportToPosRot(turretData.position, turretData.BaseRotation, (float[])null, (Quaternion[])null); val2.RigidbodySync.SetKinematic(true); Status = "Turret deployed and loaded."; Log("Deployed #" + turretData.serial + " at " + ((object)Unsafe.As(ref turretData.position)/*cast due to .constrained prefix*/).ToString() + ", gun=" + ((gun == null) ? "empty" : gun.name) + ", ammo=" + turretData.ammo); } else if (cmd.action == "pickup" || cmd.action == "recall") { if (flag) { Respond(cmd, connection, "Turret 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 turret."); return; } turretData.deployed = false; turretData.lockedTarget = null; turretData.acquiring = false; turretData.hasTarget = false; val2.RigidbodySync.SetKinematic(false); 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 = (flag3 ? ("Turret recalled to " + text + " with its gun and upgrades.") : ("Turret picked up into your " + text + ". It is still owned by " + (string.IsNullOrWhiteSpace(turretData.ownerName) ? turretData.owner.ToString() : turretData.ownerName) + ".")); } else if (cmd.action == "takeownership") { if (flag3) { Respond(cmd, connection, "You already own this turret."); return; } if (!flag2) { Respond(cmd, connection, "Hold this turret in your hands before taking ownership."); return; } if (Current.Count((TurretData x) => x.available && x.owner == player.SteamID) >= 8) { Respond(cmd, connection, "You already own the maximum of eight turrets."); return; } string text2 = (string.IsNullOrWhiteSpace(turretData.ownerName) ? turretData.owner.ToString() : turretData.ownerName); turretData.owner = player.SteamID; turretData.ownerName = player.SteamName; Status = "Ownership transferred from " + text2 + " to " + player.SteamName + "."; } else if (cmd.action == "friendlyfire") { turretData.friendlyFire = cmd.argument == 1; Status = (turretData.friendlyFire ? "Friendly fire enabled." : "Friendly fire disabled."); } else if (cmd.action == "sell") { if (turretData.weapon != null && turretData.weapon.Exists) { Respond(cmd, connection, "Remove the gun before selling the turret."); return; } int amount = Rules.ResaleValue(turretData.purchasePrice, turretData.level, turretData.tier); turretData.deployed = false; turretData.lockedTarget = null; turretData.acquiring = false; turretData.hasTarget = false; Player[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (Player val3 in array) { val3.Inventory.RemoveItem(val2); if ((Object)(object)val3.Holding.HeldItem == (Object)(object)val2) { val3.Hands.DropItem(false, val2); val3.Holding.DropItem(false, val2); val3.Holding.SetHeldItem((Item)null); } if ((Object)(object)val3.Holding.UninitializedHeldItem == (Object)(object)val2) { val3.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(turretData.serial); Current.Remove(turretData); kits.Remove(turretData.serial); Selected = 0; Status = "Turret sold for $" + amount.ToString("N0") + " (half of its kit, upgrade, and targeting-tier investment)."; } else if (cmd.action == "rename") { turretData.customName = Rules.CleanName(cmd.text); Status = "Turret name saved."; } else if (cmd.action == "upgrade") { int num7 = Rules.UpgradePrice(turretData.level); if (num7 == 0) { Respond(cmd, connection, "Maximum upgrade level reached."); return; } if (!Wallet.Charge(player, num7)) { Respond(cmd, connection, "Not enough money for this upgrade."); return; } turretData.level++; Status = "Turret upgraded to level " + turretData.level + " / 10."; } else if (cmd.action == "tier") { int num8 = Rules.TierPrice(turretData.tier); if (num8 == 0) { Respond(cmd, connection, "Boss targeting already unlocked."); return; } if (!Wallet.Charge(player, num8)) { Respond(cmd, connection, "Not enough money for this targeting tier."); return; } turretData.tier++; Status = ((turretData.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((turretData.weapon != null && turretData.weapon.Exists) ? turretData.weapon.ItemID : (-1), ((Item)gun2.prefab).ID)) { Respond(cmd, connection, gun2.name + " is already equipped. No money was charged.", turretData.serial); return; } if (!Wallet.Charge(player, gun2.price)) { Respond(cmd, connection, "Not enough money for that weapon."); return; } turretData.weapon = new SavedItem { Exists = true, ItemID = ((Item)gun2.prefab).ID, BettingMultiplier = 1f, Weight = 1f }; turretData.ammo = gun2.Magazine(turretData.weapon); turretData.reloading = false; turretData.nextShot = Time.time + 1f; Status = gun2.name + " purchased and equipped. The previous turret gun was replaced."; } else { if (!(cmd.action == "unequip") || turretData.weapon == null || !turretData.weapon.Exists) { return; } turretData.weapon = null; turretData.ammo = 0; turretData.reloading = false; turretData.hasTarget = false; turretData.lockedTarget = null; Status = "Gun removed from the turret."; } Persist(); Broadcast(); Respond(cmd, connection, Status, turretData.serial); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); Respond(cmd, connection, "Turret Mod could not complete that action. Check the BepInEx log."); } } private void ServerTick() { //IL_0247: 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_022f: 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_023e: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: 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_02c4: Invalid comparison between Unknown and I4 //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_032c: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_057f: 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_058a: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_037d: 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_0658: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_0661: 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_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Unknown result type (might be due to invalid IL or missing references) //IL_0869: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_086f: 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_0878: Unknown result type (might be due to invalid IL or missing references) ScanKits(); AuditWorld(); Creature[] array = Object.FindObjectsByType(); Player[] source = Object.FindObjectsByType(); foreach (TurretData t in Current) { Item val = FindKit(t.serial); if ((Object)(object)val == (Object)null) { continue; } if ((Object)(object)val.SyncedHolder != (Object)null) { t.deployed = false; t.lockedTarget = null; t.acquiring = false; t.hasTarget = false; t.combatStatus = "Carried / stored"; continue; } if (t.deployed && val.HasPlayerHolder) { val.ReconcileLocalHolderWithSyncedHolder(); } if (!t.deployed) { t.lockedTarget = null; t.acquiring = false; t.hasTarget = false; continue; } Gun gun = GetGun(t); if (gun == null) { t.lockedTarget = null; t.acquiring = false; t.hasTarget = false; t.combatStatus = "Empty socket - fit a gun"; continue; } if (t.reloading && Time.time >= t.nextShot) { t.ammo = gun.Magazine(t.weapon); t.reloading = false; } if (t.ammo <= 0 && !t.reloading) { t.reloading = true; t.reloads++; t.nextShot = Time.time + Rules.ReloadSeconds(gun.reload, t.level); } float num = Rules.Radius(gun.kind, t.level); KitVisual component = ((Component)val).GetComponent(); Vector3 val2 = (((Object)(object)component != (Object)null) ? component.MuzzlePosition : (t.position + Vector3.up * 1.2f)); Creature val3 = null; Vector3 val4 = Vector3.zero; float num2 = num * num; int num3 = 0; Creature[] array2 = array; Vector3 val6; foreach (Creature val5 in array2) { if ((Object)(object)val5 == (Object)null || !((NetworkBehaviour)val5).IsServerInitialized || ((NetworkBehaviour)val5).IsDeinitializing) { continue; } bool flag = val5 is Bird; bool flag2 = val5 is Fish; if (!flag && !flag2) { continue; } bool boss = (int)val5.BossType > 0; bool held = ((Item)val5).HasPlayerHolder || ((Item)val5).IsInInventory || (flag2 && (Object)(object)((Item)val5)._rodAttachedTo.Value != (Object)null); if (!Rules.Eligible(t.tier, flag, flag2, boss, val5.IsDead, held)) { continue; } Vector3 position = ((Component)val5).transform.position; val6 = position - val2; float sqrMagnitude = ((Vector3)(ref val6)).sqrMagnitude; if (sqrMagnitude > num2) { continue; } num3++; bool flag3 = false; RaycastHit[] array3 = Physics.RaycastAll(val2, position - val2, Mathf.Sqrt(sqrMagnitude), LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1); for (int j = 0; j < array3.Length; j++) { RaycastHit val7 = array3[j]; Item componentInParent = ((Component)((RaycastHit)(ref val7)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)(object)val) && !((Object)(object)componentInParent == (Object)(object)val5)) { flag3 = true; break; } } if (!flag3) { val3 = val5; val4 = position; num2 = sqrMagnitude; } } if ((Object)(object)val3 == (Object)null) { t.lockedTarget = null; t.acquiring = false; t.hasTarget = false; t.combatStatus = (t.reloading ? "Reloading" : ((num3 > 0) ? "Targets behind terrain" : ("Searching within " + num.ToString("0") + " m"))); continue; } if ((Object)(object)t.lockedTarget != (Object)(object)val3) { t.lockedTarget = val3; t.lockUntil = Time.time + 2f; t.acquiring = true; t.acquisition++; } t.hasTarget = true; t.aim = val4; if (t.acquiring && Time.time >= t.lockUntil) { t.acquiring = false; } t.combatStatus = (t.acquiring ? ("Acquiring " + ((Object)val3).name) : (t.reloading ? "Tracking / reloading" : ("Tracking " + ((Object)val3).name))); if (t.acquiring || t.reloading || Time.time < t.nextShot) { continue; } float num4 = Mathf.Sqrt(num2); val6 = val4 - val2; Vector3 normalized = ((Vector3)(ref val6)).normalized; Vector3 val8 = Vector3.Cross(normalized, Vector3.up); if (((Vector3)(ref val8)).sqrMagnitude < 0.01f) { val8 = Vector3.Cross(normalized, Vector3.right); } ((Vector3)(ref val8)).Normalize(); val6 = Vector3.Cross(val8, normalized); Vector3 normalized2 = ((Vector3)(ref val6)).normalized; float num5 = Mathf.Tan(Rules.AccuracyCone(t.level) * ((float)Math.PI / 180f)) * num4; Vector2 val9 = Random.insideUnitCircle * num5; Vector3 val10 = val4 + val8 * val9.x + normalized2 * val9.y; bool flag4 = Random.value <= Rules.Accuracy(t.level); t.shotAim = (flag4 ? Vector3.Lerp(val4, val10, 0.15f) : val10); Player val11 = null; float num6 = Vector3.Distance(val2, t.shotAim); val6 = t.shotAim - val2; foreach (RaycastHit item in from h in Physics.SphereCastAll(val2, 0.12f, ((Vector3)(ref val6)).normalized, num6, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current = item; Player val12 = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() ?? PlayerManager.GetPlayerFromBodyPart(((Component)((RaycastHit)(ref current)).collider).transform); if ((Object)(object)val12 != (Object)null && !val12.Dying.IsDead) { val11 = val12; break; } } if ((Object)(object)val11 != (Object)null && !t.friendlyFire) { t.combatStatus = "Holding fire - player in line of fire"; continue; } t.shots++; t.ammo--; t.nextShot = Time.time + Rules.Interval(gun.kind, t.level); t.combatStatus = (flag4 ? ("Firing at " + ((Object)val3).name) : ("Missed " + ((Object)val3).name)); Player val13 = ((IEnumerable)source).FirstOrDefault((Func)((Player p) => p.SteamID == t.owner)); int num7 = Rules.Damage(gun.Damage(t.weapon), t.level); if ((Object)(object)val11 != (Object)null) { Server.Instance.HitPlayer(val11, num7, Vector3.zero, ((Component)val11).transform.position, (byte)0, val13); } else if (flag4) { val3.ServerChangeHp(num7); if ((Object)(object)val13 != (Object)null) { Creature obj = val3; Vector3 val14 = val4; val6 = val4 - val2; obj.ObserverHit(val13, val14, ((Vector3)(ref val6)).normalized, num7); } } if (t.ammo <= 0) { t.reloading = true; t.reloads++; t.nextShot = Time.time + Rules.ReloadSeconds(gun.reload, t.level); } } } private void OnDestroy() { Persist(); Toggle(show: false); if (harmony != null) { harmony.UnpatchSelf(); } Instance = null; } 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_0333: Unknown result type (might be due to invalid IL or missing references) //IL_035f: 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_036e: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Expected O, but got Unknown //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0393: 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_03a2: Expected O, but got Unknown //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0417: 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_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043c: 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_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Expected O, but got Unknown if (titleStyle == null) { steel = Solid(new Color(0.055f, 0.075f, 0.085f, 0.98f)); steelInset = Solid(new Color(0.025f, 0.04f, 0.048f, 0.98f)); steelEdge = Solid(new Color(0.25f, 0.34f, 0.37f, 1f)); cyan = Solid(new Color(0.08f, 0.62f, 0.68f, 1f)); cyanHover = Solid(new Color(0.08f, 0.78f, 0.86f, 1f)); orange = Solid(new Color(0.88f, 0.38f, 0.07f, 1f)); orangeHover = Solid(new Color(1f, 0.52f, 0.1f, 1f)); red = Solid(new Color(0.55f, 0.12f, 0.1f, 1f)); redHover = Solid(new Color(0.78f, 0.18f, 0.14f, 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.32f, 0.95f, 1f); titleStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; val3.normal.textColor = new Color(1f, 0.58f, 0.18f); 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.35f, 1f, 0.75f); 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); 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) { TurretData turretData = (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 (turretData != null) { Selected = turretData.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_004d: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) DrawInteractionHint(); DrawTurretLabel(); 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_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0538: 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) 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), "TURRET CONTROL CENTER", titleStyle); GUI.Label(new Rect(446f, 11f, 210f, 22f), "AASC // SYSTEM ONLINE", headerStyle); if (GUI.Button(new Rect(680f, 8f, 30f, 28f), "X", dangerButton)) { Toggle(show: false); } Frame(new Rect(12f, 74f, 226f, 480f), "TURRET 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 turrets.", bodyStyle); GUI.DragWindow(new Rect(0f, 0f, 660f, 45f)); return; } GUI.Label(new Rect(20f, 49f, 210f, 22f), "F2 / 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.TurretPrice(list.Count); GUI.enabled = (Object)(object)Kit.Prefab != (Object)null && list.Count < 8; if (GUI.Button(new Rect(20f, 106f, 210f, 37f), (list.Count < 8) ? ("BUILD TURRET // $" + num.ToString("N0")) : "TURRET LIMIT REACHED", accentButton)) { Send("buykit"); } GUI.enabled = true; Item held = player.Holding.HeldItem; TurretData heldTurret = (Kit.Is(held) ? Current.FirstOrDefault((TurretData t) => t.available && t.serial == Kit.Serial(held)) : null); List list2 = list.ToList(); if (heldTurret != null && !list2.Any((TurretData t) => t.serial == heldTurret.serial)) { list2.Insert(0, heldTurret); } if (heldTurret != null && heldTurret.owner != player.SteamID) { Selected = heldTurret.serial; } if (!list2.Any((TurretData t) => t.serial == Selected) && list2.Count > 0) { Selected = list2[0].serial; } GUI.Label(new Rect(20f, 78f, 210f, 24f), "LINKED UNITS [" + list.Count + "]", headerStyle); turretScroll = GUI.BeginScrollView(new Rect(20f, 151f, 210f, 393f), turretScroll, new Rect(0f, 0f, 188f, (float)Mathf.Max(393, list2.Count * 62))); for (int num2 = 0; num2 < list2.Count; num2++) { TurretData turretData = list2[num2]; string text = ((turretData.owner == player.SteamID) ? "" : " • Other owner"); if (GUI.Button(new Rect(0f, (float)(num2 * 62), 184f, 56f), turretData.DisplayName + "\n" + (turretData.deployed ? "DEPLOYED" : "PORTABLE") + text, (turretData.serial == Selected) ? selectedButton : buttonStyle)) { Selected = turretData.serial; } } GUI.EndScrollView(); TurretData turretData2 = list2.FirstOrDefault((TurretData x) => x.serial == Selected); if (turretData2 == null) { GUI.Label(new Rect(255f, 95f, 450f, 90f), "Buy a turret kit to start. It needs a gun before it can protect the island.", bodyStyle); } else { DrawTurret(turretData2, player); } GUI.Label(new Rect(28f, 580f, 670f, 34f), "> " + Status, statusStyle); GUI.DragWindow(new Rect(0f, 0f, 660f, 45f)); } private void DrawTurret(TurretData t, Player player) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: 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_01d5: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_050d: 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_0518: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_057b: 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_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0894: Unknown result type (might be due to invalid IL or missing references) //IL_08bd: Unknown result type (might be due to invalid IL or missing references) //IL_093b: Unknown result type (might be due to invalid IL or missing references) //IL_0862: Unknown result type (might be due to invalid IL or missing references) //IL_0868: Unknown result type (might be due to invalid IL or missing references) //IL_086d: Unknown result type (might be due to invalid IL or missing references) //IL_0873: Unknown result type (might be due to invalid IL or missing references) //IL_0646: 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_097a: Unknown result type (might be due to invalid IL or missing references) //IL_0980: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_0a3e: Unknown result type (might be due to invalid IL or missing references) //IL_09e3: Unknown result type (might be due to invalid IL or missing references) //IL_09e9: 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_0725: Unknown result type (might be due to invalid IL or missing references) //IL_0ba3: Unknown result type (might be due to invalid IL or missing references) //IL_0aaa: 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_075f: Unknown result type (might be due to invalid IL or missing references) //IL_0764: 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_0b02: Unknown result type (might be due to invalid IL or missing references) //IL_0b6c: Unknown result type (might be due to invalid IL or missing references) //IL_0b35: Unknown result type (might be due to invalid IL or missing references) //IL_0b3b: Unknown result type (might be due to invalid IL or missing references) //IL_0b40: Unknown result type (might be due to invalid IL or missing references) //IL_0b46: Unknown result type (might be due to invalid IL or missing references) Gun gun = GetGun(t); bool flag = t.weapon != null && t.weapon.Exists; bool flag2 = t.owner == player.SteamID; string text = (string.IsNullOrWhiteSpace(t.ownerName) ? t.owner.ToString() : t.ownerName); float distance = (t.deployed ? ManagementDistance(t, player) : 0f); string text2 = (t.deployed ? (" | " + distance.ToString("0.0") + " m " + (Rules.InManagementRange(distance) ? "(in range)" : "(too far)")) : ""); GUI.Label(new Rect(255f, 50f, 440f, 24f), "Name: " + t.DisplayName + " | Owner: " + text + text2, bodyStyle); if (nameSerial != t.serial) { nameSerial = t.serial; nameDraft = t.DisplayName; confirmAction = ""; } if (!flag2) { GUI.Label(new Rect(255f, 88f, 440f, 58f), "This turret belongs to another player. Holding it does not change ownership.", bodyStyle); bool flag3 = (GUI.enabled = Kit.Is(player.Holding.HeldItem) && Kit.Serial(player.Holding.HeldItem) == t.serial); if (GUI.Button(new Rect(255f, 150f, 440f, 38f), flag3 ? "AUTHORIZE OWNERSHIP TRANSFER" : "HOLD UNIT TO AUTHORIZE", accentButton)) { Send("takeownership"); } GUI.enabled = true; string text3 = ((!flag) ? "Empty weapon socket" : ((gun != null) ? ("Equipped gun: " + gun.name) : ("Equipped gun: item #" + t.weapon.ItemID))); GUI.Label(new Rect(255f, 205f, 440f, 80f), text3 + "\nCurrent level: " + t.level + " / 10 • Auto-aim tier: " + (t.tier + 1), bodyStyle); return; } nameDraft = GUI.TextField(new Rect(255f, 82f, 345f, 27f), nameDraft, 32, inputStyle); if (GUI.Button(new Rect(605f, 82f, 90f, 27f), "RENAME", buttonStyle)) { string text4 = nameDraft; Send("rename", 0, default(Vector3), text4); } string text5 = ((!flag) ? "+\nEMPTY WEAPON\nSOCKET" : ((gun != null) ? (gun.name + "\n[ weapon slot ]") : ("ITEM #" + t.weapon.ItemID + "\n[ weapon slot ]"))); if (GUI.Button(new Rect(255f, 118f, 135f, 96f), text5, slotStyle)) { socketOpen = !socketOpen; } GUI.Label(new Rect(410f, 118f, 285f, 100f), (!flag) ? "Click the socket to buy a gun." : ((gun == null) ? ("A gun is fitted, but its base-game prefab is unavailable. Its saved item ID is " + t.weapon.ItemID + ".") : ("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); GUI.enabled = !flag || gun != null; if (flag && GUI.Button(new Rect(255f, 222f, 135f, 27f), "REMOVE GUN", dangerButton)) { Send("unequip"); } GUI.enabled = true; if (GUI.Button(new Rect(410f, 222f, 285f, 30f), t.deployed ? "RECALL TURRET" : "DEPLOY ON TARGET SURFACE", accentButton)) { if (t.deployed) { Send("recall"); } else { DeploySelected(); } } if (socketOpen) { GUI.Label(new Rect(255f, 267f, 440f, 28f), flag ? "BUY A REPLACEMENT GUN" : "BUY A GUN", bodyStyle); gunScroll = GUI.BeginScrollView(new Rect(255f, 298f, 440f, 246f), 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 flag5 = flag && t.weapon.ItemID == ((Item)gun2.prefab).ID; GUI.enabled = !flag5; string text6 = gun2.name + " • " + Rules.Radius(gun2.kind, t.level).ToString("0") + " m • " + (flag5 ? "EQUIPPED — no charge" : ("$" + gun2.price.ToString("N0"))); if (GUI.Button(new Rect(0f, (float)(i * 47), 412f, 41f), text6, flag5 ? selectedButton : accentButton)) { Send("buygun", ((Item)gun2.prefab).ID); socketOpen = false; } } GUI.enabled = true; GUI.EndScrollView(); return; } GUI.Label(new Rect(255f, 268f, 440f, 26f), "UPGRADES: " + t.level + " / 10", bodyStyle); GUI.enabled = t.level < 10; if (GUI.Button(new Rect(255f, 298f, 440f, 36f), (t.level < 10) ? ("INSTALL LEVEL " + (t.level + 1) + " // $" + Rules.UpgradePrice(t.level).ToString("N0")) : "MAXIMUM LEVEL INSTALLED", accentButton)) { Send("upgrade"); } GUI.enabled = true; GUI.Label(new Rect(255f, 340f, 440f, 30f), "Compounds each level: +10% damage, reload and fire rate; +5% range.", bodyStyle); GUI.Label(new Rect(255f, 373f, 440f, 26f), "AUTO-AIM TIER " + (t.tier + 1) + ": " + (new string[3] { "SEAGULLS", "SEAGULLS + FISH", "SEAGULLS + FISH + BOSSES" })[Mathf.Clamp(t.tier, 0, 2)], bodyStyle); GUI.enabled = t.tier < 2; if (GUI.Button(new Rect(255f, 402f, 440f, 34f), (t.tier == 0) ? "UNLOCK FISH TARGETING // $20,000" : ((t.tier == 1) ? "UNLOCK BOSS TARGETING // $100,000" : "ALL TARGETING TIERS ONLINE"), accentButton)) { Send("tier"); } GUI.enabled = true; bool flag6 = GUI.Toggle(new Rect(255f, 442f, 440f, 27f), !t.friendlyFire, "FRIENDLY-FIRE SAFETY // PROTECT PLAYERS", toggleStyle); if (flag6 == t.friendlyFire) { if (flag6) { Send("friendlyfire"); } else { confirmAction = "friendlyfire"; } } int num = Rules.ResaleValue(t.purchasePrice, t.level, t.tier); GUI.enabled = !flag; if (GUI.Button(new Rect(255f, 476f, 440f, 29f), flag ? "REMOVE GUN BEFORE DECOMMISSION" : ("SELL TURRET // $" + num.ToString("N0")), dangerButton)) { confirmAction = "sell"; } GUI.enabled = true; if (confirmAction != "") { GUI.Label(new Rect(255f, 509f, 440f, 25f), (confirmAction == "friendlyfire") ? "Enable friendly fire, are you sure?" : ("Sell this empty turret for $" + num.ToString("N0") + "?"), bodyStyle); if (GUI.Button(new Rect(255f, 537f, 210f, 23f), "CONFIRM", dangerButton)) { Send(confirmAction, (confirmAction == "friendlyfire") ? 1 : 0); confirmAction = ""; } if (GUI.Button(new Rect(485f, 537f, 210f, 23f), "CANCEL", buttonStyle)) { confirmAction = ""; } } else { GUI.Label(new Rect(255f, 511f, 440f, 45f), t.deployed ? (t.combatStatus + " | Ammo: " + t.ammo + " | Unlimited reserve") : "Hold E to deploy onto a nearby surface.", bodyStyle); } } private void DrawTurretLabel() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_0065: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.LocalPlayer; Camera main = Camera.main; if (Open || (Object)(object)localPlayer == (Object)null || (Object)(object)main == (Object)null || localPlayer.Dying.IsDead) { return; } ? val = (((int)Cursor.lockState == 1 || Mouse.current == null) ? new Ray(localPlayer.CamObject.position, localPlayer.CamObject.forward) : main.ScreenPointToRay(Vector2.op_Implicit(((InputControl)(object)((Pointer)Mouse.current).position).ReadValue()))); Item val2 = null; foreach (RaycastHit item in from h in Physics.RaycastAll((Ray)val, 6f, -1, (QueryTriggerInteraction)2) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current = item; if ((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)localPlayer) { continue; } Item componentInParent = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.SyncedHolder == (Object)(object)localPlayer)) { if (Kit.Is(componentInParent) && !componentInParent.HasPlayerHolder) { val2 = componentInParent; break; } if (!((RaycastHit)(ref current)).collider.isTrigger) { break; } } } if ((Object)(object)val2 == (Object)null) { return; } TurretData turretData = Find(Kit.Serial(val2)); if (turretData == null) { return; } Vector3 val3 = main.WorldToScreenPoint(((Component)val2).transform.position + Vector3.up * 1.65f); if (!(val3.z <= 0f)) { if (turretLabelStyle == null) { turretLabelStyle = new GUIStyle(GUI.skin.box) { fontSize = 13, alignment = (TextAnchor)4, wordWrap = true, richText = false }; } string text = (string.IsNullOrWhiteSpace(turretData.ownerName) ? turretData.owner.ToString() : turretData.ownerName); string text2 = turretData.DisplayName + "\nOwner: " + text; float num = Mathf.Min(300, Screen.width - 16); float num2 = Mathf.Max(48f, turretLabelStyle.CalcHeight(new GUIContent(text2), num)); GUI.Box(new Rect(Mathf.Clamp(val3.x - num / 2f, 8f, (float)Screen.width - num - 8f), Mathf.Clamp((float)Screen.height - val3.y - num2, 8f, Mathf.Max(8f, (float)Screen.height - num2 - 8f)), num, num2), text2, turretLabelStyle); } } 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) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_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) 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; } foreach (RaycastHit item in from h in Physics.RaycastAll(localPlayer.CamObject.position, localPlayer.CamObject.forward, 4f, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current = item; if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)localPlayer)) { Item componentInParent = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.SyncedHolder == (Object)(object)localPlayer)) { return IsDeployed(componentInParent) ? componentInParent : null; } } } return null; } public bool CapturesInteract() { if (!((Object)(object)InteractionTarget(out var _) != (Object)null)) { return holdFired; } return true; } private bool CrosshairSurface(Item held, out RaycastHit surface) { //IL_0001: 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_0029: 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_006c: 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_00ca: 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) surface = default(RaycastHit); Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } foreach (RaycastHit item in from h in Physics.RaycastAll(localPlayer.CamObject.position, localPlayer.CamObject.forward, 8f, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current = item; if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)localPlayer) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)held)) { if (((Component)((RaycastHit)(ref current)).collider).gameObject.layer == LayerMask.NameToLayer("Water") || !Rules.SurfaceAllowed(((RaycastHit)(ref current)).normal.y)) { return false; } surface = current; return true; } } return false; } public void DeploySelected() { //IL_0060: 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) Player localPlayer = Player.LocalPlayer; Item val = (((Object)(object)localPlayer == (Object)null) ? null : localPlayer.Holding.HeldItem); RaycastHit surface; if (!Kit.Is(val) || Kit.Serial(val) != Selected) { Status = "Hold the selected turret, then look at a surface within 8 metres."; } else if (!CrosshairSurface(val, out surface)) { Status = "Look at an upward-facing surface within 8 metres."; } else { Send("deploy", 0, ((RaycastHit)(ref surface)).point, null, ((RaycastHit)(ref surface)).normal); } } private void UpdateHoldInteraction() { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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) 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); TurretData turretData = Find(num); string text = (deploy ? "deploy" : ((turretData != null && (Object)(object)Player.LocalPlayer != (Object)null && turretData.owner == Player.LocalPlayer.SteamID) ? "recall" : "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 ? "deploy turret" : "pick up turret"))); 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 != 250) { 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 TurretData { 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 == 250) { 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 == 250) { hashSet.Add(Mathf.RoundToInt(p.HeldItem.BettingMultiplier)); } if (p.InventoryItems != null) { foreach (SavedItem inventoryItem in p.InventoryItems) { if (inventoryItem != null && inventoryItem.Exists && inventoryItem.ItemID == 250) { 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 = 250, BettingMultiplier = kit.Key }, syncedHolder.SteamID, syncedHolder.SteamName); } } foreach (TurretData 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((TurretData turretData) => turretData.available) + " existing turret records; " + Current.Count((TurretData turretData) => !turretData.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; } TurretData turretData = (((Object)(object)Plugin.Instance == (Object)null) ? null : Plugin.Instance.Find(Kit.Serial(__instance))); __result = ((turretData == null) ? "Turret Mod Kit" : turretData.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; } TurretData turretData = Plugin.Instance.Find(Kit.Serial(__instance)); if (turretData != null) { if (!turretData.deployed) { return turretData.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)) { TurretData turretData = Plugin.Instance.Find(Kit.Serial(__instance)); if (turretData != null) { turretData.deployed = false; } } } } [HarmonyPatch(typeof(SaveManager), "SaveServer")] internal static class SaveTurrets { 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 KeepIslandTurrets { 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 && (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)) { return !Plugin.Instance.Open; } 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) { return true; } if (((CallbackContext)(ref context)).performed) { Plugin.Instance.Toggle(show: false); } return false; } } public sealed class SlotIcon : MonoBehaviour { private static Texture2D icon; 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (applied && !((Object)(object)image == (Object)null)) { 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; } baseImage = null; gunPreview = null; signature = int.MinValue; applied = false; } } 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("AASC.turret-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("AASC turret 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_00ed: 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) 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()); int num = (((Object)(object)kitVisual == (Object)null) ? (-1) : kitVisual.InventoryGunSignature); if (num != signature) { signature = num; 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 ProtectDeployedTurret { private static bool Prefix(Item __instance) { return !Plugin.IsDeployed(__instance); } } [HarmonyPatch(typeof(RigidbodySync), "SetKinematic")] internal static class AnchorDeployedTurret { 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 SolidDeployedTurret { private static void Prefix(Item __instance, ref bool ____disablePlayerColOnGround) { if (Plugin.IsDeployed(__instance)) { ____disablePlayerColOnGround = false; } } } 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 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.85f); } } private static void Load() { attempted = true; try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AASC.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("Turret target acquired", array2.Length / num, num, num2, false); clip.SetData(array2, 0); } catch (Exception ex) { Plugin.Log("Target sound could not load: " + ex.Message); } } } }