using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; 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.Rendering; 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 LanternMod { public static class Rules { public const byte SmallId = 245; public const byte BigId = 246; public const ushort SmallCollection = 42424; public const ushort BigCollection = 42425; public const int SmallPrice = 250; public const int BigPrice = 500; public const float UseRange = 6f; public const float DeployRange = 8f; public const float HoldSeconds = 1f; public const float VendorRange = 5f; public const float VendorLookDot = 0.72f; public static int Price(byte kind) { if (kind != 246) { return 250; } return 500; } public static string TypeName(byte kind) { if (kind != 246) { return "Camping Lantern"; } return "Tiki Torch"; } public static bool IsKind(byte kind) { if (kind != 245) { return kind == 246; } return true; } public static bool Finite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } public static bool SurfaceAllowed(float y) { if (Finite(y)) { return y >= 0.02f; } return false; } public static float Intensity(float value) { return Mathf.Clamp(value, 0.1f, 2f); } public static float Temperature(float value) { return Mathf.Clamp(value, 2000f, 6500f); } public static float ColorChannel(float value) { return Mathf.Clamp01(value); } public static float Frequency(float value) { return Mathf.Clamp(value, 0.25f, 8f); } public static int EffectMode(int value) { return Mathf.Clamp(value, 0, 2); } public static Vector3 DefaultBody(byte kind) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return new Vector3(0.62f, 0.035f, 0.025f); } public static Vector3 DefaultStand() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) return new Vector3(0.3f, 0.13f, 0.045f); } public static bool CanUseVendor(float distance, float lookDot) { if (Finite(distance) && Finite(lookDot) && distance <= 5.35f) { return lookDot >= 0.72f; } return false; } public static string CleanName(string value, string fallback) { if (string.IsNullOrWhiteSpace(value)) { return fallback; } value = value.Trim(); if (value.Length <= 28) { return value; } return value.Substring(0, 28); } } [Serializable] public sealed class LanternData { public int serial; public byte kind; public ulong owner; public string ownerName; public string name; public bool deployed; public bool available = true; public float intensity = 1f; public float temperature = 3200f; public float frequency = 1f; public float yaw; public bool lightOn = true; public bool useTemperature = true; public int effectMode; public Vector3 bodyColor = new Vector3(-1f, -1f, -1f); public Vector3 standColor = new Vector3(-1f, -1f, -1f); public Vector3 lightColor = new Vector3(1f, 0.62f, 0.2f); public Vector3 position; public Vector3 surfaceNormal = Vector3.up; public Quaternion Rotation => 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 lanterns = 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 = 1; public int sequence; public int serial; public int argument; public string action; public string text; public float value; public Vector3 position; public Vector3 normal; } [Serializable] public sealed class Snapshot { public int protocol = 1; public string world; public List lanterns = 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 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 = 24 }; 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 sealed class LanternTintTarget : MonoBehaviour { public bool stand; } public static class LanternItem { public static Item SmallPrefab; public static Item BigPrefab; private static GameObject storage; public static bool Is(Item item) { if ((Object)(object)item != (Object)null && Rules.IsKind(item.ID)) { 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 Item Prefab(byte kind) { if (kind != 246) { return SmallPrefab; } return BigPrefab; } public static void Register() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown if ((Object)(object)SmallPrefab != (Object)null || (Object)(object)InstanceFinder.NetworkManager == (Object)null) { return; } Dictionary dictionary = (Dictionary)AccessTools.Field(typeof(GameInfo), "_idToSpawnable").GetValue(null); if (dictionary.Count != 0) { if (dictionary.ContainsKey(245) || dictionary.ContainsKey(246)) { throw new Exception("Lantern Mod item IDs 245 or 246 are already occupied."); } Item? obj = (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)obj == (Object)null) { throw new Exception("No compatible base item prefab was found."); } storage = new GameObject("Lantern Mod prefab storage"); storage.SetActive(false); Object.DontDestroyOnLoad((Object)(object)storage); SmallPrefab = Build(obj, 245, 42424, pole: false); BigPrefab = Build(obj, 246, 42425, pole: true); Plugin.Log("Registered Camping Lantern and Tiki Torch network items."); } } private static Item Build(Item source, byte kind, ushort collectionId, bool pole) { //IL_0146: 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_0192: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: 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_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Expected O, but got Unknown //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = (Dictionary)AccessTools.Field(typeof(GameInfo), "_idToSpawnable").GetValue(null); Item val = Object.Instantiate(source, storage.transform); ((Object)val).name = Rules.TypeName(kind); AccessTools.Field(typeof(Item), "_id").SetValue(val, kind); AccessTools.Field(typeof(Item), "_cost").SetValue(val, Rules.Price(kind)); AccessTools.Field(typeof(Item), "_worth").SetValue(val, Rules.Price(kind) / 2); AccessTools.Field(typeof(Item), "_ignoredBySeagulls").SetValue(val, true); AccessTools.Field(typeof(Item), "_ignoredByMoneyNPC").SetValue(val, false); AccessTools.Field(typeof(Item), "_ignoredByCloseDots").SetValue(val, false); AccessTools.Field(typeof(Item), "_heldPos").SetValue(val, (object)(pole ? new Vector3(0.35f, -0.85f, 0.65f) : new Vector3(0.23f, -0.52f, 0.72f))); AccessTools.Field(typeof(Item), "_heldRot").SetValue(val, (object)(pole ? new Vector3(4f, 8f, -8f) : new Vector3(5f, 12f, 0f))); Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Collider[] componentsInChildren2 = ((Component)val).GetComponentsInChildren(true); foreach (Collider val2 in componentsInChildren2) { if (!val2.isTrigger) { val2.enabled = false; } } Light[] componentsInChildren3 = ((Component)val).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Behaviour)componentsInChildren3[i]).enabled = false; } GameObject val3 = new GameObject("LanternBodyCollider"); val3.transform.SetParent(((Component)val).transform, false); BoxCollider val4 = val3.AddComponent(); val4.center = (pole ? new Vector3(0f, 0.88f, 0f) : new Vector3(0f, 0.26f, 0f)); val4.size = (pole ? new Vector3(0.52f, 1.76f, 0.44f) : new Vector3(0.39f, 0.51f, 0.33f)); AccessTools.Field(typeof(Item), "_worldColliders").SetValue(val, new Collider[1] { (Collider)val4 }); Collider val5 = (Collider)AccessTools.Field(typeof(Item), "_pickUpCollider").GetValue(val); if ((Object)(object)val5 != (Object)null) { val5.isTrigger = true; } if (val5 is SphereCollider) { SphereCollider val6 = (SphereCollider)val5; val6.radius = (pole ? 0.92f : 0.36f); val6.center = (pole ? new Vector3(0f, 0.8f, 0f) : new Vector3(0f, 0.26f, 0f)); } AccessTools.Field(typeof(Item), "_outOfHandHolder").SetValue(val, null); AccessTools.Field(typeof(Item), "_inHandHolder").SetValue(val, null); LanternVisual lanternVisual = ((Component)val).gameObject.AddComponent(); lanternVisual.Build(pole); AccessTools.Field(typeof(Item), "_mesh").SetValue(val, lanternVisual.InventoryMesh); AccessTools.Field(typeof(Item), "_inventoryMeshScale").SetValue(val, pole ? 0.35f : 0.52f); AccessTools.Field(typeof(Item), "_inventoryMeshPos").SetValue(val, (object)(pole ? new Vector3(0f, -0.55f, 0f) : new Vector3(0f, -0.2f, 0f))); AccessTools.Field(typeof(Item), "_inventoryMeshRot").SetValue(val, (object)new Vector3(15f, 30f, 0f)); AccessTools.Field(typeof(Item), "_renderers").SetValue(val, (from r in ((Component)lanternVisual).GetComponentsInChildren(true) where r.enabled select r).ToList()); NetworkObject component = ((Component)val).GetComponent(); component.SetIsSpawnable(true); PrefabObjects prefabObjects = InstanceFinder.NetworkManager.GetPrefabObjects(collectionId, true); if (prefabObjects.GetObjectCount() != 0) { throw new Exception("Lantern Mod network collection " + collectionId + " is occupied."); } prefabObjects.AddObject(component, false, true); dictionary.Add(kind, val); ((Dictionary)AccessTools.Field(typeof(GameInfo), "_allItems").GetValue(null)).Add(kind, val); ((Dictionary)AccessTools.Field(typeof(GameInfo), "_nameToSpawnable").GetValue(null)).Add((kind == 246) ? "lanternmodpole" : "lanternmodcamping", val); return val; } } public sealed class LanternVisual : MonoBehaviour { private static Material red; private static Material dark; private static Material wood; private static Material rope; private static Material glass; private static Material glow; private Light lamp; private Renderer glowRenderer; private List bodyRenderers = new List(); private List standRenderers = new List(); private HashSet privateMaterials = new HashSet(); private bool pole; private Vector3 lastBody = new Vector3(-9f, -9f, -9f); private Vector3 lastStand = new Vector3(-9f, -9f, -9f); private int lastStaticSignature = int.MinValue; public Mesh InventoryMesh { get; private set; } private bool IsPole { get { Item component = ((Component)this).GetComponent(); if (!((Object)(object)component != (Object)null)) { return pole; } return component.ID == 246; } } private static Material Mat(Color c, float metallic = 0f) { //IL_0018: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Material val = new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard")) { color = c }; if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", metallic * 0.55f); } return val; } public void Build(bool isPole) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_012c: 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_0172: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) pole = isPole; if ((Object)(object)red == (Object)null) { red = Mat(new Color(0.62f, 0.035f, 0.025f), 0.65f); dark = Mat(new Color(0.045f, 0.05f, 0.06f), 0.8f); wood = Mat(new Color(0.3f, 0.13f, 0.045f)); rope = Mat(new Color(0.55f, 0.32f, 0.1f)); glass = Mat(new Color(1f, 0.62f, 0.18f)); glow = Mat(new Color(1f, 0.43f, 0.04f)); if (glow.HasProperty("_EmissionColor")) { glow.EnableKeyword("_EMISSION"); glow.SetColor("_EmissionColor", new Color(1f, 0.24f, 0.01f) * 3f); } } Transform transform = new GameObject(isPole ? "ElevatedLanternModel" : "CampingLanternModel").transform; transform.SetParent(((Component)this).transform, false); transform.localScale = (isPole ? (Vector3.one * 0.8f) : (Vector3.one * 0.54f)); if (isPole) { BuildTiki(transform); } else { BuildCamping(transform); } } private Transform Part(string name, Transform parent, PrimitiveType primitive, Vector3 pos, Vector3 scale, Material material, Quaternion rotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) GameObject val = GameObject.CreatePrimitive(primitive); ((Object)val).name = name; val.transform.SetParent(parent, false); val.transform.localPosition = pos; val.transform.localRotation = rotation; val.transform.localScale = scale; Object.DestroyImmediate((Object)(object)val.GetComponent()); val.GetComponent().sharedMaterial = material; if ((Object)(object)InventoryMesh == (Object)null) { InventoryMesh = val.GetComponent().sharedMesh; } return val.transform; } private void Bar(Transform root, string name, Vector3 a, Vector3 b, float width, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; Part(name, root, (PrimitiveType)2, (a + b) * 0.5f, new Vector3(width, ((Vector3)(ref val)).magnitude * 0.5f, width), material, Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val)).normalized)); } private void AddLamp(Transform root, Vector3 center, float scale) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) Part("LampBottom", root, (PrimitiveType)2, center + Vector3.down * 0.28f * scale, new Vector3(0.24f * scale, 0.055f * scale, 0.24f * scale), dark, Quaternion.identity); Part("LampTop", root, (PrimitiveType)2, center + Vector3.up * 0.29f * scale, new Vector3(0.25f * scale, 0.065f * scale, 0.25f * scale), dark, Quaternion.identity); Transform val = Part("WarmGlow", root, (PrimitiveType)0, center, new Vector3(0.25f, 0.42f, 0.25f) * scale, glow, Quaternion.identity); glowRenderer = ((Component)val).GetComponent(); for (int i = 0; i < 4; i++) { float num = (float)i * (float)Math.PI * 0.5f; Bar(root, "Cage", center + new Vector3(Mathf.Cos(num) * 0.22f, -0.27f, Mathf.Sin(num) * 0.22f) * scale, center + new Vector3(Mathf.Cos(num) * 0.22f, 0.28f, Mathf.Sin(num) * 0.22f) * scale, 0.018f * scale, dark); } GameObject val2 = new GameObject("Lantern Light"); val2.layer = 0; val2.transform.SetParent(root, false); val2.transform.localPosition = center; lamp = val2.AddComponent(); lamp.type = (LightType)2; lamp.shadows = (LightShadows)0; lamp.renderMode = (LightRenderMode)1; lamp.cullingMask = -1; lamp.bounceIntensity = 1.35f; ((Behaviour)lamp).enabled = false; } private void BuildCamping(Transform root) { BuildLanternHead(root, 0f, 1f); } private void BuildLanternHead(Transform root, float baseY, float scale) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_013c: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_01a5: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0245: Unknown result type (might be due to invalid IL or missing references) Body(Part("FlatBase", root, (PrimitiveType)2, new Vector3(0f, baseY + 0.07f * scale, 0f), new Vector3(0.37f, 0.07f, 0.37f) * scale, red, Quaternion.identity)); Body(Part("FuelTank", root, (PrimitiveType)2, new Vector3(0f, baseY + 0.2f * scale, 0f), new Vector3(0.34f, 0.12f, 0.34f) * scale, red, Quaternion.identity)); Body(Part("BaseShoulder", root, (PrimitiveType)2, new Vector3(0f, baseY + 0.34f * scale, 0f), new Vector3(0.39f, 0.07f, 0.39f) * scale, red, Quaternion.identity)); Transform val = FacetedBulb(root, new Vector3(0f, baseY + 0.69f * scale, 0f), 0.92f * scale); glowRenderer = ((Component)val).GetComponent(); Body(Part("UpperShoulder", root, (PrimitiveType)2, new Vector3(0f, baseY + 1f * scale, 0f), new Vector3(0.38f, 0.07f, 0.38f) * scale, red, Quaternion.identity)); Body(Part("TopCap", root, (PrimitiveType)2, new Vector3(0f, baseY + 1.11f * scale, 0f), new Vector3(0.25f, 0.08f, 0.25f) * scale, red, Quaternion.identity)); Body(Part("TopButton", root, (PrimitiveType)2, new Vector3(0f, baseY + 1.21f * scale, 0f), new Vector3(0.14f, 0.055f, 0.14f) * scale, red, Quaternion.identity)); GameObject val2 = new GameObject("Lantern Light"); val2.layer = 0; val2.transform.SetParent(root, false); val2.transform.localPosition = new Vector3(0f, baseY + 0.69f * scale, 0f); lamp = val2.AddComponent(); lamp.type = (LightType)2; lamp.shadows = (LightShadows)0; lamp.renderMode = (LightRenderMode)1; lamp.cullingMask = -1; lamp.bounceIntensity = 1.35f; ((Behaviour)lamp).enabled = false; } private Transform FacetedBulb(Transform root, Vector3 center, float scale) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_019b: 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) float[] array = new float[5] { -0.36f, -0.25f, 0.08f, 0.28f, 0.36f }; float[] array2 = new float[5] { 0.15f, 0.25f, 0.25f, 0.15f, 0.13f }; List list = new List(); List list2 = new List(); List list3 = new List(); for (int i = 0; i < array.Length; i++) { for (int j = 0; j < 8; j++) { float num = (float)j * (float)Math.PI * 2f / 8f; list.Add(center + new Vector3(Mathf.Cos(num) * array2[i], array[i], Mathf.Sin(num) * array2[i]) * scale); list3.Add(new Vector2((float)j / 8f, (float)i / (float)(array.Length - 1))); } } for (int k = 0; k < array.Length - 1; k++) { for (int l = 0; l < 8; l++) { int num2 = (l + 1) % 8; int item = k * 8 + l; int item2 = k * 8 + num2; int item3 = (k + 1) * 8 + l; int item4 = (k + 1) * 8 + num2; list2.Add(item); list2.Add(item3); list2.Add(item2); list2.Add(item2); list2.Add(item3); list2.Add(item4); } } GameObject val = new GameObject("FacetedGlass"); val.transform.SetParent(root, false); Mesh val2 = new Mesh { name = "Camping Lantern Faceted Glass" }; val2.SetVertices(list); val2.SetTriangles(list2, 0); val2.SetUVs(0, list3); val2.RecalculateNormals(); val2.RecalculateBounds(); val.AddComponent().sharedMesh = val2; ((Renderer)val.AddComponent()).sharedMaterial = glow; return val.transform; } private void BuildTiki(Transform root) { //IL_0018: 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_0036: 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_0071: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) Stand(Part("WoodenFoot", root, (PrimitiveType)2, new Vector3(0f, 0.07f, 0f), new Vector3(0.34f, 0.07f, 0.34f), wood, Quaternion.identity)); Stand(Part("WoodenStand", root, (PrimitiveType)2, new Vector3(0f, 0.72f, 0f), new Vector3(0.12f, 0.65f, 0.12f), wood, Quaternion.identity)); for (int i = 0; i < 3; i++) { Stand(Part("StandNode" + i, root, (PrimitiveType)2, new Vector3(0f, 0.28f + (float)i * 0.43f, 0f), new Vector3(0.145f, 0.035f, 0.145f), rope, Quaternion.identity)); } BuildLanternHead(root, 1.31f, 0.68f); } private void Body(Transform value) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Renderer val = (((Object)(object)value == (Object)null) ? null : ((Component)value).GetComponent()); if ((Object)(object)val != (Object)null) { (((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent()).stand = false; val.sharedMaterial = new Material(val.sharedMaterial); bodyRenderers.Add(val); } } private void BodyBar(Transform root, string name, Vector3 a, Vector3 b, float width, Material material) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) int childCount = root.childCount; Bar(root, name, a, b, width, material); if (root.childCount > childCount) { Body(root.GetChild(root.childCount - 1)); } } private void Stand(Transform value) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Renderer val = (((Object)(object)value == (Object)null) ? null : ((Component)value).GetComponent()); if ((Object)(object)val != (Object)null) { (((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent()).stand = true; val.sharedMaterial = new Material(val.sharedMaterial); standRenderers.Add(val); } } private void EnsureColorTargets() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown if (bodyRenderers == null) { bodyRenderers = new List(); } if (standRenderers == null) { standRenderers = new List(); } if (privateMaterials == null) { privateMaterials = new HashSet(); } bodyRenderers.Clear(); standRenderers.Clear(); LanternTintTarget[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (LanternTintTarget lanternTintTarget in componentsInChildren) { if ((Object)(object)lanternTintTarget == (Object)null) { continue; } Renderer component = ((Component)lanternTintTarget).GetComponent(); if (!((Object)(object)component == (Object)null)) { if (!privateMaterials.Contains(component) && (Object)(object)component.sharedMaterial != (Object)null) { component.sharedMaterial = new Material(component.sharedMaterial) { name = ((Object)component.sharedMaterial).name + " (Lantern Instance)" }; privateMaterials.Add(component); } if (lanternTintTarget.stand) { standRenderers.Add(component); } else { bodyRenderers.Add(component); } } } if ((Object)(object)glowRenderer == (Object)null) { Transform val = ((IEnumerable)((Component)this).GetComponentsInChildren(true)).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "FacetedGlass" || ((Object)t).name == "WarmGlow")); if ((Object)(object)val != (Object)null) { glowRenderer = ((Component)val).GetComponent(); } } } public void ApplyBody(Vector3 value) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) EnsureColorTargets(); bool isPole = IsPole; if (value.x < 0f) { value = Rules.DefaultBody((byte)(isPole ? 246 : 245)); } ((Vector3)(ref value))..ctor(Rules.ColorChannel(value.x), Rules.ColorChannel(value.y), Rules.ColorChannel(value.z)); lastBody = value; Color val = default(Color); ((Color)(ref val))..ctor(value.x, value.y, value.z, 1f); foreach (Renderer bodyRenderer in bodyRenderers) { if ((Object)(object)bodyRenderer == (Object)null) { continue; } Material sharedMaterial = bodyRenderer.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null) { sharedMaterial.color = val; if (sharedMaterial.HasProperty("_BaseColor")) { sharedMaterial.SetColor("_BaseColor", val); } if (sharedMaterial.HasProperty("_Color")) { sharedMaterial.SetColor("_Color", val); } } MaterialPropertyBlock val2 = new MaterialPropertyBlock(); bodyRenderer.GetPropertyBlock(val2); val2.SetColor("_BaseColor", val); val2.SetColor("_Color", val); bodyRenderer.SetPropertyBlock(val2); } } public void ApplyStand(Vector3 value) { //IL_000f: 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_0030: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00f1: 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_00a3: 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_00d5: Unknown result type (might be due to invalid IL or missing references) EnsureColorTargets(); if (!IsPole) { return; } if (value.x < 0f) { value = Rules.DefaultStand(); } ((Vector3)(ref value))..ctor(Rules.ColorChannel(value.x), Rules.ColorChannel(value.y), Rules.ColorChannel(value.z)); lastStand = value; Color val = default(Color); ((Color)(ref val))..ctor(value.x, value.y, value.z, 1f); foreach (Renderer standRenderer in standRenderers) { if ((Object)(object)standRenderer == (Object)null) { continue; } Material sharedMaterial = standRenderer.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null) { sharedMaterial.color = val; if (sharedMaterial.HasProperty("_BaseColor")) { sharedMaterial.SetColor("_BaseColor", val); } if (sharedMaterial.HasProperty("_Color")) { sharedMaterial.SetColor("_Color", val); } } MaterialPropertyBlock val2 = new MaterialPropertyBlock(); standRenderer.GetPropertyBlock(val2); val2.SetColor("_BaseColor", val); val2.SetColor("_Color", val); standRenderer.SetPropertyBlock(val2); } } public void ResetStaticLight(LanternData data) { //IL_01ba: 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_01bf: 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_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) if (data == null || data.effectMode != 0) { return; } EnsureColorTargets(); if ((Object)(object)lamp == (Object)null) { lamp = ((Component)this).GetComponentInChildren(true); } Item component = ((Component)this).GetComponent(); Plugin instance = Plugin.Instance; bool flag = data.deployed && (Object)(object)component != (Object)null && (Object)(object)component.SyncedHolder == (Object)null && ((Object)(object)instance == (Object)null || instance.CanRenderLight(data.serial)); int num = 17; num = num * 31 + (flag ? 1 : 0); num = num * 31 + (data.lightOn ? 1 : 0); num = num * 31 + (data.useTemperature ? 1 : 0); num = num * 31 + Mathf.RoundToInt(data.intensity * 1000f); num = num * 31 + Mathf.RoundToInt(data.temperature); num = num * 31 + Mathf.RoundToInt(data.lightColor.x * 255f); num = num * 31 + Mathf.RoundToInt(data.lightColor.y * 255f); num = num * 31 + Mathf.RoundToInt(data.lightColor.z * 255f); if (num == lastStaticSignature) { return; } lastStaticSignature = num; if ((Object)(object)lamp != (Object)null) { bool isPole = IsPole; float num2 = Rules.Intensity(data.intensity); float num3 = 1f + (float)(Math.Abs(data.serial) % 97) * 0.0001f; Color val = (Color)(data.useTemperature ? Mathf.CorrelatedColorTemperatureToRGB(Rules.Temperature(data.temperature)) : new Color(Rules.ColorChannel(data.lightColor.x), Rules.ColorChannel(data.lightColor.y), Rules.ColorChannel(data.lightColor.z))); lamp.color = val; lamp.intensity = (isPole ? 12f : 7f) * num2 * num3; lamp.range = (isPole ? 18f : 12f) * Mathf.Lerp(0.75f, 1.25f, (num2 - 0.1f) / 1.9f); bool flag2 = flag && data.lightOn; if (((Behaviour)lamp).enabled != flag2) { ((Behaviour)lamp).enabled = flag2; } if ((Object)(object)glowRenderer != (Object)null) { MaterialPropertyBlock val2 = new MaterialPropertyBlock(); glowRenderer.GetPropertyBlock(val2); val2.SetColor("_BaseColor", val); val2.SetColor("_Color", val); val2.SetColor("_EmissionColor", val * 4f); glowRenderer.SetPropertyBlock(val2); } } } private void LateUpdate() { //IL_004c: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_023c: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Expected O, but got Unknown //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) Item component = ((Component)this).GetComponent(); Plugin instance = Plugin.Instance; LanternData lanternData = (((Object)(object)instance == (Object)null) ? null : instance.Find(LanternItem.Serial(component))); EnsureColorTargets(); if ((Object)(object)lamp == (Object)null) { lamp = ((Component)this).GetComponentInChildren(true); } if (lanternData != null) { ApplyBody(lanternData.bodyColor); ApplyStand(lanternData.standColor); } bool flag = lanternData != null && lanternData.deployed && (Object)(object)component != (Object)null && (Object)(object)component.SyncedHolder == (Object)null && ((Object)(object)instance == (Object)null || instance.CanRenderLight(lanternData.serial)); if (flag) { ((Component)this).transform.SetPositionAndRotation(lanternData.position, lanternData.Rotation); } if ((Object)(object)lamp == (Object)null) { return; } if (lanternData == null) { if (((Behaviour)lamp).enabled) { ((Behaviour)lamp).enabled = false; } return; } if (lanternData.effectMode == 0) { ResetStaticLight(lanternData); return; } lastStaticSignature = int.MinValue; float num = 1f; if (flag && lanternData.lightOn) { float num2 = Rules.Frequency(lanternData.frequency); num = ((lanternData.effectMode != 1) ? (0.15f + 0.85f * (Mathf.Sin(Time.time * num2 * (float)Math.PI * 2f) * 0.5f + 0.5f)) : ((Mathf.Repeat(Time.time * num2, 1f) < 0.5f) ? 1f : 0f)); } bool flag2 = flag && lanternData.lightOn && num > 0.01f; if (((Behaviour)lamp).enabled != flag2) { ((Behaviour)lamp).enabled = flag2; } if (flag) { bool isPole = IsPole; float num3 = Rules.Intensity(lanternData.intensity); float num4 = 1f + (float)(Math.Abs(lanternData.serial) % 97) * 0.0001f; Color val = (Color)(lanternData.useTemperature ? Mathf.CorrelatedColorTemperatureToRGB(Rules.Temperature(lanternData.temperature)) : new Color(Rules.ColorChannel(lanternData.lightColor.x), Rules.ColorChannel(lanternData.lightColor.y), Rules.ColorChannel(lanternData.lightColor.z))); lamp.color = val; lamp.intensity = (isPole ? 12f : 7f) * num3 * num4 * num; lamp.range = (isPole ? 18f : 12f) * Mathf.Lerp(0.75f, 1.25f, (num3 - 0.1f) / 1.9f); if ((Object)(object)glowRenderer != (Object)null) { MaterialPropertyBlock val2 = new MaterialPropertyBlock(); glowRenderer.GetPropertyBlock(val2); val2.SetColor("_BaseColor", val * num); val2.SetColor("_Color", val * num); val2.SetColor("_EmissionColor", val * (4f * num)); glowRenderer.SetPropertyBlock(val2); } } } } [BepInPlugin("ponyfisher.howtofish.lanternmod", "Lantern Mod", "0.1.10")] [DefaultExecutionOrder(29400)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "ponyfisher.howtofish.lanternmod"; public static Plugin Instance; public List Current = new List(); public int Selected; public bool Open; public bool EditorOpen; public int EditorTab; public string Status = "Buy lights from money vendors, then interact with a deployed lantern to configure it."; 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 nearMoneyVendor; private Component hoveredInteractable; private float nextTick; private float nextSave; private float nextState; private float nextIconRefresh; private float nextHello; private float nextVendorScan; private float nextLightBudget; private float statusUntil; private int sequence; private ConfigEntry maximumRenderedLights; private ConfigEntry unlimitedRenderedLights; private readonly HashSet renderAllowed = new HashSet(); private readonly Dictionary lastSequence = new Dictionary(); private readonly Dictionary rateLimit = new Dictionary(); private readonly Dictionary items = new Dictionary(); private float useStarted; private Item activeTarget; private bool holdFired; private GUIStyle hintStyle; private GUIStyle titleStyle; private GUIStyle headerStyle; private GUIStyle labelStyle; private GUIStyle statusStyle; private GUIStyle buttonStyle; private GUIStyle toggleStyle; private Vector2 listScroll; private string renameDraft = ""; private string maxLightsDraft = "16"; private int draftSerial; private int editorDraftSerial; private int bodyPartTab; private float intensityDraft = 1f; private float tempDraft = 3200f; private float frequencyDraft = 1f; private Vector3 bodyDraft; private Vector3 standDraft; private Vector3 lightColorDraft; private bool lightBudgetLoaded; private bool unlimitedDraft; public int MaximumRenderedLights { get { if (maximumRenderedLights != null) { return Mathf.Clamp(maximumRenderedLights.Value, 1, 256); } return 16; } } public bool UnlimitedRenderedLights { get { if (unlimitedRenderedLights != null) { return unlimitedRenderedLights.Value; } return true; } } public static void Log(string value) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)value); } } private void Awake() { //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown Instance = this; maximumRenderedLights = ((BaseUnityPlugin)this).Config.Bind("Rendering", "MaximumRenderedLights", 16, "Maximum number of nearest deployed lantern lights rendered for this player when Unlimited is off."); unlimitedRenderedLights = ((BaseUnityPlugin)this).Config.Bind("Rendering", "UnlimitedRenderedLights", true, "Render every deployed Lantern Mod light and raise the URP additional-light budget to its supported maximum."); savePath = Path.Combine(Paths.ConfigPath, "LanternMod-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 = "Lantern save data could not be read; actions are paused."; ((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.lanternmod"); harmony.PatchAll(typeof(Plugin).Assembly); Log("Lantern Mod 0.1.10 loaded. Interact with a lantern to open its controls."); } private void Update() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_0113: 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_011c: 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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; UpdateInteraction(); if ((Object)(object)manager != (Object)(object)InstanceFinder.NetworkManager) { RegisterNetwork(); } if (!registrationFailed && (Object)(object)LanternItem.SmallPrefab == (Object)null) { try { LanternItem.Register(); } catch (Exception ex) { registrationFailed = true; Status = "Lantern item registration failed; see the BepInEx log."; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } if ((Object)(object)LanternItem.SmallPrefab != (Object)null && Time.unscaledTime >= nextVendorScan) { nextVendorScan = Time.unscaledTime + 0.15f; nearMoneyVendor = (Object)(object)FocusedMoneyVendor(Player.LocalPlayer, 5f) != (Object)null; } if (!Open && nearMoneyVendor && current != null) { if (((ButtonControl)current.digit0Key).wasPressedThisFrame) { Send("buy", 245); } else if (((ButtonControl)current.minusKey).wasPressedThisFrame) { Send("buy", 246); } } if ((Object)(object)LanternItem.SmallPrefab != (Object)null && Time.unscaledTime >= nextIconRefresh) { nextIconRefresh = Time.unscaledTime + 0.15f; LanternInventoryIcon.RefreshAll(); } if (Time.unscaledTime >= nextLightBudget) { nextLightBudget = Time.unscaledTime + 0.35f; RefreshLightBudget(); } 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.lanterns; items.Clear(); lastSequence.Clear(); rateLimit.Clear(); } if (Time.unscaledTime >= nextTick) { nextTick = Time.unscaledTime + 0.2f; AuditWorld(); } if (Time.unscaledTime >= nextState) { nextState = Time.unscaledTime + 0.35f; Broadcast(); } if (Time.unscaledTime >= nextSave) { nextSave = Time.unscaledTime + 8f; Persist(); } } else if (!InstanceFinder.IsClientStarted) { world = null; Current = new List(); items.Clear(); } if (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; } } public void Toggle(bool value) { Open = value; if (!Open) { EditorOpen = false; Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } else { SelectUsable(); } } 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); } } public LanternData Find(int serial) { return Current.FirstOrDefault((LanternData x) => x.serial == serial); } public void SelectUsable() { Player p = Player.LocalPlayer; if ((Object)(object)p == (Object)null) { return; } Item heldItem = p.Holding.HeldItem; if (LanternItem.Is(heldItem)) { Selected = LanternItem.Serial(heldItem); } else if (Find(Selected) == null || Find(Selected).owner != p.SteamID) { Selected = Current.FirstOrDefault((LanternData x) => x.available && x.owner == p.SteamID)?.serial ?? 0; } } 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 = "Lantern Mod could not save; actions are paused."; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } public void Send(string action, int argument = 0, float value = 0f, string text = null, Vector3 position = default(Vector3), Vector3 normal = default(Vector3), int serial = 0) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.LocalPlayer == (Object)null) { SetStatus("Load into a game first."); return; } Command command = new Command { action = action, serial = ((serial > 0) ? serial : Selected), argument = argument, value = value, text = text, position = position, normal = normal, 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") { SetStatus("Waiting for the host..."); } } } private void Receive(NetworkConnection connection, RequestMessage message, Channel channel) { if (!InstanceFinder.IsServerStarted || message.json == null || message.json.Length > 4096) { return; } try { Command command = Codec.FromJson(message.json); if (command != null && command.protocol == 1 && command.sequence > 0 && (!lastSequence.TryGetValue(connection.ClientId, out var value) || command.sequence > value) && (!rateLimit.TryGetValue(connection.ClientId, out var value2) || !(Time.unscaledTime - value2 < 0.08f))) { lastSequence[connection.ClientId] = command.sequence; rateLimit[connection.ClientId] = Time.unscaledTime; Player val = ((IEnumerable)Object.FindObjectsByType()).FirstOrDefault((Func)((Player x) => ((NetworkBehaviour)x).Owner == connection)); if ((Object)(object)val != (Object)null) { Execute(val, command, connection); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Rejected Lantern Mod request: " + ex.Message)); } } private void SetStatus(string value) { Status = value; statusUntil = Time.unscaledTime + 4f; } 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) { SetStatus(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); if (reply != null) { SetStatus(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 > 250000) { return; } Snapshot snapshot = Codec.FromJson(message.json); if (snapshot == null || snapshot.protocol != 1 || snapshot.lanterns == null) { return; } Current = snapshot.lanterns; foreach (LanternData item in Current) { ApplyBodyNow(item); if (item.effectMode == 0) { ResetStaticNow(item); } } } private void Broadcast() { if ((Object)(object)manager != (Object)null && world != null) { manager.ServerManager.Broadcast(new StateMessage { json = Codec.ToJson(new Snapshot { world = world.name, lanterns = Current }) }, true, (Channel)0); } } private void Scan() { items.Clear(); Item[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (Item val in array) { if (LanternItem.Is(val) && ((NetworkBehaviour)val).IsSpawned && !((NetworkBehaviour)val).IsDeinitializing) { int num = LanternItem.Serial(val); if (num > 0 && !items.ContainsKey(num)) { items.Add(num, val); } } } } public Item FindItem(int serial) { if (items.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 x) => LanternItem.Is(x) && ((NetworkBehaviour)x).IsSpawned && !((NetworkBehaviour)x).IsDeinitializing && LanternItem.Serial(x) == serial)); if ((Object)(object)value != (Object)null) { items[serial] = value; } return value; } public void ApplyBodyNow(LanternData data) { //IL_003c: 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) if (data == null) { return; } LanternVisual[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (LanternVisual lanternVisual in array) { if (!((Object)(object)lanternVisual == (Object)null)) { Item component = ((Component)lanternVisual).GetComponent(); if ((Object)(object)component != (Object)null && LanternItem.Serial(component) == data.serial) { lanternVisual.ApplyBody(data.bodyColor); lanternVisual.ApplyStand(data.standColor); } } } } public void ResetStaticNow(LanternData data) { if (data == null) { return; } LanternVisual[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (LanternVisual lanternVisual in array) { if (!((Object)(object)lanternVisual == (Object)null)) { Item component = ((Component)lanternVisual).GetComponent(); if ((Object)(object)component != (Object)null && LanternItem.Serial(component) == data.serial) { lanternVisual.ResetStaticLight(data); } } } } public bool CanRenderLight(int serial) { if (!UnlimitedRenderedLights) { return renderAllowed.Contains(serial); } return true; } public void SetLightBudget(bool unlimited, int maximum) { if (unlimitedRenderedLights != null) { unlimitedRenderedLights.Value = unlimited; } if (maximumRenderedLights != null) { maximumRenderedLights.Value = Mathf.Clamp(maximum, 1, 256); } ((BaseUnityPlugin)this).Config.Save(); RefreshLightBudget(); SetStatus(unlimited ? "All Lantern Mod lights will render." : ("Rendering the nearest " + MaximumRenderedLights + " Lantern Mod lights.")); } private void RefreshLightBudget() { //IL_00a8: 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_00b9: Unknown result type (might be due to invalid IL or missing references) renderAllowed.Clear(); List list = Current.Where((LanternData d) => d != null && d.available && d.deployed).ToList(); if (UnlimitedRenderedLights) { foreach (LanternData item in list) { renderAllowed.Add(item.serial); } } else { Vector3 origin = (((Object)(object)Player.LocalPlayer != (Object)null && (Object)(object)Player.LocalPlayer.CamObject != (Object)null) ? Player.LocalPlayer.CamObject.position : Vector3.zero); foreach (LanternData item2 in list.OrderBy(delegate(LanternData d) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = d.position - origin; return ((Vector3)(ref val)).sqrMagnitude; }).Take(MaximumRenderedLights)) { renderAllowed.Add(item2.serial); } } ApplyPipelineLightBudget(UnlimitedRenderedLights ? 256 : MaximumRenderedLights); foreach (LanternData item3 in list) { if (item3.effectMode == 0) { ResetStaticNow(item3); } } } private void ApplyPipelineLightBudget(int requested) { try { RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline; if (!((Object)(object)currentRenderPipeline == (Object)null)) { Type type = ((object)currentRenderPipeline).GetType(); int num = Mathf.Clamp(requested, 1, 256); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo property = type.GetProperty("maxAdditionalLightsCount", bindingAttr); if (property != null && property.CanWrite) { property.SetValue(currentRenderPipeline, num, null); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not raise the render-pipeline light budget: " + ex.Message)); } } private void AuditWorld() { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ae: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) Scan(); foreach (KeyValuePair item in items) { Item value = item.Value; LanternData lanternData = Find(item.Key); if (lanternData == null) { Player syncedHolder = value.SyncedHolder; lanternData = new LanternData { serial = item.Key, kind = value.ID, owner = (((Object)(object)syncedHolder == (Object)null) ? 0 : syncedHolder.SteamID), ownerName = (((Object)(object)syncedHolder == (Object)null) ? null : syncedHolder.SteamName), name = Rules.TypeName(value.ID), bodyColor = Rules.DefaultBody(value.ID), standColor = Rules.DefaultStand() }; Current.Add(lanternData); save.nextSerial = Math.Max(save.nextSerial, item.Key + 1); } lanternData.available = true; lanternData.kind = value.ID; if (lanternData.kind == 246 && lanternData.name == "Pole Light") { lanternData.name = Rules.TypeName(lanternData.kind); } if (lanternData.bodyColor.x < 0f) { lanternData.bodyColor = Rules.DefaultBody(lanternData.kind); } if (lanternData.standColor.x < 0f) { lanternData.standColor = Rules.DefaultStand(); } if (lanternData.frequency <= 0f) { lanternData.frequency = 1f; } if ((Object)(object)value.SyncedHolder != (Object)null) { lanternData.deployed = false; } else if (lanternData.deployed) { value.RigidbodySync.SetKinematic(true); if (Vector3.Distance(((Component)value).transform.position, lanternData.position) > 0.05f) { value.RigidbodySync.TeleportToPosRot(lanternData.position, lanternData.Rotation, (float[])null, (Quaternion[])null); } } } foreach (LanternData item2 in Current) { item2.available = items.ContainsKey(item2.serial); } } 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 Spawn(Player player, int slot, int serial, byte kind) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Item val = Object.Instantiate(LanternItem.Prefab(kind), ((Component)player).transform.position + Vector3.up, Quaternion.identity, Server.Instance.DynamicObjectsHolder); val.LoadFromSave(new SavedItem { Exists = true, ItemID = kind, BettingMultiplier = serial, Weight = 1f, KillScoreMultiplier = 1f }); InstanceFinder.ServerManager.Spawn(((Component)val).gameObject, (NetworkConnection)null, default(Scene)); 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("Inventory did not accept the lantern."); } return val; } private bool Ground(Player p, Command cmd, Item item, out RaycastHit hit) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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) hit = default(RaycastHit); if (!Rules.Finite(cmd.position.x) || !Rules.Finite(cmd.position.y) || !Rules.Finite(cmd.position.z) || !Rules.SurfaceAllowed(cmd.normal.y) || Vector3.Distance(cmd.position, p.CamObject.position) > 8.35f) { return false; } Vector3 normalized = ((Vector3)(ref cmd.normal)).normalized; foreach (RaycastHit item2 in from x in Physics.RaycastAll(cmd.position + normalized * 0.35f, -normalized, 0.8f, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref x)).distance select x) { RaycastHit current = item2; if (((Component)((RaycastHit)(ref current)).collider).gameObject.layer != LayerMask.NameToLayer("Water") && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() != (Object)null) && Rules.SurfaceAllowed(((RaycastHit)(ref current)).normal.y) && !(Vector3.Dot(((RaycastHit)(ref current)).normal, normalized) < 0.5f)) { hit = current; return true; } } return false; } private float Distance(Player p, Item item) { //IL_0006: 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_002f: 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) return Mathf.Min(Vector3.Distance(((Component)p).transform.position, ((Component)item).transform.position), ((Object)(object)p.CamObject == (Object)null) ? float.MaxValue : Vector3.Distance(p.CamObject.position, ((Component)item).transform.position)); } private void PutInInventory(Player p, Item item, LanternData data, Command cmd, NetworkConnection connection, string message) { int num = OpenSlot(p); bool flag = (Object)(object)p.Holding.HeldItem == (Object)null && (Object)(object)p.Holding.UninitializedHeldItem == (Object)null && (Object)(object)p.Inventory.SyncedCurItem == (Object)null; if (num < 0 && !flag) { Respond(cmd, connection, "Free an inventory slot or empty your hands first."); return; } data.deployed = false; item.RigidbodySync.SetKinematic(false); int value = p.Inventory._syncedCurSlot.Value; item.SetSyncedHolder(p, true); if (num >= 0) { p.Inventory.AddItem((byte)num, item); } item.ReconcileLocalHolderWithSyncedHolder(); if (num >= 0) { p.Inventory.ServerSetSyncedCurSlot(value); } Respond(cmd, connection, message, data.serial); Persist(); Broadcast(); } private void Execute(Player p, Command cmd, NetworkConnection connection) { //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_02da: 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_02e4: 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_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_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_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_06e8: Unknown result type (might be due to invalid IL or missing references) //IL_06ed: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) if (cmd.action == "hello") { Broadcast(); return; } if (!persistenceReady || world == null || (Object)(object)LanternItem.SmallPrefab == (Object)null || p.Dying.IsDead) { Respond(cmd, connection, "Lantern Mod is not ready on the host."); return; } Scan(); try { if (cmd.action == "buy") { byte kind = (byte)cmd.argument; if (!Rules.IsKind(kind)) { Respond(cmd, connection, "Unknown lantern type."); return; } if ((Object)(object)FocusedMoneyVendor(p, 5f) == (Object)null) { Respond(cmd, connection, "Move close to and look at a money vendor to buy a light."); return; } int num = OpenSlot(p); if (num < 0) { Respond(cmd, connection, "Free an inventory slot first."); return; } int value = Rules.Price(kind); if (!Wallet.Charge(p, value)) { Respond(cmd, connection, "You need $" + value.ToString("N0") + "."); return; } int num2 = save.nextSerial++; try { Spawn(p, num, num2, kind); } catch { Wallet.Credit(p, value); throw; } LanternData lanternData = new LanternData { serial = num2, kind = kind, owner = p.SteamID, ownerName = p.SteamName, name = Rules.TypeName(kind), bodyColor = Rules.DefaultBody(kind) }; Current.Add(lanternData); Persist(); Broadcast(); Respond(cmd, connection, lanternData.name + " purchased for $" + value.ToString("N0") + ".", num2); return; } LanternData lanternData2 = Find(cmd.serial); Item val = FindItem(cmd.serial); if (lanternData2 == null || (Object)(object)val == (Object)null) { Respond(cmd, connection, "That lantern is unavailable."); return; } if (lanternData2.owner != p.SteamID) { Respond(cmd, connection, "That lantern belongs to " + (string.IsNullOrEmpty(lanternData2.ownerName) ? "another player" : lanternData2.ownerName) + "."); return; } bool flag = (Object)(object)val.SyncedHolder == (Object)(object)p; if (cmd.action == "deploy") { if (!flag || lanternData2.deployed) { Respond(cmd, connection, "Hold that lantern before deploying it."); return; } if (!Ground(p, cmd, val, out var hit)) { Respond(cmd, connection, "Look at an upward-facing surface within 8 metres."); return; } val.SpawnFromInventory(); p.Inventory.RemoveItem(val); if ((Object)(object)val.Holder != (Object)null) { val.Drop(false, default(Vector3), default(Vector3)); } val.SetSyncedHolder((Player)null, true); val.ReconcileLocalHolderWithSyncedHolder(); if ((Object)(object)p.Holding.HeldItem == (Object)(object)val) { p.Hands.DropItem(false, val); p.Holding.DropItem(false, val); p.Holding.SetHeldItem((Item)null); } if ((Object)(object)p.Holding.UninitializedHeldItem == (Object)(object)val) { p.Holding.SetUninitializedHeldItem((Item)null); } lanternData2.position = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * 0.012f; lanternData2.surfaceNormal = ((RaycastHit)(ref hit)).normal; Quaternion curPlayerRot = p.CurPlayerRot; lanternData2.yaw = ((Quaternion)(ref curPlayerRot)).eulerAngles.y; lanternData2.deployed = true; val.RigidbodySync.ServerSetSyncedSimulator(((NetworkBehaviour)Server.Instance).Owner); val.RigidbodySync.TeleportToPosRot(lanternData2.position, lanternData2.Rotation, (float[])null, (Quaternion[])null); val.RigidbodySync.SetKinematic(true); Respond(cmd, connection, lanternData2.name + " deployed.", lanternData2.serial); } else { if (cmd.action == "pickup") { if (flag) { Respond(cmd, connection, "That lantern is already in your inventory."); } else if (Distance(p, val) > 6.35f) { Respond(cmd, connection, "Move within 6 metres of the lantern."); } else { PutInInventory(p, val, lanternData2, cmd, connection, lanternData2.name + " picked up."); } return; } if (cmd.action == "recall") { if (flag) { Respond(cmd, connection, "That lantern is already in your inventory.", lanternData2.serial); } else { PutInInventory(p, val, lanternData2, cmd, connection, lanternData2.name + " recalled to your inventory."); } return; } if (cmd.action == "rename") { lanternData2.name = Rules.CleanName(cmd.text, Rules.TypeName(lanternData2.kind)); Respond(cmd, connection, "Lantern renamed to " + lanternData2.name + ".", lanternData2.serial); } else if (cmd.action == "intensity") { lanternData2.intensity = Rules.Intensity(cmd.value); if (lanternData2.effectMode == 0) { ResetStaticNow(lanternData2); } Respond(cmd, connection, "Light intensity updated.", lanternData2.serial); } else if (cmd.action == "temperature") { lanternData2.temperature = Rules.Temperature(cmd.value); lanternData2.useTemperature = true; if (lanternData2.effectMode == 0) { ResetStaticNow(lanternData2); } Respond(cmd, connection, "Color temperature updated.", lanternData2.serial); } else if (cmd.action == "bodycolor") { lanternData2.bodyColor = new Vector3(Rules.ColorChannel(cmd.position.x), Rules.ColorChannel(cmd.position.y), Rules.ColorChannel(cmd.position.z)); ApplyBodyNow(lanternData2); Respond(cmd, connection, "Lantern body color saved.", lanternData2.serial); } else if (cmd.action == "standcolor") { if (lanternData2.kind != 246) { Respond(cmd, connection, "That lantern has no stand."); return; } lanternData2.standColor = new Vector3(Rules.ColorChannel(cmd.position.x), Rules.ColorChannel(cmd.position.y), Rules.ColorChannel(cmd.position.z)); ApplyBodyNow(lanternData2); Respond(cmd, connection, "Lantern stand color saved.", lanternData2.serial); } else if (cmd.action == "lightcolor") { lanternData2.lightColor = new Vector3(Rules.ColorChannel(cmd.position.x), Rules.ColorChannel(cmd.position.y), Rules.ColorChannel(cmd.position.z)); lanternData2.useTemperature = false; if (lanternData2.effectMode == 0) { ResetStaticNow(lanternData2); } Respond(cmd, connection, "Light color saved.", lanternData2.serial); } else if (cmd.action == "colormode") { lanternData2.useTemperature = cmd.argument != 0; if (lanternData2.effectMode == 0) { ResetStaticNow(lanternData2); } Respond(cmd, connection, lanternData2.useTemperature ? "Color temperature mode enabled." : "Direct light color mode enabled.", lanternData2.serial); } else if (cmd.action == "lighttoggle") { lanternData2.lightOn = cmd.argument != 0; if (lanternData2.effectMode == 0) { ResetStaticNow(lanternData2); } Respond(cmd, connection, lanternData2.lightOn ? "Light switched on." : "Light switched off.", lanternData2.serial); } else if (cmd.action == "effect") { lanternData2.effectMode = Rules.EffectMode(cmd.argument); if (lanternData2.effectMode == 0) { ResetStaticNow(lanternData2); } Respond(cmd, connection, "Light mode set to " + ((lanternData2.effectMode == 1) ? "strobe" : ((lanternData2.effectMode == 2) ? "pulse" : "static")) + ".", lanternData2.serial); } else { if (!(cmd.action == "frequency")) { if (!(cmd.action == "sell")) { return; } int value2 = Rules.Price(lanternData2.kind) / 2; if (flag) { p.Inventory.RemoveItem(val); if ((Object)(object)p.Holding.HeldItem == (Object)(object)val) { p.Hands.DropItem(false, val); p.Holding.DropItem(false, val); p.Holding.SetHeldItem((Item)null); } } lanternData2.deployed = false; Wallet.Credit(p, value2); Current.Remove(lanternData2); items.Remove(lanternData2.serial); InstanceFinder.ServerManager.Despawn(((Component)val).gameObject, (DespawnType?)null); Selected = 0; Persist(); Broadcast(); Respond(cmd, connection, "Lantern sold back for $" + value2.ToString("N0") + "."); return; } lanternData2.frequency = Rules.Frequency(cmd.value); Respond(cmd, connection, "Effect frequency updated.", lanternData2.serial); } } Persist(); Broadcast(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); Respond(cmd, connection, "Lantern Mod could not complete that action. Check the BepInEx log."); } } public void CompleteVanillaSale(Item item) { if (!InstanceFinder.IsServerStarted || (Object)(object)item == (Object)null) { return; } LanternData lanternData = Find(LanternItem.Serial(item)); if (lanternData != null) { Current.Remove(lanternData); items.Remove(lanternData.serial); if (Selected == lanternData.serial) { Selected = 0; } Persist(); Broadcast(); } } public static bool IsMoneyVendor(NPC npc) { if ((Object)(object)npc == (Object)null) { return false; } FieldInfo fieldInfo = AccessTools.Field(typeof(NPC), "_quests"); return ((fieldInfo == null) ? null : (fieldInfo.GetValue(npc) as IEnumerable))?.Any((NPCQuest q) => (Object)(object)q != (Object)null && (int)q.Type == 1) ?? false; } public void SetHoveredInteractable(Component value, bool active) { if (active) { hoveredInteractable = value; } else if ((Object)(object)hoveredInteractable == (Object)(object)value) { hoveredInteractable = null; } } private static NPC VendorFrom(Component component) { if ((Object)(object)component == (Object)null) { return null; } NPC componentInParent = component.GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null)) { return component.GetComponentInChildren(true); } return componentInParent; } public NPC FocusedMoneyVendor(Player player, float range) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)player.CamObject == (Object)null) { return null; } if ((Object)(object)player == (Object)(object)Player.LocalPlayer && (Object)(object)hoveredInteractable != (Object)null) { NPC val = VendorFrom(hoveredInteractable); if (IsMoneyVendor(val) && Vector3.Distance(((Component)player).transform.position, ((Component)val).transform.position) <= range + 0.35f) { return val; } } foreach (RaycastHit item in from h in Physics.RaycastAll(player.CamObject.position, player.CamObject.forward, range, -1, (QueryTriggerInteraction)2) orderby ((RaycastHit)(ref h)).distance select h) { RaycastHit current = item; if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)player)) { NPC componentInParent = ((Component)((RaycastHit)(ref current)).collider).GetComponentInParent(); if (IsMoneyVendor(componentInParent)) { return componentInParent; } if (!((RaycastHit)(ref current)).collider.isTrigger) { break; } } } NPC result = null; float num = 0.72f; RaycastHit val3 = default(RaycastHit); foreach (NPC item2 in Object.FindObjectsByType().Where(IsMoneyVendor)) { Vector3 val2 = (((Object)(object)item2.MouthPosForItems != (Object)null) ? item2.MouthPosForItems.position : (((Component)item2).transform.position + Vector3.up)) - player.CamObject.position; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude <= 0.01f)) { float num2 = Vector3.Dot(player.CamObject.forward, val2 / magnitude); if (Rules.CanUseVendor(magnitude, num2) && !(num2 < num) && Physics.Raycast(player.CamObject.position, val2 / magnitude, ref val3, magnitude + 0.5f, -1, (QueryTriggerInteraction)2) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() != (Object)(object)item2)) { result = item2; num = num2; } } } return result; } private void OnDestroy() { Persist(); if (harmony != null) { harmony.UnpatchSelf(); } Instance = null; } public static bool IsDeployed(Item item) { if ((Object)(object)Instance != (Object)null && LanternItem.Is(item) && (Object)(object)item.SyncedHolder == (Object)null) { return Instance.Find(LanternItem.Serial(item))?.deployed ?? false; } return false; } private Item RayLantern(float range) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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) Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.CamObject == (Object)null) { return null; } foreach (RaycastHit item in from x in Physics.RaycastAll(localPlayer.CamObject.position, localPlayer.CamObject.forward, range, -1, (QueryTriggerInteraction)2) orderby ((RaycastHit)(ref x)).distance select x) { 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 (LanternItem.Is(componentInParent) && IsDeployed(componentInParent)) { return componentInParent; } if (!((RaycastHit)(ref current)).collider.isTrigger) { return null; } } } return null; } private Item InteractionTarget() { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || Open || localPlayer.BlockInputs || localPlayer.Dying.IsDead) { return null; } Item heldItem = localPlayer.Holding.HeldItem; if (LanternItem.Is(heldItem)) { return heldItem; } return RayLantern(6f); } public bool CapturesInteract() { if (!((Object)(object)InteractionTarget() != (Object)null)) { return (Object)(object)activeTarget != (Object)null; } 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_002c: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d9: 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 || (Object)(object)localPlayer.CamObject == (Object)null) { return false; } foreach (RaycastHit item in from x in Physics.RaycastAll(localPlayer.CamObject.position, localPlayer.CamObject.forward, 8f, -1, (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref x)).distance select x) { 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; } private void FireHeldAction(Item target) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0044: 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) Selected = LanternItem.Serial(target); if ((Object)(object)target.SyncedHolder == (Object)(object)Player.LocalPlayer) { if (!CrosshairSurface(target, out var surface)) { SetStatus("Look at an upward-facing surface within 8 metres."); } else { Send("deploy", 0, 0f, null, ((RaycastHit)(ref surface)).point, ((RaycastHit)(ref surface)).normal); } } else { Send("pickup"); } } private void UpdateInteraction() { Keyboard current = Keyboard.current; if (current == null) { return; } if (((ButtonControl)current.eKey).wasPressedThisFrame) { activeTarget = InteractionTarget(); useStarted = Time.unscaledTime; holdFired = false; } if ((Object)(object)activeTarget != (Object)null && ((ButtonControl)current.eKey).isPressed && !holdFired && Time.unscaledTime - useStarted >= 1f) { holdFired = true; FireHeldAction(activeTarget); } if (((ButtonControl)current.eKey).wasReleasedThisFrame) { Item val = activeTarget; if ((Object)(object)val != (Object)null && !holdFired && (Object)(object)val.SyncedHolder != (Object)(object)Player.LocalPlayer) { OpenLanternEditor(LanternItem.Serial(val)); } activeTarget = null; holdFired = false; } } private void DrawInteractionHint() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_014c: 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) Item val = activeTarget ?? InteractionTarget(); if (!((Object)(object)val == (Object)null)) { LanternData lanternData = Find(LanternItem.Serial(val)); bool num = (Object)(object)val.SyncedHolder == (Object)(object)Player.LocalPlayer; string text = ((lanternData == null) ? Rules.TypeName(val.ID) : lanternData.name); string text2 = (num ? ("Hold E to deploy " + text) : "Tap E to edit • Hold E to pick up"); if ((Object)(object)activeTarget != (Object)null && Keyboard.current != null && ((ButtonControl)Keyboard.current.eKey).isPressed) { text2 = text2 + " " + Mathf.Clamp01((Time.unscaledTime - useStarted) / 1f).ToString("P0"); } if (hintStyle == null) { hintStyle = new GUIStyle(GUI.skin.box) { fontSize = 15, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; hintStyle.normal.textColor = new Color(1f, 0.78f, 0.32f); } if (!num && lanternData != null) { GUIStyle val2 = new GUIStyle(GUI.skin.box) { fontSize = 15, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val2.normal.textColor = Color.white; GUI.Box(new Rect((float)Screen.width / 2f - 250f, (float)Screen.height * 0.685f, 500f, 40f), lanternData.name + " • Owner: " + (string.IsNullOrEmpty(lanternData.ownerName) ? "Unknown" : lanternData.ownerName), val2); } GUI.Box(new Rect((float)Screen.width / 2f - 280f, (float)Screen.height * 0.73f, 560f, 42f), text2, hintStyle); } } private void Styles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0034: Expected O, but got Unknown //IL_004e: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_01c8: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) if (titleStyle == null) { titleStyle = new GUIStyle(GUI.skin.label) { fontSize = 24, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; titleStyle.normal.textColor = new Color(1f, 0.72f, 0.25f); headerStyle = new GUIStyle(GUI.skin.label) { fontSize = 17, fontStyle = (FontStyle)1 }; headerStyle.normal.textColor = new Color(0.55f, 0.82f, 1f); labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 14 }; labelStyle.normal.textColor = new Color(0.88f, 0.92f, 0.96f); statusStyle = new GUIStyle(GUI.skin.box) { fontSize = 13, alignment = (TextAnchor)4, wordWrap = true }; statusStyle.normal.textColor = new Color(1f, 0.82f, 0.42f); buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 14, fontStyle = (FontStyle)1 }; buttonStyle.normal.textColor = Color.white; toggleStyle = new GUIStyle(GUI.skin.toggle) { fontSize = 14 }; GUIStyleState normal = toggleStyle.normal; GUIStyleState onNormal = toggleStyle.onNormal; GUIStyleState hover = toggleStyle.hover; GUIStyleState onHover = toggleStyle.onHover; Color val = default(Color); ((Color)(ref val))..ctor(0.88f, 0.92f, 0.96f); onHover.textColor = val; Color val2 = (hover.textColor = val); Color textColor = (onNormal.textColor = val2); normal.textColor = textColor; } } private void DrawPanel(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = new Color(0.055f, 0.075f, 0.095f, 0.97f); GUI.Box(r, GUIContent.none); GUI.color = new Color(0.24f, 0.34f, 0.4f, 1f); GUI.Box(new Rect(((Rect)(ref r)).x + 5f, ((Rect)(ref r)).y + 5f, ((Rect)(ref r)).width - 10f, ((Rect)(ref r)).height - 10f), GUIContent.none); GUI.color = new Color(0.075f, 0.095f, 0.115f, 1f); GUI.Box(new Rect(((Rect)(ref r)).x + 9f, ((Rect)(ref r)).y + 9f, ((Rect)(ref r)).width - 18f, ((Rect)(ref r)).height - 18f), GUIContent.none); GUI.color = color; } private bool Btn(Rect r, string text) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) Color backgroundColor = GUI.backgroundColor; GUI.backgroundColor = new Color(0.18f, 0.42f, 0.54f); bool result = GUI.Button(r, text, buttonStyle); GUI.backgroundColor = backgroundColor; return result; } private void LoadDraft(LanternData data) { if (data != null) { draftSerial = data.serial; renameDraft = data.name; intensityDraft = data.intensity; tempDraft = data.temperature; } } public void OpenLanternEditor(int serial) { LanternData lanternData = Find(serial); Player localPlayer = Player.LocalPlayer; if (lanternData != null && !((Object)(object)localPlayer == (Object)null)) { if (lanternData.owner != localPlayer.SteamID) { SetStatus("Only " + (string.IsNullOrEmpty(lanternData.ownerName) ? "the owner" : lanternData.ownerName) + " can edit this lantern."); return; } Selected = serial; EditorOpen = true; EditorTab = 0; editorDraftSerial = 0; Toggle(value: true); } } private void DrawWindow() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_011f: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_040a: 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_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: 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_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0649: 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_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_074d: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) //IL_07cf: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_0777: Unknown result type (might be due to invalid IL or missing references) //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_084b: Unknown result type (might be due to invalid IL or missing references) //IL_0811: 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_081b: Unknown result type (might be due to invalid IL or missing references) //IL_0821: Unknown result type (might be due to invalid IL or missing references) Styles(); float num = Mathf.Min(850, Screen.width - 40); float num2 = Mathf.Min(650, Screen.height - 40); float num3 = ((float)Screen.width - num) / 2f; float num4 = ((float)Screen.height - num2) / 2f; Rect r = default(Rect); ((Rect)(ref r))..ctor(num3, num4, num, num2); DrawPanel(r); GUI.Label(new Rect(num3 + 24f, num4 + 18f, num - 140f, 38f), "LANTERN CONTROL", titleStyle); GUI.Label(new Rect(num3 + 24f, num4 + 52f, num - 48f, 24f), "Interact with a deployed lantern to open its controls", labelStyle); if (Btn(new Rect(num3 + num - 58f, num4 + 18f, 34f, 30f), "X")) { Toggle(value: false); return; } float num5 = 250f; GUI.Label(new Rect(num3 + 24f, num4 + 88f, num5 - 32f, 25f), "Purchase at vendors", headerStyle); GUI.Label(new Rect(num3 + 24f, num4 + 116f, num5 - 32f, 54f), "Look at any money vendor:\n[0] Camping Lantern $250\n[-] Tiki Torch $500", labelStyle); GUI.Label(new Rect(num3 + 24f, num4 + 188f, num5 - 32f, 25f), "Your lights", headerStyle); Player p = Player.LocalPlayer; LanternData[] array = (((Object)(object)p == (Object)null) ? new LanternData[0] : (from d in Current where d.available && d.owner == p.SteamID orderby d.serial select d).ToArray()); listScroll = GUI.BeginScrollView(new Rect(num3 + 24f, num4 + 218f, num5 - 32f, num2 - 298f), listScroll, new Rect(0f, 0f, num5 - 50f, Mathf.Max(num2 - 308f, (float)(array.Length * 46)))); for (int num6 = 0; num6 < array.Length; num6++) { LanternData lanternData = array[num6]; Color backgroundColor = GUI.backgroundColor; if (lanternData.serial == Selected) { GUI.backgroundColor = new Color(0.62f, 0.34f, 0.08f); } if (GUI.Button(new Rect(0f, (float)(num6 * 46), num5 - 56f, 40f), lanternData.name + "\n" + (lanternData.deployed ? "Deployed" : "Inventory"), buttonStyle)) { Selected = lanternData.serial; LoadDraft(lanternData); } GUI.backgroundColor = backgroundColor; } GUI.EndScrollView(); LanternData lanternData2 = Find(Selected); float num7 = num3 + num5 + 18f; float num8 = num - num5 - 42f; if (lanternData2 == null || (Object)(object)p == (Object)null || lanternData2.owner != p.SteamID) { GUI.Label(new Rect(num7, num4 + 105f, num8, 70f), "Purchase a light or select one from the list to configure it.", labelStyle); GUI.Box(new Rect(num3 + 24f, num4 + num2 - 62f, num - 48f, 36f), Status, statusStyle); return; } if (draftSerial != lanternData2.serial) { LoadDraft(lanternData2); } GUI.Label(new Rect(num7, num4 + 90f, num8, 28f), lanternData2.name, headerStyle); GUI.Label(new Rect(num7, num4 + 120f, num8, 22f), Rules.TypeName(lanternData2.kind) + " • " + (lanternData2.deployed ? "Deployed" : "Stored") + " • Owner: " + lanternData2.ownerName, labelStyle); GUI.Label(new Rect(num7, num4 + 160f, 120f, 24f), "Name", labelStyle); renameDraft = GUI.TextField(new Rect(num7 + 120f, num4 + 156f, num8 - 230f, 31f), renameDraft, 28); if (Btn(new Rect(num7 + num8 - 100f, num4 + 156f, 100f, 31f), "Save name")) { Send("rename", 0, 0f, renameDraft); } GUI.Label(new Rect(num7, num4 + 210f, num8, 24f), "Light intensity: " + intensityDraft.ToString("0.00") + "x", labelStyle); intensityDraft = GUI.HorizontalSlider(new Rect(num7, num4 + 242f, num8 - 112f, 22f), intensityDraft, 0.1f, 2f); if (Btn(new Rect(num7 + num8 - 100f, num4 + 230f, 100f, 34f), "Apply")) { Send("intensity", 0, intensityDraft); } GUI.Label(new Rect(num7, num4 + 285f, num8, 24f), "Color temperature: " + Mathf.RoundToInt(tempDraft) + " K", labelStyle); tempDraft = GUI.HorizontalSlider(new Rect(num7, num4 + 317f, num8 - 112f, 22f), tempDraft, 2000f, 6500f); Color color = Mathf.CorrelatedColorTemperatureToRGB(tempDraft); Color color2 = GUI.color; GUI.color = color; GUI.Box(new Rect(num7 + num8 - 100f, num4 + 278f, 100f, 25f), GUIContent.none); GUI.color = color2; if (Btn(new Rect(num7 + num8 - 100f, num4 + 309f, 100f, 34f), "Apply")) { Send("temperature", 0, tempDraft); } GUI.Label(new Rect(num7, num4 + 360f, num8, 45f), "Warm light is near 2000 K. Neutral light is near 4000 K. Cool daylight is near 6500 K.", labelStyle); if (Btn(new Rect(num7, num4 + 425f, (num8 - 12f) / 2f, 42f), "Recall to inventory")) { Send("recall"); } Color backgroundColor2 = GUI.backgroundColor; GUI.backgroundColor = new Color(0.55f, 0.16f, 0.12f); if (GUI.Button(new Rect(num7 + (num8 + 12f) / 2f, num4 + 425f, (num8 - 12f) / 2f, 42f), "Sell for $" + Rules.Price(lanternData2.kind) / 2, buttonStyle)) { Send("sell"); } GUI.backgroundColor = backgroundColor2; GUI.Box(new Rect(num3 + 24f, num4 + num2 - 62f, num - 48f, 36f), Status, statusStyle); } private Vector3 DrawRgb(float x, float y, float width, Vector3 value) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) value.x = Rules.ColorChannel(value.x); value.y = Rules.ColorChannel(value.y); value.z = Rules.ColorChannel(value.z); GUI.Label(new Rect(x, y, width, 22f), "RED " + Mathf.RoundToInt(value.x * 255f), labelStyle); value.x = GUI.HorizontalSlider(new Rect(x, y + 25f, width, 18f), value.x, 0f, 1f); GUI.Label(new Rect(x, y + 50f, width, 22f), "GREEN " + Mathf.RoundToInt(value.y * 255f), labelStyle); value.y = GUI.HorizontalSlider(new Rect(x, y + 75f, width, 18f), value.y, 0f, 1f); GUI.Label(new Rect(x, y + 100f, width, 22f), "BLUE " + Mathf.RoundToInt(value.z * 255f), labelStyle); value.z = GUI.HorizontalSlider(new Rect(x, y + 125f, width, 18f), value.z, 0f, 1f); return value; } private void DrawColorPreview(Rect rect, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = new Color(0.02f, 0.025f, 0.03f, 1f); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x - 4f, ((Rect)(ref rect)).y - 4f, ((Rect)(ref rect)).width + 8f, ((Rect)(ref rect)).height + 8f), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true); GUI.color = new Color(Rules.ColorChannel(color.r), Rules.ColorChannel(color.g), Rules.ColorChannel(color.b), 1f); GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true); GUI.color = color2; } private void DrawGlobalRenderSettings(float x, float y, float width) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) if (!lightBudgetLoaded) { lightBudgetLoaded = true; unlimitedDraft = UnlimitedRenderedLights; maxLightsDraft = MaximumRenderedLights.ToString(); } GUI.Box(new Rect(x, y, width, 68f), GUIContent.none); GUI.Label(new Rect(x + 12f, y + 7f, 280f, 22f), "MAXIMUM NUMBER OF RENDERED LIGHTS", headerStyle); bool flag = GUI.Toggle(new Rect(x + width - 205f, y + 8f, 190f, 22f), unlimitedDraft, "Unlimited", toggleStyle); if (flag != unlimitedDraft) { unlimitedDraft = flag; } bool enabled = GUI.enabled; GUI.enabled = !unlimitedDraft; maxLightsDraft = GUI.TextField(new Rect(x + 300f, y + 34f, 90f, 26f), maxLightsDraft, 3); GUI.enabled = enabled; if (Btn(new Rect(x + width - 175f, y + 32f, 160f, 29f), "APPLY GLOBAL LIMIT")) { if (!int.TryParse(maxLightsDraft, out var result)) { result = MaximumRenderedLights; } result = Mathf.Clamp(result, 1, 256); maxLightsDraft = result.ToString(); SetLightBudget(unlimitedDraft, result); } } private void LoadEditorDraft(LanternData data) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0063: 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) editorDraftSerial = data.serial; renameDraft = data.name; bodyDraft = ((data.bodyColor.x < 0f) ? Rules.DefaultBody(data.kind) : data.bodyColor); standDraft = ((data.standColor.x < 0f) ? Rules.DefaultStand() : data.standColor); lightColorDraft = data.lightColor; intensityDraft = data.intensity; tempDraft = data.temperature; frequencyDraft = data.frequency; bodyPartTab = 0; } private void DrawEditor() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_019b: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_023a: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0dc2: Unknown result type (might be due to invalid IL or missing references) //IL_0df4: Unknown result type (might be due to invalid IL or missing references) //IL_0e28: 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_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0e81: Unknown result type (might be due to invalid IL or missing references) //IL_0e4d: 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_0e57: Unknown result type (might be due to invalid IL or missing references) //IL_0e5d: Unknown result type (might be due to invalid IL or missing references) //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: 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_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0ef7: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0f2f: Unknown result type (might be due to invalid IL or missing references) //IL_0f43: Unknown result type (might be due to invalid IL or missing references) //IL_0f69: Unknown result type (might be due to invalid IL or missing references) //IL_0f17: Unknown result type (might be due to invalid IL or missing references) //IL_0f1d: Unknown result type (might be due to invalid IL or missing references) //IL_0f21: Unknown result type (might be due to invalid IL or missing references) //IL_0f27: Unknown result type (might be due to invalid IL or missing references) //IL_0faa: Unknown result type (might be due to invalid IL or missing references) //IL_0fb0: Unknown result type (might be due to invalid IL or missing references) //IL_0fb4: Unknown result type (might be due to invalid IL or missing references) //IL_0fba: Unknown result type (might be due to invalid IL or missing references) //IL_0775: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0748: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_1004: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_0807: 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_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: 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_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_0836: Unknown result type (might be due to invalid IL or missing references) //IL_083c: Unknown result type (might be due to invalid IL or missing references) //IL_0840: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) //IL_09aa: Unknown result type (might be due to invalid IL or missing references) //IL_09af: Unknown result type (might be due to invalid IL or missing references) //IL_09b4: Unknown result type (might be due to invalid IL or missing references) //IL_09fe: Unknown result type (might be due to invalid IL or missing references) //IL_0a03: Unknown result type (might be due to invalid IL or missing references) //IL_0a27: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Unknown result type (might be due to invalid IL or missing references) //IL_08c5: 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_08ef: Unknown result type (might be due to invalid IL or missing references) //IL_090e: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_0937: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0a6e: Unknown result type (might be due to invalid IL or missing references) //IL_0a88: Unknown result type (might be due to invalid IL or missing references) //IL_0a8f: Unknown result type (might be due to invalid IL or missing references) //IL_0a95: Unknown result type (might be due to invalid IL or missing references) //IL_0973: Unknown result type (might be due to invalid IL or missing references) //IL_0979: Unknown result type (might be due to invalid IL or missing references) //IL_097d: Unknown result type (might be due to invalid IL or missing references) //IL_0983: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0acd: Unknown result type (might be due to invalid IL or missing references) //IL_0b1c: Unknown result type (might be due to invalid IL or missing references) //IL_0b5b: Unknown result type (might be due to invalid IL or missing references) //IL_0bb7: Unknown result type (might be due to invalid IL or missing references) //IL_0b7c: Unknown result type (might be due to invalid IL or missing references) //IL_0b82: Unknown result type (might be due to invalid IL or missing references) //IL_0b86: Unknown result type (might be due to invalid IL or missing references) //IL_0b8c: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: 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_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0bf4: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0d26: Unknown result type (might be due to invalid IL or missing references) //IL_0d65: Unknown result type (might be due to invalid IL or missing references) //IL_0c53: Unknown result type (might be due to invalid IL or missing references) //IL_0c12: Unknown result type (might be due to invalid IL or missing references) //IL_0d89: Unknown result type (might be due to invalid IL or missing references) //IL_0d8f: Unknown result type (might be due to invalid IL or missing references) //IL_0d93: Unknown result type (might be due to invalid IL or missing references) //IL_0d99: Unknown result type (might be due to invalid IL or missing references) //IL_0c8d: Unknown result type (might be due to invalid IL or missing references) //IL_0c93: Unknown result type (might be due to invalid IL or missing references) //IL_0c97: Unknown result type (might be due to invalid IL or missing references) //IL_0c9d: Unknown result type (might be due to invalid IL or missing references) Styles(); LanternData lanternData = Find(Selected); Player localPlayer = Player.LocalPlayer; if (lanternData == null || (Object)(object)localPlayer == (Object)null || lanternData.owner != localPlayer.SteamID) { EditorOpen = false; return; } if (editorDraftSerial != lanternData.serial) { LoadEditorDraft(lanternData); } float num = Mathf.Min(760, Screen.width - 40); float num2 = Mathf.Min(820, Screen.height - 40); float num3 = ((float)Screen.width - num) / 2f; float num4 = ((float)Screen.height - num2) / 2f; DrawPanel(new Rect(num3, num4, num, num2)); GUI.Label(new Rect(num3 + 24f, num4 + 18f, num - 110f, 36f), lanternData.name + " — LIGHT EDITOR", titleStyle); GUI.Label(new Rect(num3 + 24f, num4 + 52f, num - 60f, 22f), "Owner: " + lanternData.ownerName + " • " + (lanternData.deployed ? "Deployed" : "Stored"), labelStyle); if (Btn(new Rect(num3 + num - 58f, num4 + 18f, 34f, 30f), "X")) { Toggle(value: false); return; } Color backgroundColor = GUI.backgroundColor; float num5 = (num - 64f) / 3f; if (EditorTab == 0) { GUI.backgroundColor = new Color(0.65f, 0.35f, 0.08f); } if (GUI.Button(new Rect(num3 + 24f, num4 + 86f, num5, 38f), "BODY COLOR", buttonStyle)) { EditorTab = 0; } GUI.backgroundColor = backgroundColor; if (EditorTab == 1) { GUI.backgroundColor = new Color(0.65f, 0.35f, 0.08f); } if (GUI.Button(new Rect(num3 + 32f + num5, num4 + 86f, num5, 38f), "LIGHT & EFFECTS", buttonStyle)) { EditorTab = 1; } GUI.backgroundColor = backgroundColor; if (EditorTab == 2) { GUI.backgroundColor = new Color(0.65f, 0.35f, 0.08f); } if (GUI.Button(new Rect(num3 + 40f + num5 * 2f, num4 + 86f, num5, 38f), "MANAGE", buttonStyle)) { EditorTab = 2; } GUI.backgroundColor = backgroundColor; if (EditorTab == 0) { if (lanternData.kind == 246) { if (Btn(new Rect(num3 + 42f, num4 + 142f, (num - 96f) / 2f, 34f), "LANTERN BODY")) { bodyPartTab = 0; } if (Btn(new Rect(num3 + 54f + (num - 96f) / 2f, num4 + 142f, (num - 96f) / 2f, 34f), "WOODEN STAND")) { bodyPartTab = 1; } } else { bodyPartTab = 0; } float num6 = ((lanternData.kind == 246) ? 215 : 184); GUI.Label(new Rect(num3 + 34f, num4 + num6 - 38f, num - 68f, 28f), (bodyPartTab == 0) ? "Lantern housing color" : "Wooden stand color", headerStyle); Vector3 value = ((bodyPartTab == 0) ? bodyDraft : standDraft); value = DrawRgb(num3 + 42f, num4 + num6, num - 250f, value); if (bodyPartTab == 0) { bodyDraft = value; } else { standDraft = value; } Color color = default(Color); ((Color)(ref color))..ctor(value.x, value.y, value.z); DrawColorPreview(new Rect(num3 + num - 175f, num4 + num6 - 4f, 120f, 120f), color); GUI.Label(new Rect(num3 + num - 180f, num4 + num6 + 121f, 135f, 24f), "COLOR PREVIEW", labelStyle); float num7 = num6 + 171f; if (Btn(new Rect(num3 + 42f, num4 + num7, num - 84f, 42f), (bodyPartTab == 0) ? "APPLY AND SAVE BODY COLOR" : "APPLY AND SAVE STAND COLOR")) { if (bodyPartTab == 0) { lanternData.bodyColor = new Vector3(Rules.ColorChannel(bodyDraft.x), Rules.ColorChannel(bodyDraft.y), Rules.ColorChannel(bodyDraft.z)); ApplyBodyNow(lanternData); Send("bodycolor", 0, 0f, null, lanternData.bodyColor); } else { lanternData.standColor = new Vector3(Rules.ColorChannel(standDraft.x), Rules.ColorChannel(standDraft.y), Rules.ColorChannel(standDraft.z)); ApplyBodyNow(lanternData); Send("standcolor", 0, 0f, null, lanternData.standColor); } } if (Btn(new Rect(num3 + 42f, num4 + num7 + 52f, num - 84f, 38f), (bodyPartTab == 0) ? "RESTORE ORIGINAL BODY COLOR" : "RESTORE ORIGINAL WOOD COLOR")) { if (bodyPartTab == 0) { bodyDraft = Rules.DefaultBody(lanternData.kind); lanternData.bodyColor = bodyDraft; ApplyBodyNow(lanternData); Send("bodycolor", 0, 0f, null, bodyDraft); } else { standDraft = Rules.DefaultStand(); lanternData.standColor = standDraft; ApplyBodyNow(lanternData); Send("standcolor", 0, 0f, null, standDraft); } } } else if (EditorTab == 1) { GUI.Label(new Rect(num3 + 34f, num4 + 142f, 180f, 28f), "Light power", headerStyle); Color backgroundColor2 = GUI.backgroundColor; GUI.backgroundColor = (lanternData.lightOn ? new Color(0.18f, 0.56f, 0.24f) : new Color(0.55f, 0.16f, 0.12f)); if (GUI.Button(new Rect(num3 + 205f, num4 + 140f, 145f, 34f), lanternData.lightOn ? "LIGHT ON" : "LIGHT OFF", buttonStyle)) { Send("lighttoggle", (!lanternData.lightOn) ? 1 : 0); } GUI.backgroundColor = backgroundColor2; GUI.Label(new Rect(num3 + 34f, num4 + 187f, 190f, 26f), "Color control", headerStyle); if (Btn(new Rect(num3 + 205f, num4 + 182f, 180f, 34f), lanternData.useTemperature ? "TEMPERATURE ✓" : "TEMPERATURE")) { Send("colormode", 1); } if (Btn(new Rect(num3 + 395f, num4 + 182f, 180f, 34f), (!lanternData.useTemperature) ? "RGB COLOR ✓" : "RGB COLOR")) { Send("colormode"); } if (lanternData.useTemperature) { GUI.Label(new Rect(num3 + 42f, num4 + 230f, num - 84f, 24f), "Color temperature: " + Mathf.RoundToInt(tempDraft) + " K", labelStyle); tempDraft = GUI.HorizontalSlider(new Rect(num3 + 42f, num4 + 260f, num - 210f, 20f), tempDraft, 2000f, 6500f); Color color2 = Mathf.CorrelatedColorTemperatureToRGB(tempDraft); DrawColorPreview(new Rect(num3 + num - 145f, num4 + 232f, 90f, 45f), color2); if (Btn(new Rect(num3 + 42f, num4 + 288f, num - 84f, 34f), "APPLY COLOR TEMPERATURE")) { lanternData.temperature = Rules.Temperature(tempDraft); ResetStaticNow(lanternData); Send("temperature", 0, lanternData.temperature); } } else { lightColorDraft = DrawRgb(num3 + 42f, num4 + 225f, num - 250f, lightColorDraft); Color color3 = default(Color); ((Color)(ref color3))..ctor(lightColorDraft.x, lightColorDraft.y, lightColorDraft.z); DrawColorPreview(new Rect(num3 + num - 175f, num4 + 230f, 120f, 85f), color3); if (Btn(new Rect(num3 + 42f, num4 + 374f, num - 84f, 34f), "APPLY LIGHT COLOR")) { lanternData.lightColor = new Vector3(Rules.ColorChannel(lightColorDraft.x), Rules.ColorChannel(lightColorDraft.y), Rules.ColorChannel(lightColorDraft.z)); ResetStaticNow(lanternData); Send("lightcolor", 0, 0f, null, lanternData.lightColor); } } float num8 = (lanternData.useTemperature ? 340 : 422); GUI.Label(new Rect(num3 + 42f, num4 + num8, num - 84f, 22f), "Intensity: " + intensityDraft.ToString("0.00") + "x", labelStyle); intensityDraft = GUI.HorizontalSlider(new Rect(num3 + 42f, num4 + num8 + 27f, num - 205f, 18f), intensityDraft, 0.1f, 2f); if (Btn(new Rect(num3 + num - 150f, num4 + num8 + 12f, 95f, 32f), "APPLY")) { Send("intensity", 0, intensityDraft); } float num9 = num8 + 58f; GUI.Label(new Rect(num3 + 42f, num4 + num9, num - 84f, 22f), "Lighting effect", headerStyle); string[] array = new string[3] { "STATIC", "STROBE", "PULSE" }; for (int i = 0; i < 3; i++) { Color backgroundColor3 = GUI.backgroundColor; if (lanternData.effectMode == i) { GUI.backgroundColor = new Color(0.64f, 0.34f, 0.08f); } if (GUI.Button(new Rect(num3 + 42f + (float)i * ((num - 96f) / 3f), num4 + num9 + 27f, (num - 114f) / 3f, 34f), array[i], buttonStyle)) { lanternData.effectMode = i; if (i == 0) { ResetStaticNow(lanternData); } Send("effect", i); } GUI.backgroundColor = backgroundColor3; } GUI.Label(new Rect(num3 + 42f, num4 + num9 + 70f, num - 84f, 22f), "Strobe / pulse frequency: " + frequencyDraft.ToString("0.00") + " Hz", labelStyle); frequencyDraft = GUI.HorizontalSlider(new Rect(num3 + 42f, num4 + num9 + 97f, num - 205f, 18f), frequencyDraft, 0.25f, 8f); if (Btn(new Rect(num3 + num - 150f, num4 + num9 + 82f, 95f, 32f), "APPLY")) { Send("frequency", 0, frequencyDraft); } } else { GUI.Label(new Rect(num3 + 34f, num4 + 152f, num - 68f, 28f), "Lantern name", headerStyle); renameDraft = GUI.TextField(new Rect(num3 + 42f, num4 + 194f, num - 204f, 36f), renameDraft, 28); if (Btn(new Rect(num3 + num - 150f, num4 + 194f, 108f, 36f), "SAVE NAME")) { Send("rename", 0, 0f, renameDraft); } GUI.Label(new Rect(num3 + 42f, num4 + 252f, num - 84f, 60f), Rules.TypeName(lanternData.kind) + " • " + (lanternData.deployed ? "Deployed" : "Stored") + "\nOwner: " + lanternData.ownerName, labelStyle); if (Btn(new Rect(num3 + 42f, num4 + 332f, num - 84f, 44f), "RECALL TO INVENTORY")) { Send("recall"); } Color backgroundColor4 = GUI.backgroundColor; GUI.backgroundColor = new Color(0.55f, 0.16f, 0.12f); if (GUI.Button(new Rect(num3 + 42f, num4 + 392f, num - 84f, 44f), "SELL FOR $" + Rules.Price(lanternData.kind) / 2, buttonStyle)) { Send("sell"); } GUI.backgroundColor = backgroundColor4; } DrawGlobalRenderSettings(num3 + 24f, num4 + num2 - 120f, num - 48f); GUI.Box(new Rect(num3 + 24f, num4 + num2 - 44f, num - 48f, 28f), Status, statusStyle); } private void DrawVendorPrompt() { //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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00d4: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_015c: Unknown result type (might be due to invalid IL or missing references) if (nearMoneyVendor && !((Object)(object)Player.LocalPlayer == (Object)null) && !Open) { Styles(); float num = 430f; float num2 = Mathf.Clamp((float)Screen.width * 0.5f + 460f, 12f, (float)Screen.width - num - 18f); float num3 = (float)Screen.height * 0.67f; bool flag = Wallet.Balance(Player.LocalPlayer) >= 250; bool flag2 = Wallet.Balance(Player.LocalPlayer) >= 500; GUIStyle val = new GUIStyle(GUI.skin.box) { alignment = (TextAnchor)4, fontSize = 16, fontStyle = (FontStyle)1 }; val.normal.textColor = (Color)(flag ? Color.white : new Color(1f, 0.45f, 0.35f)); GUI.Box(new Rect(num2, num3, num, 38f), "[0] Buy Camping Lantern - $250", val); val.normal.textColor = (Color)(flag2 ? Color.white : new Color(1f, 0.45f, 0.35f)); GUI.Box(new Rect(num2, num3 + 42f, num, 38f), "[-] Buy Tiki Torch - $500", val); if (Time.unscaledTime < statusUntil) { GUI.Box(new Rect(num2, num3 + 84f, num, 32f), Status, statusStyle); } } } private void OnGUI() { DrawInteractionHint(); DrawVendorPrompt(); if (Open && EditorOpen) { DrawEditor(); } } } internal static class Wallet { private static Type WalletType => Type.GetType("NoSharedMoney.Wallets, NoSharedMoney", throwOnError: false); public static int Balance(Player p) { 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 }); } return MoneyManager.Money; } public static bool Charge(Player p, int value) { Type walletType = WalletType; if (walletType != null) { MethodInfo methodInfo = AccessTools.Method(walletType, "Get", new Type[1] { typeof(Player) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(walletType, "Remove", new Type[2] { typeof(Player), typeof(int) }, (Type[])null); if ((int)methodInfo.Invoke(null, new object[1] { p }) < value) { return false; } methodInfo2.Invoke(null, new object[2] { p, value }); return true; } if ((Object)(object)MoneyManager.Instance == (Object)null || !MoneyManager.CanAfford(value)) { return false; } MoneyManager.RemoveMoney(value, p); return true; } public static void Credit(Player p, int value) { 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, value }); } else { MoneyManager.AddMoney(value, p); } } } [HarmonyPatch(typeof(PlayerHolding), "PickUpInput")] internal static class LanternCaptureInteract { private static bool Prefix() { if (!((Object)(object)Plugin.Instance == (Object)null)) { return !Plugin.Instance.CapturesInteract(); } return true; } } [HarmonyPatch(typeof(GameInfo), "Awake")] internal static class RegisterLanterns { private static void Postfix() { try { LanternItem.Register(); } catch (Exception ex) { Plugin.Log("Lantern registration deferred: " + ex.Message); } } } [HarmonyPatch(typeof(Interactable), "Hover")] internal static class LanternVendorHoverStart { private static void Postfix(Interactable __instance) { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.SetHoveredInteractable((Component)(object)__instance, active: true); } } } [HarmonyPatch(typeof(Interactable), "UnHover")] internal static class LanternVendorHoverStop { private static void Postfix(Interactable __instance) { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.SetHoveredInteractable((Component)(object)__instance, active: false); } } } [HarmonyPatch(typeof(Item), "GetName")] internal static class LanternName { private static bool Prefix(Item __instance, ref string __result) { if (!LanternItem.Is(__instance)) { return true; } LanternData lanternData = (((Object)(object)Plugin.Instance == (Object)null) ? null : Plugin.Instance.Find(LanternItem.Serial(__instance))); __result = ((lanternData == null) ? Rules.TypeName(__instance.ID) : lanternData.name); return false; } } [HarmonyPatch(typeof(MoneyManager), "SellItem")] internal static class LanternVanillaSale { private static void Postfix(Item item) { if (LanternItem.Is(item) && (Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.CompleteVanillaSale(item); } } } [HarmonyPatch(typeof(Item), "SetSyncedHolder")] internal static class LanternHolder { private static void Postfix(Item __instance) { if (LanternItem.Is(__instance) && !((Object)(object)__instance.SyncedHolder == (Object)null) && !((Object)(object)Plugin.Instance == (Object)null)) { LanternData lanternData = Plugin.Instance.Find(LanternItem.Serial(__instance)); if (lanternData != null) { lanternData.deployed = false; } } } } [HarmonyPatch(typeof(SaveManager), "SaveServer")] internal static class SaveLanterns { private static void Postfix() { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.Instance.Persist(); } } } [HarmonyPatch(typeof(SaveManager), "GetWorldItemSavePriority")] internal static class LanternSavePriority { private static bool Prefix(Item item, ref int __result) { if (!LanternItem.Is(item)) { return true; } __result = 0; return false; } } [HarmonyPatch(typeof(ItemManager), "RemoveItemsFarAwar")] internal static class KeepLanterns { private static void Prefix(List toRemove) { toRemove.RemoveAll(LanternItem.Is); } } [HarmonyPatch(typeof(Player), "get_BlockInputs")] internal static class LanternBlockInput { 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 LanternBlockCamera { 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 LanternClosePanel { 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(value: false); } return false; } } [HarmonyPatch(typeof(Item), "PickUp")] internal static class NoDirectLanternPickup { private static bool Prefix(Item __instance, bool calledFromLocal, bool sendToServer) { if (calledFromLocal || sendToServer) { return !Plugin.IsDeployed(__instance); } return true; } } [HarmonyPatch(typeof(Item), "get_CanPickUp")] internal static class LanternPickupPrompt { private static void Postfix(Item __instance, ref bool __result) { if (Plugin.IsDeployed(__instance)) { __result = false; } } } [HarmonyPatch(typeof(Item), "DestroyItem")] internal static class ProtectLantern { private static bool Prefix(Item __instance) { return !Plugin.IsDeployed(__instance); } } [HarmonyPatch(typeof(RigidbodySync), "SetKinematic")] internal static class AnchorLantern { private static void Prefix(RigidbodySync __instance, ref bool kinematic) { if (Plugin.IsDeployed(((Component)__instance).GetComponent())) { kinematic = true; } } } [HarmonyPatch(typeof(RigidbodySync), "StartSimulateLocal")] internal static class PreventLanternExplosion { private static bool Prefix(RigidbodySync __instance) { return !Plugin.IsDeployed(((Component)__instance).GetComponent()); } } [HarmonyPatch(typeof(Item), "UpdateLayer")] internal static class SolidLantern { private static void Prefix(Item __instance, ref bool ____disablePlayerColOnGround) { if (Plugin.IsDeployed(__instance)) { ____disablePlayerColOnGround = false; } } } public sealed class LanternSlotIcon : MonoBehaviour { private InventorySlot slot; private Renderer previewRenderer; private MeshFilter filter; private GameObject overlay; private bool previousRenderer; private bool applied; private byte kind; private static Texture2D small; private static Texture2D big; private static Texture2D Load(string resource) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown using Stream stream = typeof(LanternSlotIcon).Assembly.GetManifestResourceStream(resource); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, memoryStream.ToArray()); ((Texture)val).wrapMode = (TextureWrapMode)1; return val; } private static Texture2D Icon(byte value) { if (value == 246) { if ((Object)(object)big == (Object)null) { big = Load("LanternMod.pole-light-icon.png"); } return big; } if ((Object)(object)small == (Object)null) { small = Load("LanternMod.camping-lantern-icon.png"); } return small; } private void Create(RawImage nativeImage) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)overlay != (Object)null)) { overlay = new GameObject("Lantern Mod Icon", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(RawImage) }); overlay.transform.SetParent(((Component)nativeImage).transform, false); RectTransform val = (RectTransform)overlay.transform; val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; ((Transform)val).localScale = Vector3.one; RawImage component = overlay.GetComponent(); component.uvRect = new Rect(0f, 0f, 1f, 1f); ((Graphic)component).color = Color.white; ((Graphic)component).raycastTarget = false; } } public void Apply(InventorySlot target) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown slot = target; if (!LanternItem.Is(slot.Item)) { return; } kind = slot.Item.ID; Texture2D val = Icon(kind); if ((Object)(object)val == (Object)null) { return; } RawImage val2 = (RawImage)AccessTools.Field(typeof(InventorySlot), "_itemImage").GetValue(slot); previewRenderer = (Renderer)AccessTools.Field(typeof(InventorySlot), "_renderer").GetValue(slot); filter = (MeshFilter)AccessTools.Field(typeof(InventorySlot), "_filter").GetValue(slot); if (!((Object)(object)val2 == (Object)null)) { Create(val2); overlay.GetComponent().texture = (Texture)(object)val; if (!applied) { previousRenderer = (Object)(object)previewRenderer == (Object)null || previewRenderer.enabled; applied = true; } if ((Object)(object)previewRenderer != (Object)null) { previewRenderer.enabled = false; } overlay.SetActive(true); } } public void Restore() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00bf: Unknown result type (might be due to invalid IL or missing references) if (!applied) { return; } InventorySlot val = slot; Item val2 = (((Object)(object)val == (Object)null) ? null : val.Item); if ((Object)(object)overlay != (Object)null) { overlay.SetActive(false); } applied = false; if ((Object)(object)val2 != (Object)null && !LanternItem.Is(val2) && (Object)(object)filter != (Object)null) { filter.mesh = val2.Mesh; ((Component)filter).transform.localPosition = val2.InventoryMeshPos; ((Component)filter).transform.localEulerAngles = val2.InventoryMeshRot; ((Component)filter).transform.localScale = Vector3.one * val2.InventoryMeshScale; if ((Object)(object)previewRenderer != (Object)null) { previewRenderer.enabled = true; } try { AccessTools.Method(typeof(InventorySlot), "ApplyCookness", (Type[])null, (Type[])null).Invoke(val, new object[1] { val2 }); AccessTools.Method(typeof(InventorySlot), "ApplySkin", (Type[])null, (Type[])null).Invoke(val, new object[1] { val2 }); } catch { } } else if ((Object)(object)previewRenderer != (Object)null) { previewRenderer.enabled = previousRenderer; } slot = null; } private void Update() { if (applied && ((Object)(object)slot == (Object)null || !LanternItem.Is(slot.Item))) { Restore(); } } private void OnDestroy() { Restore(); } } [HarmonyPatch(typeof(InventorySlot), "SetItem")] internal static class LanternInventoryIcon { public static void RefreshAll() { InventorySlot[] array = Object.FindObjectsByType((FindObjectsInactive)1); foreach (InventorySlot val in array) { LanternSlotIcon lanternSlotIcon = ((Component)val).GetComponent(); if (LanternItem.Is(val.Item)) { if ((Object)(object)lanternSlotIcon == (Object)null) { lanternSlotIcon = ((Component)val).gameObject.AddComponent(); } lanternSlotIcon.Apply(val); } else if ((Object)(object)lanternSlotIcon != (Object)null) { lanternSlotIcon.Restore(); } } } 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 (LanternItem.Is(__instance.Item)) { (((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent()).Apply(__instance); } } } }