Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Voyagers Better REPO v0.1.3
BepInEx/plugins/VoyagersBetterREPO/VoyagersBetterREPO.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using TMPro; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Profiling; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using VoyagersBetterREPO.Audio; using VoyagersBetterREPO.Development; using VoyagersBetterREPO.Visuals; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("VoyagersBetterREPO")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.3.0")] [assembly: AssemblyInformationalVersion("0.1.3")] [assembly: AssemblyProduct("VoyagersBetterREPO")] [assembly: AssemblyTitle("VoyagersBetterREPO")] [assembly: AssemblyVersion("0.1.3.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VoyagersBetterREPO { internal static class DevelopmentDiagnostics { internal static string Hierarchy(Transform transform) { List<string> list = new List<string>(); Transform val = transform; while (Object.op_Implicit((Object)(object)val)) { list.Add(((Object)val).name); val = val.parent; } list.Reverse(); return string.Join("/", list); } internal static void WriteInventory() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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) List<object> list = new List<object>(); Graphic[] array = Object.FindObjectsOfType<Graphic>(true); foreach (Graphic val in array) { string text = Hierarchy(((Component)val).transform); if (!Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<MenuPage>()) && text.IndexOf("Cursor", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("Version", StringComparison.OrdinalIgnoreCase) < 0) { continue; } TMP_Text val2 = (TMP_Text)(object)((val is TMP_Text) ? val : null); RawImage val3 = (RawImage)(object)((val is RawImage) ? val : null); Image val4 = (Image)(object)((val is Image) ? val : null); string name = ((object)val).GetType().Name; bool activeInHierarchy = ((Component)val).gameObject.activeInHierarchy; string? color = ((object)val.color/*cast due to .constrained prefix*/).ToString(); object obj; if (val3 == null) { obj = null; } else { Texture texture = val3.texture; obj = ((texture != null) ? ((Object)texture).name : null); } if (obj == null) { if (val4 == null) { obj = null; } else { Sprite sprite = val4.sprite; if (sprite == null) { obj = null; } else { Texture2D texture2 = sprite.texture; obj = ((texture2 != null) ? ((Object)texture2).name : null); } } } object sprite2; if (val4 == null) { sprite2 = null; } else { Sprite sprite3 = val4.sprite; sprite2 = ((sprite3 != null) ? ((Object)sprite3).name : null); } Material material = val.material; list.Add(new { path = text, type = name, active = activeInHierarchy, color = color, texture = (string)obj, sprite = (string)sprite2, material = ((material != null) ? ((Object)material).name : null), face = ((Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.fontSharedMaterial)) ? ((object)val2.fontSharedMaterial.GetColor(ShaderUtilities.ID_FaceColor)/*cast due to .constrained prefix*/).ToString() : null), textRole = (Object.op_Implicit((Object)(object)val2) ? ((Object)val2).name : null) }); } List<string> list2 = new List<string>(); AudioClip[] array2 = Resources.FindObjectsOfTypeAll<AudioClip>(); foreach (AudioClip val5 in array2) { list2.Add(((Object)val5).name); } list2.Sort(StringComparer.Ordinal); List<object> list3 = new List<object>(); array2 = Resources.FindObjectsOfTypeAll<AudioClip>(); foreach (AudioClip val6 in array2) { if (Plugin.Instance.Catalog.IsOwned(val6)) { list3.Add(new { name = ((Object)val6).name, length = val6.length, samples = val6.samples, channels = val6.channels, loadType = ((object)val6.loadType/*cast due to .constrained prefix*/).ToString(), loadState = ((object)val6.loadState/*cast due to .constrained prefix*/).ToString(), nativeObjectBytes = Profiler.GetRuntimeMemorySizeLong((Object)(object)val6) }); } } List<object> list4 = new List<object>(); AudioSource[] array3 = Object.FindObjectsOfType<AudioSource>(true); foreach (AudioSource val7 in array3) { if (Object.op_Implicit((Object)(object)val7.clip) && (Plugin.Instance.Catalog.IsOwned(val7.clip) || Object.op_Implicit((Object)(object)((Component)val7).GetComponent<MusicBinding>()))) { string path = Hierarchy(((Component)val7).transform); string name2 = ((Object)val7.clip).name; bool isPlaying = val7.isPlaying; bool loop = val7.loop; float volume = val7.volume; float pitch = val7.pitch; float spatialBlend = val7.spatialBlend; AudioMixerGroup outputAudioMixerGroup = val7.outputAudioMixerGroup; list4.Add(new { path = path, clip = name2, isPlaying = isPlaying, loop = loop, volume = volume, pitch = pitch, spatialBlend = spatialBlend, mixer = ((outputAudioMixerGroup != null) ? ((Object)outputAudioMixerGroup).name : null) }); } } int num = 0; Material[] array4 = Resources.FindObjectsOfTypeAll<Material>(); for (int i = 0; i < array4.Length; i++) { if (((Object)array4[i]).name.EndsWith(" (VBR)", StringComparison.Ordinal)) { num++; } } string text2 = Path.Combine(Paths.ConfigPath, "VoyagersBetterREPO-diagnostics"); Directory.CreateDirectory(text2); string text3 = Path.Combine(text2, "inventory.json"); File.WriteAllText(text3, JsonConvert.SerializeObject((object)new { game = Application.version, unity = Application.unityVersion, rules = Plugin.Instance.Catalog.RuleCount, audioFiles = Plugin.Instance.Catalog.UniqueFileCount, hits = Plugin.Instance.Catalog.PlayHits, perEventHits = Plugin.Instance.Catalog.HitCounts, ownedMaterials = num, graphics = list, audioSources = list4, customClips = list3, loadedAudioClips = list2 }, (Formatting)1)); Plugin.Instance.InfoLog("UI/audio inventory saved: " + text3); } } [BepInPlugin("voyager.repo.voyagersbetterrepo", "Voyagers Better REPO", "0.1.3")] [BepInProcess("REPO.exe")] public sealed class Plugin : BaseUnityPlugin { public const string Id = "voyager.repo.voyagersbetterrepo"; public const string Version = "0.1.3"; internal ConfigEntry<bool> Effects; internal ConfigEntry<bool> Music; internal ConfigEntry<bool> Logo; internal ConfigEntry<bool> Theme; internal ConfigEntry<bool> Diagnostics; internal ConfigEntry<bool> SelfTest; internal ConfigEntry<bool> MoonArt; internal ConfigEntry<bool> RainbowLaser; internal ConfigEntry<bool> RainbowStaffLaser; internal ConfigEntry<bool> DarkFountainBeam; internal ConfigEntry<bool> EndermanAppearance; internal ConfigEntry<bool> CopperGolemRugrat; internal ConfigEntry<bool> CashoutCoolerModel; internal ConfigEntry<bool> ArcticLaptopModel; internal ConfigEntry<bool> ArcticComputerModel; internal ConfigEntry<bool> ArcticPhoneModel; internal ConfigEntry<bool> FortniteChestModel; internal ConfigEntry<bool> SledgeHammerModel; internal ConfigEntry<bool> WizardCauldronBoxModel; internal ConfigEntry<bool> ManorClownModel; internal ConfigEntry<bool> ManorPaintingArt; internal ConfigEntry<bool> IPhoneMapDevice; internal ConfigEntry<bool> IPhoneMapInterface; internal ClipCatalog Catalog; internal string ModDirectory = ""; private Harmony harmony; private bool settingsDirty; private bool inventoryIconDirty; private bool cashoutCoolerDirty; private bool arcticLaptopDirty; private bool arcticComputerDirty; private bool arcticPhoneDirty; private bool fortniteChestDirty; private bool sledgeHammerDirty; private bool wizardCauldronBoxDirty; private bool manorClownDirty; private bool manorPaintingDirty; private bool iPhoneMapDirty; private bool quitting; internal static Plugin Instance { get; private set; } private void Awake() { //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown Instance = this; ModDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Effects = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "SoundEffects", true, "Replace mapped sound effects with per-rule pitch. Keep game routing, position and source lifecycle."); Music = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "Music", true, "Replace mapped main-menu/lobby music and play the developer-room loop through the game's music mixer."); Logo = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "Logo", true, "Use the custom main-menu logo. Does not disable seasonal decorations."); Theme = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "GreenTheme", true, "Apply the green theme to identified menu controls and cursor, preserving warning and disabled states."); MoonArt = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "HalloweenMoonArt", true, "Use custom main-menu Halloween moon and approval/disapproval faces. Preserve event behavior."); RainbowLaser = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "RainbowBeamerLaser", true, "Smoothly cycle Beamer beam colors through the rainbow every second."); RainbowStaffLaser = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "RainbowWizardStaffLaser", true, "Cycle staff rainbow every three seconds idle, every second while firing; synchronized beam, jewel and particles."); DarkFountainBeam = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "DarkFountainBeam", true, "Use the outlined black-and-white beam and neon-blue muzzle particles for the Photon Blaster and C.A.R.T. Laser."); EndermanAppearance = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "EndermanAppearance", true, "Use the Enderman model and textures from the local Minecraft Java 1.21.11 client for Thin Man."); CopperGolemRugrat = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "CopperGolemRugrat", true, "Use the local Minecraft Java 1.21.11 Copper Golem model, health-based oxidation, animation and character sounds for Rugrat. Preserve native gameplay."); CashoutCoolerModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "CashoutCoolerModel", true, "Use the sideways Cashout terminal, held glow sequence and scoped audio for the Arctic Sample Cooler Wide."); ArcticLaptopModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "ArcticLaptopModel", true, "Use the supplied ASUS ROG Strix Scar 17 model for the Arctic Laptop, preserving native colliders and gameplay."); ArcticComputerModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "ArcticComputerModel", true, "Use the supplied gaming PC tower for the Arctic Computer, preserving native colliders and gameplay."); ArcticPhoneModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "ArcticPhoneModel", true, "Use the supplied white iPhone 4s for the Arctic Phone, preserving native hitboxes, ringing, vibration and pickup behavior."); FortniteChestModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "FortniteChestModel", true, "Use the supplied Fortnite chest, gold smoke/glow, treasure light and positional ambient loop for the regular Arctic Sample Cooler, preserving its native hitbox. SoundEffects also controls the loop."); SledgeHammerModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "SledgeHammerModel", true, "Use the supplied intact Sledge Hammer model, fitted to the native grip and head collider."); WizardCauldronBoxModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "WizardCauldronBoxModel", true, "Use the Minecraft grass block for the Wizard Cauldron Box shell."); ManorClownModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "ManorClownModel", true, "Use the supplied Balatro Joker bust for the Manor Clown."); ManorPaintingArt = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "ManorPaintingArt", true, "Use the supplied photo on the Manor Painting canvas."); IPhoneMapDevice = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "IPhoneMapDevice", true, "Use the glacier-blue iPhone for the handheld map, preserving native controls, audio and gameplay."); IPhoneMapInterface = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", "IPhoneMapInterface", true, "Use the portrait Maps interface and fading top blur on the handheld map. Preserve discovery, markers and shop/offline states."); Diagnostics = ((BaseUnityPlugin)this).Config.Bind<bool>("Development", "Diagnostics", false, "Write bounded clip-hit diagnostics and a UI inventory on F8. Not required for normal play."); SelfTest = ((BaseUnityPlugin)this).Config.Bind<bool>("Development", "RunAudioProbe", false, "Development only: run a positional/loop audio probe in the main menu, then turn this off. No gameplay changes."); ((BaseUnityPlugin)this).Config.SettingChanged += delegate(object _, SettingChangedEventArgs change) { settingsDirty = true; if ((object)change.ChangedSetting == DarkFountainBeam) { inventoryIconDirty = true; } if ((object)change.ChangedSetting == CashoutCoolerModel || (object)change.ChangedSetting == Effects) { cashoutCoolerDirty = true; } if ((object)change.ChangedSetting == ArcticLaptopModel) { arcticLaptopDirty = true; } if ((object)change.ChangedSetting == ArcticComputerModel) { arcticComputerDirty = true; } if ((object)change.ChangedSetting == ArcticPhoneModel) { arcticPhoneDirty = true; } if ((object)change.ChangedSetting == FortniteChestModel) { fortniteChestDirty = true; } if ((object)change.ChangedSetting == SledgeHammerModel) { sledgeHammerDirty = true; } if ((object)change.ChangedSetting == WizardCauldronBoxModel) { wizardCauldronBoxDirty = true; } if ((object)change.ChangedSetting == ManorClownModel) { manorClownDirty = true; } if ((object)change.ChangedSetting == ManorPaintingArt) { manorPaintingDirty = true; } if ((object)change.ChangedSetting == IPhoneMapDevice || (object)change.ChangedSetting == IPhoneMapInterface) { iPhoneMapDirty = true; } }; Catalog = new ClipCatalog(this); HalloweenMoonArt.Load(); ((Component)this).gameObject.AddComponent<LabSession>(); ThemePalette.Load(ModDirectory); harmony = new Harmony("voyager.repo.voyagersbetterrepo"); harmony.PatchAll(typeof(Plugin).Assembly); SceneManager.sceneLoaded += SceneLoaded; Application.quitting += Quitting; ((MonoBehaviour)this).StartCoroutine(Initialize()); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Voyagers Better REPO 0.1.3: fresh implementation; Unity " + Application.unityVersion + ". Assets: " + ModDirectory)); } private IEnumerator Initialize() { yield return Catalog.Load(); yield return CopperGolemAudio.Load(); VisualTheme.Bootstrap(); HalloweenMoonArt.Discover(); MusicBinding.Discover(); if (SelfTest.Value) { ((MonoBehaviour)this).StartCoroutine(DevelopmentProbe.Run()); } } private void SceneLoaded(Scene scene, LoadSceneMode mode) { ((MonoBehaviour)this).StartCoroutine(RefreshScene()); } private IEnumerator RefreshScene() { yield return null; VisualTheme.Bootstrap(); HalloweenMoonArt.Discover(); MusicBinding.Discover(); } private void Update() { if (settingsDirty) { settingsDirty = false; VisualTheme.Refresh(); HalloweenMoonArt.Refresh(); } if (inventoryIconDirty) { inventoryIconDirty = false; PhotonInventoryIcon.Refresh(); } if (cashoutCoolerDirty) { cashoutCoolerDirty = false; CashoutCooler.Refresh(); } if (arcticLaptopDirty) { arcticLaptopDirty = false; VoyagersBetterREPO.Visuals.ArcticLaptopModel.Refresh(); } if (arcticComputerDirty) { arcticComputerDirty = false; VoyagersBetterREPO.Visuals.ArcticComputerModel.Refresh(); } if (arcticPhoneDirty) { arcticPhoneDirty = false; VoyagersBetterREPO.Visuals.ArcticPhoneModel.Refresh(); } if (fortniteChestDirty) { fortniteChestDirty = false; VoyagersBetterREPO.Visuals.FortniteChestModel.Refresh(); } if (sledgeHammerDirty) { sledgeHammerDirty = false; VoyagersBetterREPO.Visuals.SledgeHammerModel.Refresh(); } if (wizardCauldronBoxDirty) { wizardCauldronBoxDirty = false; VoyagersBetterREPO.Visuals.WizardCauldronBoxModel.Refresh(); } if (manorClownDirty) { manorClownDirty = false; VoyagersBetterREPO.Visuals.ManorClownModel.Refresh(); } if (manorPaintingDirty) { manorPaintingDirty = false; VoyagersBetterREPO.Visuals.ManorPaintingArt.Refresh(); } if (iPhoneMapDirty) { iPhoneMapDirty = false; VoyagersBetterREPO.Visuals.IPhoneMapDevice.Refresh(); } if (Input.GetKeyDown((KeyCode)287)) { try { ((BaseUnityPlugin)this).Config.Reload(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Reloaded settings. Feature switches apply live; restart for sound-map/asset edits."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Settings reload failed: " + ex.Message)); } } if (Diagnostics.Value && Input.GetKeyDown((KeyCode)289)) { DevelopmentDiagnostics.WriteInventory(); } if (Diagnostics.Value && Input.GetKeyDown((KeyCode)290)) { ((MonoBehaviour)this).StartCoroutine(DevelopmentProbe.Run()); } } internal void InfoLog(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } internal void Warn(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)message); } private void Quitting() { quitting = true; } private void OnDestroy() { SceneManager.sceneLoaded -= SceneLoaded; Application.quitting -= Quitting; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if (!quitting) { MusicBinding.RestoreAll(); VisualTheme.RestoreAll(); PhotonInventoryIcon.Refresh(); } PhotonInventoryIcon.Dispose(); CashoutCooler.Dispose(); VoyagersBetterREPO.Visuals.ArcticLaptopModel.Dispose(); VoyagersBetterREPO.Visuals.ArcticComputerModel.Dispose(); VoyagersBetterREPO.Visuals.ArcticPhoneModel.Dispose(); VoyagersBetterREPO.Visuals.FortniteChestModel.Dispose(); VoyagersBetterREPO.Visuals.SledgeHammerModel.Dispose(); VoyagersBetterREPO.Visuals.WizardCauldronBoxModel.Dispose(); VoyagersBetterREPO.Visuals.ManorClownModel.Dispose(); VoyagersBetterREPO.Visuals.ManorPaintingArt.Dispose(); VoyagersBetterREPO.Visuals.IPhoneMapDevice.Dispose(); PlayerDeathSignal.Dispose(); Catalog?.Dispose(); HalloweenMoonArt.Dispose(); RainbowBeamerCharge.Dispose(); RainbowEmissionTextures.Dispose(); ThinManAppearance.Dispose(); RugratAppearance.Dispose(); CopperGolemAudio.Dispose(); } } } namespace VoyagersBetterREPO.Visuals { [HarmonyPatch(typeof(ValuableObject), "Awake")] internal sealed class ArcticComputerModel : MonoBehaviour { private const string PrefabName = "Valuable Arctic Computer"; private static Mesh? replacement; private static Material? finish; private static readonly Texture2D?[] Textures = (Texture2D?[])(object)new Texture2D[4]; private static bool attempted; private MeshFilter filter; private MeshRenderer meshRenderer; private Mesh originalMesh; private Material originalMaterial; private static void Postfix(ValuableObject __instance) { string name = ((Object)((Component)__instance).gameObject).name; if (!(name != "Valuable Arctic Computer") || !(name != "Valuable Arctic Computer(Clone)")) { Transform val = ((Component)__instance).transform.Find("Object/Mesh"); MeshFilter val2 = default(MeshFilter); MeshRenderer val3 = default(MeshRenderer); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<MeshFilter>(ref val2) && ((Component)val).TryGetComponent<MeshRenderer>(ref val3) && Object.op_Implicit((Object)(object)val2.sharedMesh) && !(((Object)val2.sharedMesh).name != "Valuable Computer") && Object.op_Implicit((Object)(object)((Renderer)val3).sharedMaterial) && !(((Object)((Renderer)val3).sharedMaterial.shader).name != "Standard")) { ArcticComputerModel arcticComputerModel = ((Component)__instance).gameObject.AddComponent<ArcticComputerModel>(); arcticComputerModel.filter = val2; arcticComputerModel.meshRenderer = val3; arcticComputerModel.originalMesh = val2.sharedMesh; arcticComputerModel.originalMaterial = ((Renderer)val3).sharedMaterial; arcticComputerModel.Apply(Plugin.Instance.ArcticComputerModel.Value); } } } private void Apply(bool enabled) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)filter) || !Object.op_Implicit((Object)(object)meshRenderer)) { return; } if (enabled && (Object)(object)filter.sharedMesh == (Object)(object)originalMesh && (Object)(object)((Renderer)meshRenderer).sharedMaterial == (Object)(object)originalMaterial) { if (!attempted) { Load(originalMesh.bounds, originalMaterial.shader); } if (Object.op_Implicit((Object)(object)replacement) && Object.op_Implicit((Object)(object)finish)) { filter.sharedMesh = replacement; ((Renderer)meshRenderer).sharedMaterial = finish; } } else if (!enabled) { if (Object.op_Implicit((Object)(object)replacement) && (Object)(object)filter.sharedMesh == (Object)(object)replacement) { filter.sharedMesh = originalMesh; } if (Object.op_Implicit((Object)(object)finish) && (Object)(object)((Renderer)meshRenderer).sharedMaterial == (Object)(object)finish) { ((Renderer)meshRenderer).sharedMaterial = originalMaterial; } } } internal static void Refresh() { ArcticComputerModel[] array = Object.FindObjectsOfType<ArcticComputerModel>(true); for (int i = 0; i < array.Length; i++) { array[i].Apply(Plugin.Instance.ArcticComputerModel.Value); } } private static void Load(Bounds target, Shader shader) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0065: Expected O, but got Unknown //IL_00b4: 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_00cd: 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_00dd: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_019b: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) attempted = true; try { string path = Path.Combine(Plugin.Instance.ModDirectory, "models", "arctic-computer"); replacement = ReadMesh(Path.Combine(path, "computer.mesh"), target); finish = new Material(Shader.Find("Standard") ?? shader) { name = "VBR Gaming PC Finish", color = Color.white }; string[] array = new string[3] { "base", "metallic-smoothness", "emission" }; string[] array2 = new string[3] { "_MainTex", "_MetallicGlossMap", "_EmissionMap" }; for (int i = 0; i < array.Length; i++) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, i == 1) { name = "VBR Gaming PC " + array[i], filterMode = (FilterMode)2, anisoLevel = 4 }; Textures[i] = val; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, array[i] + ".png")), true)) { throw new InvalidDataException("Invalid PC texture " + array[i]); } finish.SetTexture(array2[i], (Texture)(object)val); } finish.SetFloat("_GlossMapScale", 1f); Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false, true) { name = "VBR Gaming PC neutral normal", filterMode = (FilterMode)0 }; Textures[3] = val2; Color val3 = default(Color); ((Color)(ref val3))..ctor(0.5f, 0.5f, 1f, 1f); val2.SetPixels((Color[])(object)new Color[4] { val3, val3, val3, val3 }); val2.Apply(false, true); finish.SetTexture("_BumpMap", (Texture)(object)val2); finish.SetFloat("_BumpScale", 1f); finish.EnableKeyword("_NORMALMAP"); finish.SetFloat("_Mode", 0f); finish.SetInt("_SrcBlend", 1); finish.SetInt("_DstBlend", 0); finish.SetInt("_ZWrite", 1); finish.SetOverrideTag("RenderType", "Opaque"); finish.renderQueue = 2000; finish.DisableKeyword("_ALPHATEST_ON"); finish.DisableKeyword("_ALPHABLEND_ON"); finish.DisableKeyword("_ALPHAPREMULTIPLY_ON"); finish.EnableKeyword("_METALLICGLOSSMAP"); finish.SetColor("_EmissionColor", new Color(2.5f, 2.5f, 2.5f, 1f)); finish.EnableKeyword("_EMISSION"); } catch (Exception ex) { Release(); Plugin.Instance.Warn("Could not load the Arctic Computer gaming PC model: " + ex.Message); } } private static Mesh ReadMesh(string path, Bounds target) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (binaryReader.ReadUInt32() != 844251734) { throw new InvalidDataException("Invalid PC mesh header."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); bool flag = ((num < 3 || num > 500000) ? true : false); if (flag || num2 < 3 || num2 > 3000000 || num2 % 3 != 0 || binaryReader.BaseStream.Length != 12 + 32L * (long)num + 4L * (long)num2) { throw new InvalidDataException("Invalid PC mesh size."); } Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector2[] array3 = (Vector2[])(object)new Vector2[num]; for (int i = 0; i < num; i++) { array[i] = new Vector3(ReadFinite(binaryReader), ReadFinite(binaryReader), ReadFinite(binaryReader)); array2[i] = new Vector3(ReadFinite(binaryReader), ReadFinite(binaryReader), ReadFinite(binaryReader)); array3[i] = new Vector2(ReadFinite(binaryReader), ReadFinite(binaryReader)); if (((Vector3)(ref array2[i])).sqrMagnitude < 0.9f || ((Vector3)(ref array2[i])).sqrMagnitude > 1.1f) { throw new InvalidDataException("Invalid PC normal."); } } int[] array4 = new int[num2]; for (int j = 0; j < num2; j++) { array4[j] = binaryReader.ReadInt32(); if (array4[j] < 0 || array4[j] >= num) { throw new InvalidDataException("Invalid PC triangle."); } } Bounds val = new Bounds(array[0], Vector3.zero); Vector3[] array5 = array; foreach (Vector3 val2 in array5) { ((Bounds)(ref val)).Encapsulate(val2); } float num3 = Mathf.Min(((Bounds)(ref target)).size.x / ((Bounds)(ref val)).size.x, Mathf.Min(((Bounds)(ref target)).size.y / ((Bounds)(ref val)).size.y, ((Bounds)(ref target)).size.z / ((Bounds)(ref val)).size.z)); if (num3 <= 0f || !float.IsFinite(num3)) { throw new InvalidDataException("Invalid PC bounds."); } Vector3 val3 = new Vector3(((Bounds)(ref target)).center.x, ((Bounds)(ref target)).min.y + ((Bounds)(ref val)).extents.y * num3, ((Bounds)(ref target)).center.z); for (int l = 0; l < num; l++) { array[l] = val3 + (array[l] - ((Bounds)(ref val)).center) * num3; } Mesh val4 = new Mesh { name = "VBR Gaming PC Tower", indexFormat = (IndexFormat)1, vertices = array, normals = array2, uv = array3, triangles = array4 }; val4.RecalculateTangents(); return val4; } private static float ReadFinite(BinaryReader reader) { float num = reader.ReadSingle(); if (!float.IsFinite(num)) { throw new InvalidDataException("Non-finite PC vertex."); } return num; } private static void Release() { if (Object.op_Implicit((Object)(object)replacement)) { Object.Destroy((Object)(object)replacement); } if (Object.op_Implicit((Object)(object)finish)) { Object.Destroy((Object)(object)finish); } replacement = null; finish = null; Texture2D[] textures = Textures; foreach (Texture2D val in textures) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } Array.Clear(Textures, 0, Textures.Length); } internal static void Dispose() { ArcticComputerModel[] array = Object.FindObjectsOfType<ArcticComputerModel>(true); foreach (ArcticComputerModel obj in array) { obj.Apply(enabled: false); Object.Destroy((Object)(object)obj); } Release(); attempted = false; } } [HarmonyPatch(typeof(ValuableObject), "Awake")] internal sealed class ArcticLaptopModel : MonoBehaviour { private const string PrefabName = "Valuable Arctic Laptop"; private static Mesh? replacement; private static Material? finish; private static readonly Texture2D?[] Textures = (Texture2D?[])(object)new Texture2D[5]; private static bool attempted; private MeshFilter filter; private MeshRenderer renderer; private Mesh originalMesh; private Material originalMaterial; internal static string DisplayName(string prefabName) { return prefabName switch { "Valuable Arctic Sample Cooler" => "Fortnite Chest", "Valuable Arctic Phone" => "iPhone 4s", "Valuable Arctic Computer" => "Gaming PC", "Valuable Arctic Laptop" => "ASUS Laptop", _ => prefabName, }; } private static void Postfix(ValuableObject __instance) { string name = ((Object)((Component)__instance).gameObject).name; if (!(name != "Valuable Arctic Laptop") || !(name != "Valuable Arctic Laptop(Clone)")) { Transform val = ((Component)__instance).transform.Find("Object/Mesh"); MeshFilter val2 = default(MeshFilter); MeshRenderer val3 = default(MeshRenderer); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<MeshFilter>(ref val2) && ((Component)val).TryGetComponent<MeshRenderer>(ref val3) && Object.op_Implicit((Object)(object)val2.sharedMesh) && !(((Object)val2.sharedMesh).name != "Valuable Arctic Laptop") && Object.op_Implicit((Object)(object)((Renderer)val3).sharedMaterial) && !(((Object)((Renderer)val3).sharedMaterial.shader).name != "Standard")) { ArcticLaptopModel arcticLaptopModel = ((Component)__instance).gameObject.AddComponent<ArcticLaptopModel>(); arcticLaptopModel.filter = val2; arcticLaptopModel.renderer = val3; arcticLaptopModel.originalMesh = val2.sharedMesh; arcticLaptopModel.originalMaterial = ((Renderer)val3).sharedMaterial; arcticLaptopModel.Apply(Plugin.Instance.ArcticLaptopModel.Value); } } } private void Apply(bool enabled) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)filter) || !Object.op_Implicit((Object)(object)renderer)) { return; } if (enabled && (Object)(object)filter.sharedMesh == (Object)(object)originalMesh && (Object)(object)((Renderer)renderer).sharedMaterial == (Object)(object)originalMaterial) { if (!attempted) { Load(originalMesh.bounds, originalMaterial); } if (Object.op_Implicit((Object)(object)replacement) && Object.op_Implicit((Object)(object)finish)) { filter.sharedMesh = replacement; ((Renderer)renderer).sharedMaterial = finish; } } else if (!enabled) { if (Object.op_Implicit((Object)(object)replacement) && (Object)(object)filter.sharedMesh == (Object)(object)replacement) { filter.sharedMesh = originalMesh; } if (Object.op_Implicit((Object)(object)finish) && (Object)(object)((Renderer)renderer).sharedMaterial == (Object)(object)finish) { ((Renderer)renderer).sharedMaterial = originalMaterial; } } } internal static void Refresh() { ArcticLaptopModel[] array = Object.FindObjectsOfType<ArcticLaptopModel>(true); for (int i = 0; i < array.Length; i++) { array[i].Apply(Plugin.Instance.ArcticLaptopModel.Value); } } private static void Load(Bounds target, Material original) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: 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_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Expected O, but got Unknown //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) attempted = true; try { string path = Path.Combine(Plugin.Instance.ModDirectory, "models", "arctic-laptop"); replacement = ReadMesh(Path.Combine(path, "laptop.mesh"), target); finish = new Material(original) { name = "VBR ASUS ROG Laptop Finish" }; string[] array = new string[4] { "base", "normal", "metallic-smoothness", "emission" }; string[] array2 = new string[4] { "_MainTex", "_BumpMap", "_MetallicGlossMap", "_EmissionMap" }; for (int i = 0; i < array.Length; i++) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, i == 1 || i == 2) { name = "VBR ASUS Laptop " + array[i], filterMode = (FilterMode)2, anisoLevel = 4 }; Textures[i] = val; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, array[i] + ".png")), true)) { throw new InvalidDataException("Invalid laptop texture " + array[i]); } finish.SetTexture(array2[i], (Texture)(object)val); finish.SetTextureScale(array2[i], Vector2.one); finish.SetTextureOffset(array2[i], Vector2.zero); } Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false, true); try { if (!ImageConversion.LoadImage(val2, File.ReadAllBytes(Path.Combine(path, "rgb-mask.png")))) { throw new InvalidDataException("Invalid laptop RGB mask."); } Texture2D val3 = Textures[3]; Texture2D val4 = new Texture2D(2, 2, (TextureFormat)4, false, false); try { ImageConversion.LoadImage(val4, File.ReadAllBytes(Path.Combine(path, "emission.png"))); Color[] pixels = val4.GetPixels(); Color[] pixels2 = val2.GetPixels(); if (pixels.Length != pixels2.Length) { throw new InvalidDataException("Laptop RGB mask size mismatch."); } for (int j = 0; j < pixels.Length; j++) { pixels[j] = ((Color)(ref pixels[j])).linear * Mathf.Lerp(1f, 12f, pixels2[j].r); } Texture2D val5 = new Texture2D(((Texture)val3).width, ((Texture)val3).height, (TextureFormat)17, true, true) { name = "VBR ASUS Laptop HDR RGB", filterMode = (FilterMode)2, anisoLevel = 4 }; Textures[4] = val5; val5.SetPixels(pixels); val5.Apply(true, true); finish.SetTexture("_EmissionMap", (Texture)(object)val5); } finally { Object.Destroy((Object)(object)val4); } } finally { Object.Destroy((Object)(object)val2); } finish.SetColor("_Color", Color.white); finish.SetColor("_EmissionColor", Color.white); finish.SetFloat("_BumpScale", 1f); finish.SetFloat("_GlossMapScale", 1f); finish.SetFloat("_Mode", 0f); finish.SetFloat("_Cutoff", 0.4f); finish.SetInt("_SrcBlend", 1); finish.SetInt("_DstBlend", 0); finish.SetInt("_ZWrite", 1); finish.SetOverrideTag("RenderType", "Opaque"); finish.renderQueue = 2000; finish.DisableKeyword("_ALPHABLEND_ON"); finish.DisableKeyword("_ALPHAPREMULTIPLY_ON"); finish.DisableKeyword("_ALPHATEST_ON"); finish.EnableKeyword("_NORMALMAP"); finish.EnableKeyword("_METALLICGLOSSMAP"); finish.EnableKeyword("_EMISSION"); } catch (Exception ex) { Release(); Plugin.Instance.Warn("Could not load the ASUS Arctic Laptop model: " + ex.Message); } } private static Mesh ReadMesh(string path, Bounds target) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (binaryReader.ReadUInt32() != 844251734) { throw new InvalidDataException("Invalid laptop mesh header."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); bool flag = ((num < 3 || num > 500000) ? true : false); if (flag || num2 < 3 || num2 > 3000000 || num2 % 3 != 0 || binaryReader.BaseStream.Length != 12 + 32L * (long)num + 4L * (long)num2) { throw new InvalidDataException("Invalid laptop mesh size."); } Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector2[] array3 = (Vector2[])(object)new Vector2[num]; for (int i = 0; i < num; i++) { array[i] = new Vector3(ReadFinite(binaryReader), ReadFinite(binaryReader), ReadFinite(binaryReader)); array2[i] = new Vector3(ReadFinite(binaryReader), ReadFinite(binaryReader), ReadFinite(binaryReader)); array3[i] = new Vector2(ReadFinite(binaryReader), ReadFinite(binaryReader)); if (((Vector3)(ref array2[i])).sqrMagnitude < 0.9f || ((Vector3)(ref array2[i])).sqrMagnitude > 1.1f) { throw new InvalidDataException("Invalid laptop normal."); } } int[] array4 = new int[num2]; for (int j = 0; j < num2; j++) { array4[j] = binaryReader.ReadInt32(); if (array4[j] < 0 || array4[j] >= num) { throw new InvalidDataException("Invalid laptop triangle."); } } Bounds val = new Bounds(array[0], Vector3.zero); Vector3[] array5 = array; foreach (Vector3 val2 in array5) { ((Bounds)(ref val)).Encapsulate(val2); } float num3 = Mathf.Min(((Bounds)(ref target)).size.x / ((Bounds)(ref val)).size.x, Mathf.Min(((Bounds)(ref target)).size.y / ((Bounds)(ref val)).size.y, ((Bounds)(ref target)).size.z / ((Bounds)(ref val)).size.z)); if (num3 <= 0f || !float.IsFinite(num3)) { throw new InvalidDataException("Invalid laptop bounds."); } Vector3 val3 = new Vector3(((Bounds)(ref target)).center.x, ((Bounds)(ref target)).min.y + ((Bounds)(ref val)).extents.y * num3, ((Bounds)(ref target)).center.z); for (int l = 0; l < num; l++) { array[l] = val3 + (array[l] - ((Bounds)(ref val)).center) * num3; } Mesh val4 = new Mesh { name = "VBR ASUS ROG Strix Scar 17", indexFormat = (IndexFormat)1, vertices = array, normals = array2, uv = array3, triangles = array4 }; val4.RecalculateTangents(); return val4; } private static float ReadFinite(BinaryReader reader) { float num = reader.ReadSingle(); if (!float.IsFinite(num)) { throw new InvalidDataException("Non-finite laptop vertex."); } return num; } private static void Release() { if (Object.op_Implicit((Object)(object)replacement)) { Object.Destroy((Object)(object)replacement); } if (Object.op_Implicit((Object)(object)finish)) { Object.Destroy((Object)(object)finish); } replacement = null; finish = null; Texture2D[] textures = Textures; foreach (Texture2D val in textures) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } Array.Clear(Textures, 0, Textures.Length); } internal static void Dispose() { ArcticLaptopModel[] array = Object.FindObjectsOfType<ArcticLaptopModel>(true); foreach (ArcticLaptopModel obj in array) { obj.Apply(enabled: false); Object.Destroy((Object)(object)obj); } Release(); attempted = false; } } [HarmonyPatch(typeof(PhoneValuable), "Start")] internal sealed class ArcticPhoneModel : MonoBehaviour { private const string PrefabName = "Valuable Arctic Phone"; private static Mesh? replacement; private static Material? finish; private static readonly Texture2D?[] Textures = (Texture2D?[])(object)new Texture2D[4]; private static bool attempted; private MeshFilter filter; private MeshRenderer visual; private Mesh originalMesh; private Material originalMaterial; private Material? activeMaterial; private static void Postfix(PhoneValuable __instance) { string name = ((Object)((Component)__instance).gameObject).name; if (!(name != "Valuable Arctic Phone") || !(name != "Valuable Arctic Phone(Clone)")) { Transform val = ((Component)__instance).transform.Find("Object/Mesh"); MeshFilter val2 = default(MeshFilter); MeshRenderer val3 = default(MeshRenderer); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)__instance.phoneMesh) && val.IsChildOf(__instance.phoneMesh.transform) && ((Component)val).TryGetComponent<MeshFilter>(ref val2) && ((Component)val).TryGetComponent<MeshRenderer>(ref val3) && Object.op_Implicit((Object)(object)val2.sharedMesh) && !(((Object)val2.sharedMesh).name != "Arctic Valuable Phone") && Object.op_Implicit((Object)(object)((Renderer)val3).sharedMaterial) && !(((Object)((Renderer)val3).sharedMaterial.shader).name != "Standard")) { ArcticPhoneModel arcticPhoneModel = ((Component)__instance).gameObject.AddComponent<ArcticPhoneModel>(); arcticPhoneModel.filter = val2; arcticPhoneModel.visual = val3; arcticPhoneModel.originalMesh = val2.sharedMesh; arcticPhoneModel.originalMaterial = ((Renderer)val3).material; arcticPhoneModel.Apply(Plugin.Instance.ArcticPhoneModel.Value); } } } private void Apply(bool enabled) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)filter) || !Object.op_Implicit((Object)(object)visual)) { return; } if (enabled && (Object)(object)filter.sharedMesh == (Object)(object)originalMesh && (Object)(object)((Renderer)visual).sharedMaterial == (Object)(object)originalMaterial) { if (!attempted) { Load(originalMesh.bounds, originalMaterial.shader); } if (!Object.op_Implicit((Object)(object)replacement) || !Object.op_Implicit((Object)(object)finish)) { return; } if (!Object.op_Implicit((Object)(object)activeMaterial)) { Material val = new Material(finish) { name = "VBR iPhone 4s instance" }; ((Renderer)visual).material = val; activeMaterial = ((Renderer)visual).material; if ((Object)(object)activeMaterial != (Object)(object)val) { Object.Destroy((Object)(object)val); } } SetEmission(activeMaterial, originalMaterial.IsKeywordEnabled("_EMISSION")); filter.sharedMesh = replacement; ((Renderer)visual).material = activeMaterial; } else if (!enabled) { if (Object.op_Implicit((Object)(object)replacement) && (Object)(object)filter.sharedMesh == (Object)(object)replacement) { filter.sharedMesh = originalMesh; } if (Object.op_Implicit((Object)(object)activeMaterial) && (Object)(object)((Renderer)visual).sharedMaterial == (Object)(object)activeMaterial) { SetEmission(originalMaterial, activeMaterial.IsKeywordEnabled("_EMISSION")); ((Renderer)visual).material = originalMaterial; } } } private static void SetEmission(Material material, bool enabled) { if (enabled) { material.EnableKeyword("_EMISSION"); } else { material.DisableKeyword("_EMISSION"); } } internal static void Refresh() { ArcticPhoneModel[] array = Object.FindObjectsOfType<ArcticPhoneModel>(true); for (int i = 0; i < array.Length; i++) { array[i].Apply(Plugin.Instance.ArcticPhoneModel.Value); } } private static void Load(Bounds target, Shader shader) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0065: Expected O, but got Unknown //IL_01d0: 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_00ce: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown attempted = true; try { string path = Path.Combine(Plugin.Instance.ModDirectory, "models", "arctic-phone"); replacement = ReadMesh(Path.Combine(path, "phone.mesh"), target); finish = new Material(Shader.Find("Standard") ?? shader) { name = "VBR iPhone 4s Finish", color = Color.white }; string[] array = new string[4] { "base", "normal", "metallic-smoothness", "emission" }; string[] array2 = new string[4] { "_MainTex", "_BumpMap", "_MetallicGlossMap", "_EmissionMap" }; for (int i = 0; i < array.Length; i++) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, i == 1 || i == 2) { name = "VBR iPhone 4s " + array[i], filterMode = (FilterMode)2, anisoLevel = 4 }; Textures[i] = val; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, array[i] + ".png")), true)) { throw new InvalidDataException("Invalid phone texture " + array[i]); } finish.SetTexture(array2[i], (Texture)(object)val); } finish.SetFloat("_Mode", 0f); finish.SetInt("_SrcBlend", 1); finish.SetInt("_DstBlend", 0); finish.SetInt("_ZWrite", 1); finish.SetOverrideTag("RenderType", "Opaque"); finish.renderQueue = 2000; finish.SetFloat("_GlossMapScale", 1f); finish.SetColor("_EmissionColor", Color.white); finish.EnableKeyword("_NORMALMAP"); finish.EnableKeyword("_METALLICGLOSSMAP"); finish.DisableKeyword("_EMISSION"); } catch (Exception ex) { Release(); Plugin.Instance.Warn("Could not load the Arctic Phone iPhone model: " + ex.Message); } } private static Mesh ReadMesh(string path, Bounds target) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0283: 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_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (binaryReader.ReadUInt32() != 844251734) { throw new InvalidDataException("Invalid phone mesh header."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); bool flag = ((num < 3 || num > 500000) ? true : false); if (flag || num2 < 3 || num2 > 3000000 || num2 % 3 != 0 || binaryReader.BaseStream.Length != 12 + 32L * (long)num + 4L * (long)num2) { throw new InvalidDataException("Invalid phone mesh size."); } Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector2[] array3 = (Vector2[])(object)new Vector2[num]; for (int i = 0; i < num; i++) { array[i] = new Vector3(ReadFinite(binaryReader), ReadFinite(binaryReader), ReadFinite(binaryReader)); array2[i] = new Vector3(ReadFinite(binaryReader), ReadFinite(binaryReader), ReadFinite(binaryReader)); array3[i] = new Vector2(ReadFinite(binaryReader), ReadFinite(binaryReader)); if (((Vector3)(ref array2[i])).sqrMagnitude < 0.9f || ((Vector3)(ref array2[i])).sqrMagnitude > 1.1f) { throw new InvalidDataException("Invalid phone normal."); } } int[] array4 = new int[num2]; for (int j = 0; j < num2; j++) { array4[j] = binaryReader.ReadInt32(); if (array4[j] < 0 || array4[j] >= num) { throw new InvalidDataException("Invalid phone triangle."); } } Bounds val = new Bounds(array[0], Vector3.zero); Vector3[] array5 = array; foreach (Vector3 val2 in array5) { ((Bounds)(ref val)).Encapsulate(val2); } float num3 = Mathf.Min(((Bounds)(ref target)).size.x / ((Bounds)(ref val)).size.x, Mathf.Min(((Bounds)(ref target)).size.y / ((Bounds)(ref val)).size.y, ((Bounds)(ref target)).size.z / ((Bounds)(ref val)).size.z)); if (num3 <= 0f || !float.IsFinite(num3)) { throw new InvalidDataException("Invalid phone bounds."); } for (int l = 0; l < num; l++) { array[l] = ((Bounds)(ref target)).center + (array[l] - ((Bounds)(ref val)).center) * num3; } Mesh val3 = new Mesh { name = "VBR iPhone 4s", indexFormat = (IndexFormat)1, vertices = array, normals = array2, uv = array3, triangles = array4 }; val3.RecalculateTangents(); return val3; } private static float ReadFinite(BinaryReader reader) { float num = reader.ReadSingle(); if (!float.IsFinite(num)) { throw new InvalidDataException("Non-finite phone vertex."); } return num; } private static void Release() { if (Object.op_Implicit((Object)(object)replacement)) { Object.Destroy((Object)(object)replacement); } if (Object.op_Implicit((Object)(object)finish)) { Object.Destroy((Object)(object)finish); } replacement = null; finish = null; Texture2D[] textures = Textures; foreach (Texture2D val in textures) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } Array.Clear(Textures, 0, Textures.Length); } private void OnDestroy() { Apply(enabled: false); if (Object.op_Implicit((Object)(object)activeMaterial)) { Object.Destroy((Object)(object)activeMaterial); } } internal static void Dispose() { ArcticPhoneModel[] array = Object.FindObjectsOfType<ArcticPhoneModel>(true); foreach (ArcticPhoneModel arcticPhoneModel in array) { arcticPhoneModel.Apply(enabled: false); if (Object.op_Implicit((Object)(object)arcticPhoneModel.activeMaterial)) { Object.Destroy((Object)(object)arcticPhoneModel.activeMaterial); } arcticPhoneModel.activeMaterial = null; Object.Destroy((Object)(object)arcticPhoneModel); } Release(); attempted = false; } } [HarmonyPatch(typeof(EnemyBeamer), "Awake")] internal static class BeamerRainbowLaserPatch { private static void Postfix(EnemyBeamer __instance) { SemiLaser laser = __instance.laser; if (Object.op_Implicit((Object)(object)laser)) { BeamerRainbowLaser beamerRainbowLaser = ((Component)laser).GetComponent<BeamerRainbowLaser>(); if (!Object.op_Implicit((Object)(object)beamerRainbowLaser)) { beamerRainbowLaser = ((Component)laser).gameObject.AddComponent<BeamerRainbowLaser>(); } beamerRainbowLaser.Configure(laser); } } } [HarmonyPatch(typeof(ValuableWizardStaff), "Start")] internal static class WizardStaffRainbowLaserPatch { private static void Postfix(ValuableWizardStaff __instance) { SemiLaser semiLaser = __instance.semiLaser; if (Object.op_Implicit((Object)(object)semiLaser)) { StaffRainbowPhase staffRainbowPhase = ((Component)__instance).GetComponent<StaffRainbowPhase>(); if (!Object.op_Implicit((Object)(object)staffRainbowPhase)) { staffRainbowPhase = ((Component)__instance).gameObject.AddComponent<StaffRainbowPhase>(); staffRainbowPhase.Configure(__instance); } BeamerRainbowLaser beamerRainbowLaser = ((Component)semiLaser).GetComponent<BeamerRainbowLaser>(); if (!Object.op_Implicit((Object)(object)beamerRainbowLaser)) { beamerRainbowLaser = ((Component)semiLaser).gameObject.AddComponent<BeamerRainbowLaser>(); } beamerRainbowLaser.Configure(semiLaser, wizardStaff: true); beamerRainbowLaser.StaffPhase = staffRainbowPhase; beamerRainbowLaser.BindStaffSwirl(__instance); (((Component)__instance).GetComponent<RainbowStaffJewel>() ?? ((Component)__instance).gameObject.AddComponent<RainbowStaffJewel>()).Configure(__instance); } } } internal sealed class BeamerRainbowLaser : MonoBehaviour { private sealed class BeamTint { internal Renderer Renderer; internal int Slot = -1; internal readonly MaterialPropertyBlock Original = new MaterialPropertyBlock(); internal readonly MaterialPropertyBlock Working = new MaterialPropertyBlock(); internal Color Color; } private sealed class LightTint { internal Light Light; internal Color Color; } private sealed class ParticleTint { internal ParticleSystem System; internal MinMaxGradient Original; internal MinMaxGradient Neutral; } private static readonly int ColorId = Shader.PropertyToID("_Color"); private readonly List<BeamTint> beams = new List<BeamTint>(); private readonly List<LightTint> lights = new List<LightTint>(); private readonly List<ParticleTint> particles = new List<ParticleTint>(); private SemiLaser laser; private bool applied; private bool staff; internal StaffRainbowPhase? StaffPhase; internal void Configure(SemiLaser owner, bool wizardStaff = false) { //IL_00b5: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Invalid comparison between Unknown and I4 //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)laser)) { return; } laser = owner; staff = wizardStaff; if (!Object.op_Implicit((Object)(object)owner.enableLaser)) { return; } string[] array = new string[2] { "Line", "Line Inside" }; foreach (string text in array) { Transform val = owner.enableLaser.transform.Find(text); LineRenderer val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<LineRenderer>() : null); if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)((Renderer)val2).sharedMaterial) && ((Renderer)val2).sharedMaterial.HasProperty(ColorId)) { BeamTint beamTint = new BeamTint { Renderer = (Renderer)(object)val2, Color = ((Renderer)val2).sharedMaterial.GetColor(ColorId) }; ((Renderer)val2).GetPropertyBlock(beamTint.Original); beams.Add(beamTint); } } if (Object.op_Implicit((Object)(object)owner.hitTransform)) { MeshRenderer[] componentsInChildren = ((Component)owner.hitTransform).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer renderer in componentsInChildren) { Add((Renderer)(object)renderer); } } Transform[] array2 = (Transform[])(object)new Transform[3] { owner.hitParticlesTransform, owner.shootTransform, owner.graceTransform }; foreach (Transform val3 in array2) { if (Object.op_Implicit((Object)(object)val3)) { ParticleSystemRenderer[] componentsInChildren2 = ((Component)val3).GetComponentsInChildren<ParticleSystemRenderer>(true); foreach (ParticleSystemRenderer renderer2 in componentsInChildren2) { Add((Renderer)(object)renderer2); } ParticleSystem[] componentsInChildren3 = ((Component)val3).GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem ps in componentsInChildren3) { AddParticle(ps); } } } Light[] componentsInChildren4 = owner.enableLaser.GetComponentsInChildren<Light>(true); foreach (Light val4 in componentsInChildren4) { if ((int)val4.type == 2 && (int)val4.shadows == 0) { lights.Add(new LightTint { Light = val4, Color = val4.color }); } } if (Object.op_Implicit((Object)(object)owner.laserSpotLight)) { lights.Add(new LightTint { Light = owner.laserSpotLight, Color = owner.laserSpotLight.color }); } } private void Add(Renderer renderer) { //IL_0049: 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) if (!Object.op_Implicit((Object)(object)renderer)) { return; } Material[] sharedMaterials = renderer.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if (Object.op_Implicit((Object)(object)sharedMaterials[i]) && sharedMaterials[i].HasProperty(ColorId)) { BeamTint beamTint = new BeamTint { Renderer = renderer, Slot = i, Color = sharedMaterials[i].GetColor(ColorId) }; renderer.GetPropertyBlock(beamTint.Original, i); beams.Add(beamTint); } } } internal void BindStaffSwirl(ValuableWizardStaff owner) { Transform val = ((Component)owner).transform.Find("Object/Mesh/Staff/Particle Swirl"); if (Object.op_Implicit((Object)(object)val)) { Add((Renderer)(object)((Component)val).GetComponent<ParticleSystemRenderer>()); AddParticle(((Component)val).GetComponent<ParticleSystem>()); } } private void AddParticle(ParticleSystem ps) { //IL_0009: 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_001a: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_003c: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)ps)) { ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { colorOverLifetime = ps.colorOverLifetime; MinMaxGradient color = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color; particles.Add(new ParticleTint { System = ps, Original = color, Neutral = ParticlePalette.Neutral(color) }); } } } private void LateUpdate() { //IL_008f: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Plugin.Instance) || !(staff ? Plugin.Instance.RainbowStaffLaser.Value : Plugin.Instance.RainbowLaser.Value) || !Object.op_Implicit((Object)(object)laser) || !Object.op_Implicit((Object)(object)laser.enableLaser)) { Restore(); return; } Color val = (Object.op_Implicit((Object)(object)StaffPhase) ? StaffPhase.Sample() : Color.HSVToRGB(Mathf.Repeat(Time.time, 1f), 1f, 1f)); if (!applied) { foreach (ParticleTint particle in particles) { if (Object.op_Implicit((Object)(object)particle.System)) { ColorOverLifetimeModule colorOverLifetime = particle.System.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = particle.Neutral; } } } foreach (BeamTint beam in beams) { if (Object.op_Implicit((Object)(object)beam.Renderer)) { Color val2 = val * Mathf.Max(beam.Color.r, Mathf.Max(beam.Color.g, beam.Color.b)); val2.a = beam.Color.a; if (beam.Slot < 0) { beam.Renderer.GetPropertyBlock(beam.Working); } else { beam.Renderer.GetPropertyBlock(beam.Working, beam.Slot); } beam.Working.SetColor(ColorId, val2); if (beam.Slot < 0) { beam.Renderer.SetPropertyBlock(beam.Working); } else { beam.Renderer.SetPropertyBlock(beam.Working, beam.Slot); } } } foreach (LightTint light in lights) { if (Object.op_Implicit((Object)(object)light.Light)) { Color color = val * Mathf.Max(light.Color.r, Mathf.Max(light.Color.g, light.Color.b)); color.a = light.Color.a; light.Light.color = color; } } applied = true; } private void Restore() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if (!applied) { return; } foreach (BeamTint beam in beams) { if (Object.op_Implicit((Object)(object)beam.Renderer)) { MaterialPropertyBlock val = (beam.Original.isEmpty ? null : beam.Original); if (beam.Slot < 0) { beam.Renderer.SetPropertyBlock(val); } else { beam.Renderer.SetPropertyBlock(val, beam.Slot); } } } foreach (LightTint light in lights) { if (Object.op_Implicit((Object)(object)light.Light)) { light.Light.color = light.Color; } } foreach (ParticleTint particle in particles) { if (Object.op_Implicit((Object)(object)particle.System)) { ColorOverLifetimeModule colorOverLifetime = particle.System.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = particle.Original; } } applied = false; } private void OnDisable() { Restore(); } private void OnDestroy() { Restore(); } } internal sealed class CashoutActivity : MonoBehaviour { private const float ProcessingDelay = 1f; private const float FlashInterval = 0.18f; private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor"); private static readonly FieldRef<Sound, float> LoopStart = AccessTools.FieldRefAccess<Sound, float>("StartTimeOverride"); private ValuableObject valuable; private PhysGrabObject physical; private PhysGrabObjectImpactDetector detector; private MeshFilter filter; private MeshRenderer visual; private readonly MaterialPropertyBlock originalBlock = new MaterialPropertyBlock(); private readonly MaterialPropertyBlock block = new MaterialPropertyBlock(); private bool ownsEmission; private bool held; private bool pickupStarted; private bool loopsStarted; private bool destroyed; private float loopsAt; private float flashStarted = -1f; private float damageFlashStarted = -1f; private Color emission; private AudioSource? pickup; private Sound? processing; private Sound? money; private bool Active { get { if (Plugin.Instance.CashoutCoolerModel.Value && Object.op_Implicit((Object)(object)filter) && Object.op_Implicit((Object)(object)filter.sharedMesh)) { return ((Object)filter.sharedMesh).name == "VBR Cashout Terminal"; } return false; } } internal bool IsHeld { get { if (!Object.op_Implicit((Object)(object)physical)) { return false; } foreach (PhysGrabber item in physical.playerGrabbing) { if (Object.op_Implicit((Object)(object)item) && item.grabbed) { return true; } } return false; } } private Vector3 Position { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) if (!Object.op_Implicit((Object)(object)visual)) { return ((Component)this).transform.position; } Bounds bounds = ((Renderer)visual).bounds; return ((Bounds)(ref bounds)).center; } } internal void Initialize(ValuableObject owner, MeshFilter mesh, MeshRenderer renderer) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown valuable = owner; physical = ((Component)owner).GetComponent<PhysGrabObject>(); detector = ((Component)owner).GetComponent<PhysGrabObjectImpactDetector>(); filter = mesh; visual = renderer; if (Object.op_Implicit((Object)(object)detector)) { detector.onDestroy.AddListener(new UnityAction(Destroyed)); } } private void LateUpdate() { //IL_0090: 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_0095: 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_00cc: 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_0117: 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) if (!Object.op_Implicit((Object)(object)valuable) || !Active || destroyed || !Object.op_Implicit((Object)(object)physical) || physical.dead) { Reset(); return; } bool isHeld = IsHeld; if (isHeld != held) { held = isHeld; if (isHeld) { flashStarted = -1f; } else { damageFlashStarted = -1f; StopAudio(); flashStarted = Time.time; } } Color val = (held ? Color.white : Color.black); if (held && damageFlashStarted >= 0f) { int num = Mathf.FloorToInt((Time.time - damageFlashStarted) / 0.18f); if (num < 6 && num % 2 == 0) { val = Color.red; } if (num >= 6) { damageFlashStarted = -1f; } } if (!held && flashStarted >= 0f) { int num2 = Mathf.FloorToInt((Time.time - flashStarted) / 0.18f); if (num2 < 6 && num2 % 2 == 0) { val = Color.red; } if (num2 >= 6) { flashStarted = -1f; } } SetEmission(val); if (!Plugin.Instance.Effects.Value || !held) { StopAudio(); } else { if (!Plugin.Instance.Catalog.Ready) { return; } if (!pickupStarted) { pickupStarted = true; pickup = Play("vbr cashout pickup", 0.8f, follow: true); loopsAt = Time.time + 1f; } if (!(Time.time < loopsAt)) { if (!loopsStarted) { loopsStarted = true; processing = CreateLoop("vbr cashout processing", 0.8f); money = CreateLoop("vbr cashout processing money", 0.2f); } UpdateLoop(processing); UpdateLoop(money); } } } private AudioSource? Play(string key, float volume, bool follow) { //IL_0039: 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) Sound val = CreateSound(key, volume); if (val == null) { return null; } if (!follow) { return val.Play(Position, 1f, 1f, 1f, 1f); } return val.Play(((Component)this).transform, Position, 1f, 1f, 1f, 1f); } private static Sound? CreateSound(string key, float volume) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) AudioClip effect = Plugin.Instance.Catalog.GetEffect(key); if (!Object.op_Implicit((Object)(object)effect)) { return null; } Sound val = new Sound(); val.Sounds = (AudioClip[])(object)new AudioClip[1] { effect }; val.Type = (AudioType)0; val.Volume = volume; val.VolumeRandom = 0f; val.Pitch = 1f; val.PitchRandom = 0f; val.SpatialBlend = 1f; val.Doppler = 0f; val.ReverbMix = 1f; return val; } private Sound? CreateLoop(string key, float volume) { //IL_0046: 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) Sound val = CreateSound(key, volume); if (val == null || !Object.op_Implicit((Object)(object)AudioManager.instance) || !Object.op_Implicit((Object)(object)AudioManager.instance.AudioDefault)) { return null; } LoopStart.Invoke(val) = 0f; GameObject val2 = Object.Instantiate<GameObject>(AudioManager.instance.AudioDefault, Position, Quaternion.identity, AudioManager.instance.SoundsParent); ((Object)val2).name = "VBR Cashout " + key; val.Source = val2.GetComponent<AudioSource>(); if (!Object.op_Implicit((Object)(object)val.Source)) { Object.Destroy((Object)(object)val2); return null; } val.Source.Stop(); val.PlayLoop(true, 20f, 20f, 1f, 1f); return val; } private void UpdateLoop(Sound? sound) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (sound != null && Object.op_Implicit((Object)(object)sound.Source)) { ((Component)sound.Source).transform.position = Position; sound.PlayLoop(true, 20f, 20f, 1f, 1f); } } private void SetEmission(Color color) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0072: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)visual) && (!ownsEmission || !(emission == color))) { if (!ownsEmission) { ((Renderer)visual).GetPropertyBlock(originalBlock); } ((Renderer)visual).GetPropertyBlock(block); block.SetColor(EmissionColor, color); ((Renderer)visual).SetPropertyBlock(block); emission = color; ownsEmission = true; } } private static void StopSource(AudioSource? source) { if (Object.op_Implicit((Object)(object)source)) { source.Stop(); Object.Destroy((Object)(object)((Component)source).gameObject); } } private void StopAudio() { StopSource(pickup); StopSource(processing?.Source); StopSource(money?.Source); pickup = null; processing = (money = null); pickupStarted = (loopsStarted = false); } internal void Damage() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Active) { if (!destroyed && IsHeld) { damageFlashStarted = Time.time; SetEmission(Color.red); } if (Plugin.Instance.Effects.Value) { Play("vbr cashout damage", 0.65f, follow: true); } } } private void Destroyed() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!destroyed) { destroyed = true; StopAudio(); if (Active && Plugin.Instance.Effects.Value) { Play("vbr cashout stop", 0.6f, follow: false); } SetEmission(Color.black); } } internal void Reset() { StopAudio(); held = false; flashStarted = -1f; damageFlashStarted = -1f; if (ownsEmission && Object.op_Implicit((Object)(object)visual)) { ((Renderer)visual).SetPropertyBlock(originalBlock); } ownsEmission = false; } private void OnDisable() { Reset(); } private void OnDestroy() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)detector)) { detector.onDestroy.RemoveListener(new UnityAction(Destroyed)); } Reset(); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")] internal static class CashoutValueLoss { private static readonly FieldRef<ValuableObject, float> Value = AccessTools.FieldRefAccess<ValuableObject, float>("dollarValueCurrent"); private static void Prefix(PhysGrabObjectImpactDetector __instance, PhotonMessageInfo _info, out (CashoutActivity? Activity, ValuableObject? Valuable, float Before, bool Held) __state) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) CashoutActivity component = ((Component)__instance).GetComponent<CashoutActivity>(); ValuableObject val = (Object.op_Implicit((Object)(object)component) ? ((Component)__instance).GetComponent<ValuableObject>() : null); __state = (Activity: component, Valuable: val, Before: Object.op_Implicit((Object)(object)val) ? Value.Invoke(val) : 0f, Held: Object.op_Implicit((Object)(object)component) && component.IsHeld && SemiFunc.MasterOnlyRPC(_info)); } private static void Postfix((CashoutActivity? Activity, ValuableObject? Valuable, float Before, bool Held) __state) { if (__state.Held && Object.op_Implicit((Object)(object)__state.Activity) && Object.op_Implicit((Object)(object)__state.Valuable) && Value.Invoke(__state.Valuable) < __state.Before) { __state.Activity.Damage(); } } } [HarmonyPatch(typeof(ValuableObject), "Awake")] internal sealed class CashoutCooler : MonoBehaviour { private const string PrefabName = "Valuable Arctic Sample Cooler Wide"; private static readonly Texture2D?[] Textures = (Texture2D?[])(object)new Texture2D[4]; private static Mesh? terminal; private static Material? finish; private static bool loadAttempted; private static PhysAudio? metalAudio; private static bool audioLoadAttempted; private static readonly FieldInfo ImpactAudioField = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "impactAudio"); private MeshFilter filter; private MeshRenderer meshRenderer; private Mesh originalMesh; private Material originalMaterial; private ValuableObject valuable; private PhysAudio originalAudio; private CashoutActivity activity; private static void Postfix(ValuableObject __instance) { string name = ((Object)((Component)__instance).gameObject).name; if (name != "Valuable Arctic Sample Cooler Wide" && name != "Valuable Arctic Sample Cooler Wide(Clone)") { return; } Transform val = ((Component)__instance).transform.Find("Object/Mesh"); MeshFilter val2 = default(MeshFilter); MeshRenderer val3 = default(MeshRenderer); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<MeshFilter>(ref val2) && ((Component)val).TryGetComponent<MeshRenderer>(ref val3)) { Mesh sharedMesh = val2.sharedMesh; Material sharedMaterial = ((Renderer)val3).sharedMaterial; if (Object.op_Implicit((Object)(object)sharedMesh) && !(((Object)sharedMesh).name != "Arctic Valuable Big Crate") && Object.op_Implicit((Object)(object)sharedMaterial) && !(((Object)sharedMaterial.shader).name != "Standard")) { CashoutCooler cashoutCooler = ((Component)__instance).gameObject.AddComponent<CashoutCooler>(); cashoutCooler.filter = val2; cashoutCooler.meshRenderer = val3; cashoutCooler.originalMesh = sharedMesh; cashoutCooler.originalMaterial = sharedMaterial; cashoutCooler.valuable = __instance; cashoutCooler.originalAudio = __instance.audioPreset; cashoutCooler.Apply(Plugin.Instance.CashoutCoolerModel.Value); cashoutCooler.activity = ((Component)__instance).gameObject.AddComponent<CashoutActivity>(); cashoutCooler.activity.Initialize(__instance, val2, val3); } } } private void Apply(bool enabled) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (!enabled && Object.op_Implicit((Object)(object)activity)) { activity.Reset(); } ApplyAudio(enabled && Plugin.Instance.Effects.Value); if (!Object.op_Implicit((Object)(object)filter) || !Object.op_Implicit((Object)(object)meshRenderer)) { return; } if (enabled && (Object)(object)filter.sharedMesh == (Object)(object)originalMesh && (Object)(object)((Renderer)meshRenderer).sharedMaterial == (Object)(object)originalMaterial) { if (!loadAttempted) { Load(originalMesh.bounds, originalMaterial.shader); } if (Object.op_Implicit((Object)(object)terminal) && Object.op_Implicit((Object)(object)finish)) { filter.sharedMesh = terminal; ((Renderer)meshRenderer).sharedMaterial = finish; } } else if (!enabled) { if (Object.op_Implicit((Object)(object)terminal) && (Object)(object)filter.sharedMesh == (Object)(object)terminal) { filter.sharedMesh = originalMesh; } if (Object.op_Implicit((Object)(object)finish) && (Object)(object)((Renderer)meshRenderer).sharedMaterial == (Object)(object)finish) { ((Renderer)meshRenderer).sharedMaterial = originalMaterial; } } } private void ApplyAudio(bool enabled) { //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)valuable)) { return; } if (enabled && !audioLoadAttempted) { audioLoadAttempted = true; GameObject val = ((PrefabRef<GameObject>)(object)(from list in Resources.LoadAll<LevelValuables>("ScriptableObjects").Concat(RunManager.instance.levels.SelectMany((Level level) => level.ValuablePresets)).SelectMany((LevelValuables preset) => new List<PrefabRef>[7] { preset.tiny, preset.small, preset.medium, preset.big, preset.wide, preset.tall, preset.veryTall }) where list != null select list).SelectMany((List<PrefabRef> list) => list).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef item) => item != null && ((PrefabRef<GameObject>)(object)item).PrefabName == "Valuable Arctic Snow Bike" && ((PrefabRef<GameObject>)(object)item).IsValid())))?.Prefab; metalAudio = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetComponent<ValuableObject>()?.audioPreset); if (Object.op_Implicit((Object)(object)metalAudio) && ((Object)metalAudio).name != "PhysAudio - Metal Hollow Big") { metalAudio = null; } if (!Object.op_Implicit((Object)(object)metalAudio)) { Plugin.Instance.Warn("Cashout Metal hollow Big audio preset was not found."); } } PhysAudio val2 = (PhysAudio)((enabled && Object.op_Implicit((Object)(object)metalAudio)) ? ((object)metalAudio) : ((object)originalAudio)); PhysAudio audioPreset = valuable.audioPreset; if ((Object)(object)audioPreset != (Object)(object)originalAudio && (Object)(object)audioPreset != (Object)(object)metalAudio) { return; } valuable.audioPreset = val2; PhysGrabObjectImpactDetector component = ((Component)valuable).GetComponent<PhysGrabObjectImpactDetector>(); if (Object.op_Implicit((Object)(object)component)) { PhysAudio val3 = (PhysAudio)ImpactAudioField.GetValue(component); if ((Object)(object)val3 == (Object)(object)originalAudio || (Object)(object)val3 == (Object)(object)metalAudio) { ImpactAudioField.SetValue(component, val2); } } } internal static void Refresh() { CashoutCooler[] array = Object.FindObjectsOfType<CashoutCooler>(true); for (int i = 0; i < array.Length; i++) { array[i].Apply(Plugin.Instance.CashoutCoolerModel.Value); } } private static void Load(Bounds bounds, Shader shader) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) loadAttempted = true; try { string text = Path.Combine(Plugin.Instance.ModDirectory, "models", "cashout"); terminal = ReadMesh(Path.Combine(text, "terminal.mesh"), bounds); finish = new Material(shader) { name = "VBR Cashout Finish" }; SetTexture(text, 0, "base", "_MainTex", linear: false); SetTexture(text, 1, "normal", "_BumpMap", linear: true); SetTexture(text, 2, "metallic-smoothness", "_MetallicGlossMap", linear: true); SetTexture(text, 3, "emission", "_EmissionMap", linear: false); finish.SetFloat("_GlossMapScale", 1f); finish.SetColor("_EmissionColor", Color.black); finish.EnableKeyword("_NORMALMAP"); finish.EnableKeyword("_METALLICGLOSSMAP"); finish.EnableKeyword("_EMISSION"); } catch (Exception ex) { ReleaseAssets(); Plugin.Instance.Warn("Could not load the Cashout cooler model: " + ex.Message); } } private static void SetTexture(string directory, int index, string name, string property, bool linear) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = "VBR Cashout " + name, filterMode = (FilterMode)2, anisoLevel = 4 }; Textures[index] = val; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(directory, name + ".png")), true)) { throw new InvalidDataException("Invalid Cashout texture " + name); } finish.SetTexture(property, (Texture)(object)val); } private static Mesh ReadMesh(string path, Bounds target) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_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_0159: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (binaryReader.ReadUInt32() != 827474518) { throw new InvalidDataException("Invalid Cashout mesh header."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); bool flag = ((num < 3 || num > 65535) ? true : false); if (flag || num2 < 3 || num2 % 3 != 0 || binaryReader.BaseStream.Length