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 StorableValuables v1.0.4
StorableValuables.dll
Decompiled 4 months 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Tolga")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4")] [assembly: AssemblyProduct("StorableValuables")] [assembly: AssemblyTitle("StorableValuables")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 StoreValuables { public static class Config { public static ConfigEntry<bool> EnableValuableStorage; public static ConfigEntry<bool> EnableStaminaDrain; public static ConfigEntry<bool> EnableMovementPenalty; public static ConfigEntry<bool> EnableAutoDropOnStaminaDepletion; public static ConfigEntry<bool> EnableDamageOnDrop; public static ConfigEntry<float> StaminaDrainBase; public static ConfigEntry<float> StaminaDrainWeightMultiplier; public static ConfigEntry<string> StaminaDrainCalculationMode; public static ConfigEntry<float> StaminaDepletionThreshold; public static ConfigEntry<float> StaminaWarningThreshold; public static ConfigEntry<float> MovementSpeedPenaltyPerWeight; public static ConfigEntry<float> MinMovementSpeedMultiplier; public static ConfigEntry<float> MaxMovementSpeedPenalty; public static ConfigEntry<bool> ApplyToSprintSpeed; public static ConfigEntry<bool> ApplyToCrouchSpeed; public static ConfigEntry<string> MovementPenaltyCalculationMode; public static ConfigEntry<float> DamagePercentage; public static ConfigEntry<float> MinDamageAmount; public static ConfigEntry<float> MaxDamageAmount; public static ConfigEntry<string> DamageCalculationMode; public static ConfigEntry<float> MaxWeightPerSlot; public static ConfigEntry<float> MaxTotalWeight; public static ConfigEntry<bool> AllowMultipleValuablesPerSlot; public static ConfigEntry<bool> RequireEmptySlot; public static ConfigEntry<bool> AutoReleaseOnDeath; public static ConfigEntry<bool> ShowWeightIndicator; public static ConfigEntry<bool> ShowStaminaDrainIndicator; public static ConfigEntry<bool> ShowStaminaWarning; public static ConfigEntry<Color> StaminaWarningColor; public static ConfigEntry<bool> ShowDamageNotification; public static ConfigEntry<string> WeightDisplayFormat; public static ConfigEntry<string> StaminaDrainDisplayFormat; public static ConfigEntry<float> TotalWeightHudOffsetX; public static ConfigEntry<float> TotalWeightHudOffsetY; public static ConfigEntry<bool> NetworkSyncEnabled; public static ConfigEntry<string> PhysicsModeOnStore; public static ConfigEntry<Vector3> DropPositionOffset; public static ConfigEntry<float> DropForce; public static ConfigEntry<float> DropDistance; public static ConfigEntry<float> CooldownAfterDrop; public static ConfigEntry<bool> ShowRotatingIcon; public static ConfigEntry<bool> DebugLogging; public static void Initialize(ConfigFile configFile) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Expected O, but got Unknown //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Expected O, but got Unknown //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Expected O, but got Unknown //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Expected O, but got Unknown //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Expected O, but got Unknown //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Expected O, but got Unknown //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Expected O, but got Unknown //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Expected O, but got Unknown //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Expected O, but got Unknown //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Expected O, but got Unknown //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Expected O, but got Unknown EnableValuableStorage = configFile.Bind<bool>("Feature Toggles", "EnableValuableStorage", true, "Master toggle to enable/disable storing valuables in inventory"); EnableStaminaDrain = configFile.Bind<bool>("Feature Toggles", "EnableStaminaDrain", true, "Enable/disable stamina drain while holding valuables"); EnableMovementPenalty = configFile.Bind<bool>("Feature Toggles", "EnableMovementPenalty", true, "Enable/disable movement speed penalty based on weight"); EnableAutoDropOnStaminaDepletion = configFile.Bind<bool>("Feature Toggles", "EnableAutoDropOnStaminaDepletion", true, "Enable/disable automatic drop when stamina reaches 0"); EnableDamageOnDrop = configFile.Bind<bool>("Feature Toggles", "EnableDamageOnDrop", true, "Enable/disable damage to valuable when dropped due to stamina depletion"); StaminaDrainBase = configFile.Bind<float>("Stamina System", "StaminaDrainBase", 5f, new ConfigDescription("Base stamina drain per second (applies even with no weight)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>())); StaminaDrainWeightMultiplier = configFile.Bind<float>("Stamina System", "StaminaDrainWeightMultiplier", 2f, new ConfigDescription("Additional stamina drain per unit of weight", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>())); StaminaDrainCalculationMode = configFile.Bind<string>("Stamina System", "StaminaDrainCalculationMode", "Linear", new ConfigDescription("How weight affects stamina drain: Linear or Exponential", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Linear", "Exponential" }), Array.Empty<object>())); StaminaDepletionThreshold = configFile.Bind<float>("Stamina System", "StaminaDepletionThreshold", 0f, new ConfigDescription("Stamina level at which auto-drop triggers (0 = exact zero)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>())); StaminaWarningThreshold = configFile.Bind<float>("Stamina System", "StaminaWarningThreshold", 20f, new ConfigDescription("Stamina level to show warning UI (0 = disabled)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>())); MovementSpeedPenaltyPerWeight = configFile.Bind<float>("Movement Speed", "MovementSpeedPenaltyPerWeight", 0.1f, new ConfigDescription("Speed reduction per unit of weight (0.1 = 10% per weight)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); MinMovementSpeedMultiplier = configFile.Bind<float>("Movement Speed", "MinMovementSpeedMultiplier", 0.3f, new ConfigDescription("Minimum movement speed (0.3 = 30% of base speed)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); MaxMovementSpeedPenalty = configFile.Bind<float>("Movement Speed", "MaxMovementSpeedPenalty", 0.7f, new ConfigDescription("Maximum speed reduction (0.7 = can reduce up to 70%, leaving 30% minimum)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); ApplyToSprintSpeed = configFile.Bind<bool>("Movement Speed", "ApplyToSprintSpeed", true, "Apply penalty to sprint speed as well"); ApplyToCrouchSpeed = configFile.Bind<bool>("Movement Speed", "ApplyToCrouchSpeed", true, "Apply penalty to crouch speed as well"); MovementPenaltyCalculationMode = configFile.Bind<string>("Movement Speed", "MovementPenaltyCalculationMode", "Linear", new ConfigDescription("How weight affects movement: Linear, Exponential, or Step", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Linear", "Exponential", "Step" }), Array.Empty<object>())); DamagePercentage = configFile.Bind<float>("Damage System", "DamagePercentage", 0.1f, new ConfigDescription("Percentage of value lost (0.1 = 10%, 1.0 = 100%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); MinDamageAmount = configFile.Bind<float>("Damage System", "MinDamageAmount", 1f, new ConfigDescription("Minimum damage amount in dollars (prevents tiny damages)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000000f), Array.Empty<object>())); MaxDamageAmount = configFile.Bind<float>("Damage System", "MaxDamageAmount", -1f, new ConfigDescription("Maximum damage amount (-1 = no limit, otherwise caps damage)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1000000f), Array.Empty<object>())); DamageCalculationMode = configFile.Bind<string>("Damage System", "DamageCalculationMode", "Percentage", new ConfigDescription("How damage is calculated: Percentage, Fixed, or WeightBased", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Percentage", "Fixed", "WeightBased" }), Array.Empty<object>())); MaxWeightPerSlot = configFile.Bind<float>("Storage System", "MaxWeightPerSlot", -1f, new ConfigDescription("Maximum weight allowed per slot (-1 = unlimited)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1000000f), Array.Empty<object>())); MaxTotalWeight = configFile.Bind<float>("Storage System", "MaxTotalWeight", -1f, new ConfigDescription("Maximum total weight across all slots (-1 = unlimited)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1000000f), Array.Empty<object>())); AllowMultipleValuablesPerSlot = configFile.Bind<bool>("Storage System", "AllowMultipleValuablesPerSlot", false, "Not implemented yet; currently has no effect (reserved for a future feature)."); RequireEmptySlot = configFile.Bind<bool>("Storage System", "RequireEmptySlot", true, "Require slot to be empty before storing (prevents overwriting)"); AutoReleaseOnDeath = configFile.Bind<bool>("Storage System", "AutoReleaseOnDeath", true, "Automatically drop all stored valuables when player dies"); ShowWeightIndicator = configFile.Bind<bool>("Visual/UI", "ShowWeightIndicator", true, "Show weight indicator in inventory UI"); ShowStaminaDrainIndicator = configFile.Bind<bool>("Visual/UI", "ShowStaminaDrainIndicator", true, "Show stamina drain rate in UI"); ShowStaminaWarning = configFile.Bind<bool>("Visual/UI", "ShowStaminaWarning", true, "Show warning when stamina is low"); StaminaWarningColor = configFile.Bind<Color>("Visual/UI", "StaminaWarningColor", Color.red, "Color for stamina warning UI"); ShowDamageNotification = configFile.Bind<bool>("Visual/UI", "ShowDamageNotification", true, "Show notification when valuable takes damage on drop"); WeightDisplayFormat = configFile.Bind<string>("Visual/UI", "WeightDisplayFormat", "{0:F1} kg", "Format string for weight display"); StaminaDrainDisplayFormat = configFile.Bind<string>("Visual/UI", "StaminaDrainDisplayFormat", "-{0:F1}/s", "Format string for stamina drain display"); TotalWeightHudOffsetX = configFile.Bind<float>("Visual/UI", "TotalWeightHudOffsetX", -24f, new ConfigDescription("Total weight HUD text offset X (anchored to right-center; negative moves left)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2000f, 2000f), Array.Empty<object>())); TotalWeightHudOffsetY = configFile.Bind<float>("Visual/UI", "TotalWeightHudOffsetY", -60f, new ConfigDescription("Total weight HUD text offset Y (anchored to right-center; negative moves down)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2000f, 2000f), Array.Empty<object>())); NetworkSyncEnabled = configFile.Bind<bool>("Advanced", "NetworkSyncEnabled", false, "Not implemented yet; currently has no effect (reserved for a future multiplayer sync feature)."); PhysicsModeOnStore = configFile.Bind<string>("Advanced", "PhysicsModeOnStore", "Kinematic", new ConfigDescription("How to handle physics when storing: Kinematic, Disable, or Keep", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Kinematic", "Disable", "Keep" }), Array.Empty<object>())); DropPositionOffset = configFile.Bind<Vector3>("Advanced", "DropPositionOffset", new Vector3(0f, 0.5f, 1f), "Offset from player position when dropping valuable"); DropForce = configFile.Bind<float>("Advanced", "DropForce", 2f, new ConfigDescription("Force applied when dropping valuable", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>())); DropDistance = configFile.Bind<float>("Advanced", "DropDistance", 2f, new ConfigDescription("Distance in front of camera to drop valuable when unequipping", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 100f), Array.Empty<object>())); CooldownAfterDrop = configFile.Bind<float>("Advanced", "CooldownAfterDrop", 1f, new ConfigDescription("Cooldown in seconds before can store again after auto-drop", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>())); ShowRotatingIcon = configFile.Bind<bool>("Advanced", "ShowRotatingIcon", true, "Rotate the 3D model in inventory slot for better visibility"); DebugLogging = configFile.Bind<bool>("Advanced", "DebugLogging", false, "Enable debug logging for troubleshooting"); } } internal static class ExtractionHaulSync { internal static void RemoveFromHaulList(ValuableObject valuable, string context) { if ((Object)(object)valuable == (Object)null) { return; } try { if (SemiFunc.IsMasterClientOrSingleplayer()) { RoundDirector instance = RoundDirector.instance; if (instance?.dollarHaulList != null && instance.dollarHaulList.Contains(((Component)valuable).gameObject)) { instance.dollarHaulList.Remove(((Component)valuable).gameObject); StoreValuables.Logger.LogDebug((object)("[" + context + "] Removed '" + ((Object)((Component)valuable).gameObject).name + "' from RoundDirector.dollarHaulList")); } } } catch (Exception ex) { StoreValuables.Logger.LogDebug((object)("[" + context + "] RemoveFromHaulList failed: " + ex.Message)); } } internal static void RefreshRoomVolumesAndSyncHaulList(ValuableObject valuable, string context) { if ((Object)(object)valuable == (Object)null) { return; } try { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } RoomVolumeCheck component = ((Component)valuable).GetComponent<RoomVolumeCheck>(); if ((Object)(object)component != (Object)null) { component.CheckSet(); } bool flag = false; if ((Object)(object)component != (Object)null && component.CurrentRooms != null) { foreach (RoomVolume currentRoom in component.CurrentRooms) { if ((Object)(object)currentRoom != (Object)null && currentRoom.Extraction) { flag = true; break; } } } RoundDirector instance = RoundDirector.instance; if (instance?.dollarHaulList != null) { bool flag2 = instance.dollarHaulList.Contains(((Component)valuable).gameObject); if (flag && !flag2) { instance.dollarHaulList.Add(((Component)valuable).gameObject); StoreValuables.Logger.LogDebug((object)("[" + context + "] Added '" + ((Object)((Component)valuable).gameObject).name + "' to RoundDirector.dollarHaulList (now in extraction)")); } else if (!flag && flag2) { instance.dollarHaulList.Remove(((Component)valuable).gameObject); StoreValuables.Logger.LogDebug((object)("[" + context + "] Removed '" + ((Object)((Component)valuable).gameObject).name + "' from RoundDirector.dollarHaulList (not in extraction)")); } } } catch (Exception ex) { StoreValuables.Logger.LogDebug((object)("[" + context + "] RefreshRoomVolumesAndSyncHaulList failed: " + ex.Message)); } } } public class ItemPreviewer : MonoBehaviour { [CompilerGenerated] private sealed class <DisableIconsAfterFrame>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ItemPreviewer <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DisableIconsAfterFrame>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; ItemPreviewer itemPreviewer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (!itemPreviewer._previewActive) { return false; } <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: { <>1__state = -1; Image[] componentsInChildren = ((Component)itemPreviewer).GetComponentsInChildren<Image>(true); foreach (Image val in componentsInChildren) { if (!itemPreviewer._previewActive) { return false; } if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && (!((Object)(object)itemPreviewer.uiDisplay != (Object)null) || !((Object)(object)((Component)val).gameObject == (Object)(object)((Component)itemPreviewer.uiDisplay).gameObject)) && (((Object)((Component)val).gameObject).name == "Icon" || ((Object)((Component)val).gameObject).name.Contains("Icon"))) { itemPreviewer.TrackAndDisableIcon(val); } } SpriteRenderer[] componentsInChildren2 = ((Component)itemPreviewer).GetComponentsInChildren<SpriteRenderer>(true); if (componentsInChildren2.Length != 0) { SpriteRenderer[] array = componentsInChildren2; foreach (SpriteRenderer val2 in array) { if (!itemPreviewer._previewActive) { return false; } if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null) && (((Object)((Component)val2).gameObject).name == "Icon" || ((Object)((Component)val2).gameObject).name.Contains("Icon"))) { itemPreviewer.TrackAndDisableIcon(val2); } } } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RenderAfterFrame>d__22 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ItemPreviewer <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RenderAfterFrame>d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; ItemPreviewer itemPreviewer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)itemPreviewer.previewCamera != (Object)null && (Object)(object)itemPreviewer.renderTexture != (Object)null && (Object)(object)itemPreviewer.uiDisplay != (Object)null) { ((Component)itemPreviewer.previewCamera).transform.LookAt(itemPreviewer._currentLookTargetWorld); if (!itemPreviewer.renderTexture.IsCreated()) { itemPreviewer.renderTexture.Create(); } itemPreviewer.previewCamera.targetTexture = itemPreviewer.renderTexture; itemPreviewer.uiDisplay.texture = (Texture)(object)itemPreviewer.renderTexture; ((Graphic)itemPreviewer.uiDisplay).color = Color.white; ((Behaviour)itemPreviewer.uiDisplay).enabled = true; Transform transform = ((Component)itemPreviewer.uiDisplay).transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val != (Object)null) { ((Transform)val).SetAsLastSibling(); } if ((Object)(object)itemPreviewer.currentPreviewObject != (Object)null) { Renderer[] componentsInChildren = itemPreviewer.currentPreviewObject.GetComponentsInChildren<Renderer>(); int num2 = 0; int num3 = 0; uint num4 = 0u; Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { if ((Object)(object)val2 != (Object)null && val2.enabled) { num2++; if (((Component)val2).gameObject.layer == 23) { num3++; } if (val2.renderingLayerMask > num4) { num4 = val2.renderingLayerMask; } } } } _ = ((Behaviour)itemPreviewer.previewCamera).enabled; ((Behaviour)itemPreviewer.previewCamera).enabled = false; bool fog = RenderSettings.fog; Color ambientLight = RenderSettings.ambientLight; float ambientIntensity = RenderSettings.ambientIntensity; RenderSettings.fog = false; RenderSettings.ambientLight = Color.white * 0.5f; RenderSettings.ambientIntensity = Mathf.Max(ambientIntensity, 1f); try { if ((Object)(object)itemPreviewer._previewReflectionProbe != (Object)null) { try { itemPreviewer._previewReflectionProbe.RenderProbe(); } catch (Exception) { } } itemPreviewer.previewCamera.Render(); itemPreviewer.previewCamera.Render(); } finally { RenderSettings.fog = fog; RenderSettings.ambientLight = ambientLight; RenderSettings.ambientIntensity = ambientIntensity; } RenderTexture.active = itemPreviewer.renderTexture; Texture2D val3 = new Texture2D(1, 1); val3.ReadPixels(new Rect(0f, 0f, 1f, 1f), 0, 0); val3.Apply(); val3.GetPixel(0, 0); RenderTexture.active = null; Object.Destroy((Object)val3); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public GameObject? currentPreviewObject; public Camera? previewCamera; public RenderTexture? renderTexture; public RawImage? uiDisplay; public GameObject? previewStage; private ReflectionProbe? _previewReflectionProbe; private bool _previewActive; private float _nextIconRescanTime; private readonly List<(Image img, bool enabled, bool active)> _disabledIconImages = new List<(Image, bool, bool)>(); private readonly List<(SpriteRenderer sr, bool enabled, bool active)> _disabledIconSpriteRenderers = new List<(SpriteRenderer, bool, bool)>(); private Vector3 _currentLookTargetWorld; private int _previewStageSlotIndex = -1; private void Awake() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Expected O, but got Unknown //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) StoreValuables.Logger.LogDebug((object)("[ItemPreviewer] Awake called for " + ((Object)((Component)this).gameObject).name)); _previewStageSlotIndex = TryGetInventorySlotIndex(); float num = ((_previewStageSlotIndex >= 0) ? ((float)(_previewStageSlotIndex + 1) * 100f) : 100f); float num2 = (float)Mathf.Abs(((Object)this).GetInstanceID() % 10) * 2f; previewStage = new GameObject($"PreviewStage_{((Object)this).GetInstanceID()}"); previewStage.transform.position = new Vector3(0f, -10000f - num - num2, 0f); ((Object)previewStage).hideFlags = (HideFlags)61; SetupReflectionProbe(); GameObject val = new GameObject("PreviewLight"); val.transform.SetParent(previewStage.transform); val.transform.localPosition = new Vector3(0f, 0f, 0f); ((Object)val).hideFlags = (HideFlags)61; Light val2 = val.AddComponent<Light>(); val2.type = (LightType)2; val2.range = 10f; val2.intensity = 4f; val2.cullingMask = 8388608; ConfigureHDRPLight(val2); GameObject val3 = new GameObject("PreviewCam"); val3.transform.SetParent(previewStage.transform); val3.transform.localPosition = new Vector3(0f, 0f, -1.5f); ((Object)val3).hideFlags = (HideFlags)61; previewCamera = val3.AddComponent<Camera>(); previewCamera.clearFlags = (CameraClearFlags)2; previewCamera.backgroundColor = new Color(0.15f, 0.15f, 0.15f, 1f); previewCamera.cullingMask = 8388608; ((Behaviour)previewCamera).enabled = false; previewCamera.orthographic = false; previewCamera.fieldOfView = 30f; previewCamera.nearClipPlane = 0.1f; previewCamera.farClipPlane = 10f; ConfigureHDRPCamera(previewCamera); if ((Object)(object)renderTexture == (Object)null) { renderTexture = new RenderTexture(256, 256, 16, (RenderTextureFormat)0); ((Object)renderTexture).name = $"PreviewRT_{((Object)this).GetInstanceID()}"; renderTexture.Create(); } previewCamera.targetTexture = renderTexture; Transform val4 = ((Component)this).transform.Find("ModItemPreview"); RectTransform val5 = null; int layer = ((Component)this).gameObject.layer; try { Image val6 = ((IEnumerable<Image>)((Component)this).GetComponentsInChildren<Image>(true)).FirstOrDefault((Func<Image, bool>)((Image i) => (Object)(object)i != (Object)null && (Object)(object)((Component)i).gameObject != (Object)null && (((Object)((Component)i).gameObject).name == "Icon" || ((Object)((Component)i).gameObject).name.Contains("Icon")))); val5 = (RectTransform)(((Object)(object)val6 != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val6 != (Object)null && (Object)(object)((Component)val6).gameObject != (Object)null) { layer = ((Component)val6).gameObject.layer; } } catch { val5 = null; } GameObject val7; if ((Object)(object)val4 != (Object)null) { StoreValuables.Logger.LogDebug((object)"[ItemPreviewer] Found existing ModItemPreview, reusing it"); val7 = ((Component)val4).gameObject; uiDisplay = val7.GetComponent<RawImage>(); if ((Object)(object)uiDisplay == (Object)null) { uiDisplay = val7.AddComponent<RawImage>(); } } else { Transform val8 = (((Object)(object)val5 != (Object)null && (Object)(object)((Component)val5).transform.parent != (Object)null) ? ((Component)val5).transform.parent : ((Component)this).transform); val7 = new GameObject("ModItemPreview", new Type[1] { typeof(RectTransform) }); val7.transform.SetParent(val8, false); val7.AddComponent<LayoutElement>().ignoreLayout = true; uiDisplay = val7.AddComponent<RawImage>(); } try { val7.layer = layer; if ((Object)(object)uiDisplay != (Object)null) { ((Component)uiDisplay).gameObject.layer = layer; } } catch { } if ((Object)(object)uiDisplay != (Object)null) { Transform transform = ((Component)uiDisplay).transform; RectTransform val9 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val9 != (Object)null) { if ((Object)(object)val5 != (Object)null) { val9.anchorMin = val5.anchorMin; val9.anchorMax = val5.anchorMax; val9.pivot = val5.pivot; val9.anchoredPosition3D = val5.anchoredPosition3D; val9.sizeDelta = val5.sizeDelta; ((Transform)val9).localRotation = ((Transform)val5).localRotation; ((Transform)val9).localScale = ((Transform)val5).localScale; val9.offsetMin = val5.offsetMin; val9.offsetMax = val5.offsetMax; } else { val9.anchorMin = Vector2.zero; val9.anchorMax = Vector2.one; val9.pivot = new Vector2(0.5f, 0.5f); val9.anchoredPosition = Vector2.zero; val9.sizeDelta = Vector2.zero; ((Transform)val9).localScale = Vector3.one; } ((Transform)val9).SetAsLastSibling(); } } Canvas val10 = val7.GetComponent<Canvas>(); if ((Object)(object)val10 == (Object)null) { val10 = val7.AddComponent<Canvas>(); } Canvas val11 = null; if ((Object)(object)val7.transform.parent != (Object)null) { val11 = ((Component)val7.transform.parent).GetComponentInParent<Canvas>(); } val10.overrideSorting = true; if ((Object)(object)val11 != (Object)null && (Object)(object)val11 != (Object)(object)val10) { val10.renderMode = val11.renderMode; val10.worldCamera = val11.worldCamera; val10.planeDistance = val11.planeDistance; val10.sortingLayerID = val11.sortingLayerID; val10.sortingOrder = val11.sortingOrder + 1; } else { val10.sortingOrder = 5000; } if ((Object)(object)val7.GetComponent<GraphicRaycaster>() == (Object)null) { val7.AddComponent<GraphicRaycaster>(); } if ((Object)(object)uiDisplay != (Object)null && (Object)(object)renderTexture != (Object)null) { uiDisplay.texture = (Texture)(object)renderTexture; ((Graphic)uiDisplay).raycastTarget = false; ((Behaviour)uiDisplay).enabled = false; ((Graphic)uiDisplay).color = Color.white; StoreValuables.Logger.LogDebug((object)"[ItemPreviewer] Awake: Assigned renderTexture to RawImage"); } else { StoreValuables.Logger.LogError((object)$"[ItemPreviewer] Failed to setup uiDisplay or renderTexture is null. uiDisplay: {(Object)(object)uiDisplay != (Object)null}, renderTexture: {(Object)(object)renderTexture != (Object)null}"); } } public void SetItem(GameObject? itemPrefab) { //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) StoreValuables.Logger.LogDebug((object)("[ItemPreviewer] SetItem called with " + (((Object)(object)itemPrefab != (Object)null) ? ((Object)itemPrefab).name : "null"))); if ((Object)(object)itemPrefab == (Object)null) { _previewActive = false; RestoreDisabledIcons(); _nextIconRescanTime = 0f; } if ((Object)(object)currentPreviewObject != (Object)null) { Object.Destroy((Object)(object)currentPreviewObject); currentPreviewObject = null; } if ((Object)(object)itemPrefab == (Object)null || (Object)(object)renderTexture == (Object)null || (Object)(object)uiDisplay == (Object)null || (Object)(object)previewCamera == (Object)null) { if ((Object)(object)uiDisplay != (Object)null) { ((Behaviour)uiDisplay).enabled = false; } if ((Object)(object)previewCamera != (Object)null) { ((Behaviour)previewCamera).enabled = false; } return; } _previewActive = true; ((MonoBehaviour)this).StartCoroutine(DisableIconsAfterFrame()); ((Behaviour)uiDisplay).enabled = true; currentPreviewObject = Object.Instantiate<GameObject>(itemPrefab, previewStage.transform); currentPreviewObject.transform.localPosition = Vector3.zero; currentPreviewObject.transform.localRotation = Quaternion.identity; ((Object)currentPreviewObject).name = "Preview_" + ((Object)itemPrefab).name; List<Component> list = new List<Component>(); MonoBehaviour[] componentsInChildren = currentPreviewObject.GetComponentsInChildren<MonoBehaviour>(); foreach (MonoBehaviour val in componentsInChildren) { if (!(val is ItemPreviewer)) { list.Add((Component)(object)val); } } foreach (Component item in list) { Object.Destroy((Object)(object)item); } Rigidbody[] componentsInChildren2 = currentPreviewObject.GetComponentsInChildren<Rigidbody>(); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } Collider[] componentsInChildren3 = currentPreviewObject.GetComponentsInChildren<Collider>(); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.Destroy((Object)(object)componentsInChildren3[i]); } LODGroup[] componentsInChildren4 = currentPreviewObject.GetComponentsInChildren<LODGroup>(true); foreach (LODGroup val2 in componentsInChildren4) { if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } } SetupRenderersForPreview(currentPreviewObject); currentPreviewObject.SetActive(true); Bounds meshBounds = default(Bounds); ((Bounds)(ref meshBounds))..ctor(Vector3.zero, Vector3.zero); bool flag = false; int num = 0; int num2 = 0; Renderer[] componentsInChildren5 = currentPreviewObject.GetComponentsInChildren<Renderer>(true); Vector3 size; foreach (Renderer val3 in componentsInChildren5) { if ((Object)(object)val3 == (Object)null) { continue; } num++; if (val3 is ParticleSystemRenderer || !val3.enabled) { continue; } try { if (val3.sharedMaterials == null || val3.sharedMaterials.Length == 0) { continue; } goto IL_02d1; } catch { } continue; IL_02d1: Bounds val4 = RendererLocalBoundsToRootLocalBounds(currentPreviewObject.transform, val3); size = ((Bounds)(ref val4)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f)) { if (!flag) { meshBounds = val4; flag = true; } else { ((Bounds)(ref meshBounds)).Encapsulate(val4); } num2++; } } if (flag) { size = ((Bounds)(ref meshBounds)).size; if (!(((Vector3)(ref size)).magnitude < 0.001f)) { float num3 = Mathf.Max(new float[3] { ((Bounds)(ref meshBounds)).size.x, ((Bounds)(ref meshBounds)).size.y, ((Bounds)(ref meshBounds)).size.z }); if (num3 < 0.01f) { num3 = 1f; StoreValuables.Logger.LogWarning((object)"[ItemPreviewer] Bounds too small, using fallback maxDim 1.0"); } float num4 = 0.8f / num3; currentPreviewObject.transform.localScale = Vector3.one * num4; StoreValuables.Logger.LogInfo((object)$"[ItemPreviewer] Scaled {((Object)itemPrefab).name} by {num4} (maxDim: {num3})"); currentPreviewObject.transform.localPosition = -(((Bounds)(ref meshBounds)).center * num4); PositionCameraForPreview(currentPreviewObject, previewCamera, meshBounds, num4); ((MonoBehaviour)this).StartCoroutine(RenderAfterFrame()); return; } } StoreValuables.Logger.LogError((object)("[ItemPreviewer] Item " + ((Object)itemPrefab).name + " has no valid Renderers or bounds!")); ((Behaviour)uiDisplay).enabled = false; ((Behaviour)previewCamera).enabled = false; } [IteratorStateMachine(typeof(<DisableIconsAfterFrame>d__14))] private IEnumerator DisableIconsAfterFrame() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DisableIconsAfterFrame>d__14(0) { <>4__this = this }; } private int TryGetInventorySlotIndex() { try { InventorySpot component = ((Component)this).GetComponent<InventorySpot>(); if ((Object)(object)component != (Object)null) { return component.inventorySpotIndex; } } catch { } return -1; } private bool IsTracked(Image img) { for (int i = 0; i < _disabledIconImages.Count; i++) { if ((Object)(object)_disabledIconImages[i].img == (Object)(object)img) { return true; } } return false; } private bool IsTracked(SpriteRenderer sr) { for (int i = 0; i < _disabledIconSpriteRenderers.Count; i++) { if ((Object)(object)_disabledIconSpriteRenderers[i].sr == (Object)(object)sr) { return true; } } return false; } private void TrackAndDisableIcon(Image img) { if (!((Object)(object)img == (Object)null) && !((Object)(object)((Component)img).gameObject == (Object)null) && (!((Object)(object)uiDisplay != (Object)null) || !((Object)(object)((Component)img).gameObject == (Object)(object)((Component)uiDisplay).gameObject))) { if (!IsTracked(img)) { _disabledIconImages.Add((img, ((Behaviour)img).enabled, ((Component)img).gameObject.activeSelf)); } ((Behaviour)img).enabled = false; ((Component)img).gameObject.SetActive(false); } } private void TrackAndDisableIcon(SpriteRenderer sr) { if (!((Object)(object)sr == (Object)null) && !((Object)(object)((Component)sr).gameObject == (Object)null)) { if (!IsTracked(sr)) { _disabledIconSpriteRenderers.Add((sr, ((Renderer)sr).enabled, ((Component)sr).gameObject.activeSelf)); } ((Renderer)sr).enabled = false; ((Component)sr).gameObject.SetActive(false); } } private void ReDisableTrackedIconsIfNeeded() { for (int i = 0; i < _disabledIconImages.Count; i++) { Image item = _disabledIconImages[i].img; if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).gameObject == (Object)null) && (((Behaviour)item).enabled || ((Component)item).gameObject.activeSelf)) { ((Behaviour)item).enabled = false; ((Component)item).gameObject.SetActive(false); } } for (int j = 0; j < _disabledIconSpriteRenderers.Count; j++) { SpriteRenderer item2 = _disabledIconSpriteRenderers[j].sr; if (!((Object)(object)item2 == (Object)null) && !((Object)(object)((Component)item2).gameObject == (Object)null) && (((Renderer)item2).enabled || ((Component)item2).gameObject.activeSelf)) { ((Renderer)item2).enabled = false; ((Component)item2).gameObject.SetActive(false); } } } private void RestoreDisabledIcons() { for (int i = 0; i < _disabledIconImages.Count; i++) { var (val, enabled, active) = _disabledIconImages[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null)) { try { ((Component)val).gameObject.SetActive(active); ((Behaviour)val).enabled = enabled; } catch { } } } _disabledIconImages.Clear(); for (int j = 0; j < _disabledIconSpriteRenderers.Count; j++) { var (val2, enabled2, active2) = _disabledIconSpriteRenderers[j]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null)) { try { ((Component)val2).gameObject.SetActive(active2); ((Renderer)val2).enabled = enabled2; } catch { } } } _disabledIconSpriteRenderers.Clear(); } [IteratorStateMachine(typeof(<RenderAfterFrame>d__22))] private IEnumerator RenderAfterFrame() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RenderAfterFrame>d__22(0) { <>4__this = this }; } private void PositionCameraForPreview(GameObject previewObj, Camera? cam, Bounds meshBounds, float appliedScale) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_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) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)previewObj == (Object)null || (Object)(object)cam == (Object)null) { return; } Vector3 val = (_currentLookTargetWorld = previewObj.transform.TransformPoint(((Bounds)(ref meshBounds)).center)); Vector3 val2 = ((Bounds)(ref meshBounds)).size; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { ((Bounds)(ref meshBounds))..ctor(Vector3.zero, Vector3.one); } Vector3 val3 = ((Bounds)(ref meshBounds)).extents * Mathf.Max(appliedScale, 0.0001f); cam.fieldOfView = 40f; float num = cam.fieldOfView * (MathF.PI / 180f) * 0.5f; float num2 = Mathf.Atan(Mathf.Tan(num) * cam.aspect); float num3 = Mathf.Max(Mathf.Tan(num), 0.0001f); float num4 = Mathf.Max(Mathf.Tan(num2), 0.0001f); float num5 = val3.y / (num3 * 0.85f); float num6 = val3.x / (num4 * 0.85f); float num7 = Mathf.Max(val3.z, 0.05f); float num8 = Mathf.Max(num5, num6) + num7; num8 = Mathf.Clamp(num8, 0.6f, 6f); val2 = new Vector3(0.5f, 0.5f, -1.5f); Vector3 normalized = ((Vector3)(ref val2)).normalized; ((Component)cam).transform.localPosition = normalized * num8; ((Component)cam).transform.LookAt(val); cam.nearClipPlane = 0.01f; cam.farClipPlane = Mathf.Max(10f, num8 + 10f); Renderer[] componentsInChildren = previewObj.GetComponentsInChildren<Renderer>(); int num9 = 0; int num10 = 0; Renderer[] array = componentsInChildren; foreach (Renderer val4 in array) { if ((Object)(object)val4 != (Object)null && val4.enabled) { num9++; if (((Component)val4).gameObject.layer == 23) { num10++; } } } Vector3 val5 = val; StoreValuables.Logger.LogDebug((object)$"[ItemPreviewer] Camera positioned at local {((Component)cam).transform.localPosition}, looking at world {val5}, FOV: {cam.fieldOfView}"); } private static Bounds WorldBoundsToLocalBounds(Transform root, Bounds worldBounds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Bounds)(ref worldBounds)).center; Vector3 extents = ((Bounds)(ref worldBounds)).extents; Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(center.x - extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z + extents.z) }; Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(root.InverseTransformPoint(array[0]), Vector3.zero); for (int i = 1; i < array.Length; i++) { ((Bounds)(ref result)).Encapsulate(root.InverseTransformPoint(array[i])); } return result; } private static Bounds RendererLocalBoundsToRootLocalBounds(Transform root, Renderer renderer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c3: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_0202: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) Bounds localBounds = default(Bounds); try { localBounds = renderer.localBounds; } catch { ((Bounds)(ref localBounds))..ctor(Vector3.zero, Vector3.zero); } Vector3 size = ((Bounds)(ref localBounds)).size; if (((Vector3)(ref size)).sqrMagnitude < 1E-06f) { try { return WorldBoundsToLocalBounds(root, renderer.bounds); } catch { return new Bounds(Vector3.zero, Vector3.zero); } } Vector3 center = ((Bounds)(ref localBounds)).center; Vector3 extents = ((Bounds)(ref localBounds)).extents; Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(center.x - extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x - extents.x, center.y + extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y - extents.y, center.z + extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z - extents.z), new Vector3(center.x + extents.x, center.y + extents.y, center.z + extents.z) }; Vector3 val = root.InverseTransformPoint(((Component)renderer).transform.TransformPoint(array[0])); Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(val, Vector3.zero); for (int i = 1; i < array.Length; i++) { Vector3 val2 = root.InverseTransformPoint(((Component)renderer).transform.TransformPoint(array[i])); ((Bounds)(ref result)).Encapsulate(val2); } return result; } private void SetupReflectionProbe() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) if (!((Object)(object)previewStage == (Object)null) && !((Object)(object)_previewReflectionProbe != (Object)null)) { GameObject val = new GameObject("PreviewReflectionProbe"); val.transform.SetParent(previewStage.transform, false); val.transform.localPosition = Vector3.zero; ((Object)val).hideFlags = (HideFlags)61; val.layer = 23; ReflectionProbe val2 = val.AddComponent<ReflectionProbe>(); val2.mode = (ReflectionProbeMode)1; val2.refreshMode = (ReflectionProbeRefreshMode)2; val2.timeSlicingMode = (ReflectionProbeTimeSlicingMode)2; val2.intensity = 1f; val2.boxProjection = true; val2.size = new Vector3(10f, 10f, 10f); val2.cullingMask = 8388608; val2.clearFlags = (ReflectionProbeClearFlags)2; val2.backgroundColor = new Color(0.2f, 0.2f, 0.2f, 1f); _previewReflectionProbe = val2; } } private void Update() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)currentPreviewObject != (Object)null && Config.ShowRotatingIcon.Value) { currentPreviewObject.transform.Rotate(Vector3.up * 45f * Time.deltaTime); } if (!_previewActive || !((Object)(object)currentPreviewObject != (Object)null)) { return; } ReDisableTrackedIconsIfNeeded(); if (_disabledIconImages.Count != 0 || _disabledIconSpriteRenderers.Count != 0) { return; } float unscaledTime = Time.unscaledTime; if (!(_nextIconRescanTime <= 0f) && !(unscaledTime >= _nextIconRescanTime)) { return; } _nextIconRescanTime = unscaledTime + 1f; try { Image[] componentsInChildren = ((Component)this).GetComponentsInChildren<Image>(true); foreach (Image val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && (!((Object)(object)uiDisplay != (Object)null) || !((Object)(object)((Component)val).gameObject == (Object)(object)((Component)uiDisplay).gameObject)) && (((Object)((Component)val).gameObject).name == "Icon" || ((Object)((Component)val).gameObject).name.Contains("Icon"))) { TrackAndDisableIcon(val); } } SpriteRenderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null) && (((Object)((Component)val2).gameObject).name == "Icon" || ((Object)((Component)val2).gameObject).name.Contains("Icon"))) { TrackAndDisableIcon(val2); } } } catch { } } private void OnDestroy() { StoreValuables.Logger.LogDebug((object)"[ItemPreviewer] OnDestroy called, cleaning up"); RestoreDisabledIcons(); _previewActive = false; if ((Object)(object)currentPreviewObject != (Object)null) { Object.Destroy((Object)(object)currentPreviewObject); } if ((Object)(object)renderTexture != (Object)null) { renderTexture.Release(); Object.Destroy((Object)(object)renderTexture); } if ((Object)(object)previewStage != (Object)null) { Object.Destroy((Object)(object)previewStage); } } private void SetupRenderersForPreview(GameObject obj) { SetupRenderersRecursive(obj.transform, 23); } private void SetupRenderersRecursive(Transform t, int layer) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown ((Component)t).gameObject.layer = layer; Renderer component = ((Component)t).GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.renderingLayerMask = uint.MaxValue; component.enabled = true; component.shadowCastingMode = (ShadowCastingMode)1; } foreach (Transform item in t) { Transform t2 = item; SetupRenderersRecursive(t2, layer); } } private void SetLayerRecursively(GameObject obj, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown obj.layer = layer; foreach (Transform item in obj.transform) { Transform val = item; SetLayerRecursively(((Component)val).gameObject, layer); } } private Type? GetHDRPType(string typeName) { string text = "UnityEngine.Rendering.HighDefinition." + typeName; string[] array = new string[4] { "Unity.RenderPipelines.HighDefinition.Runtime", "Unity.RenderPipelines.HighDefinition.Runtime.dll", "UnityEngine.Rendering.HighDefinition", "HighDefinition.Runtime" }; foreach (string text2 in array) { try { Type type = Type.GetType(text + ", " + text2); if (type != null) { return type; } } catch { } } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { string text3 = assembly.GetName().Name ?? "Unknown"; Type type2 = assembly.GetType(text); if (type2 != null) { return type2; } if (!text3.Contains("Render") && !text3.Contains("HighDefinition") && !text3.Contains("HDRP") && !text3.Contains("Rendering") && !text3.Contains("Unity")) { continue; } try { Type[] types = assembly.GetTypes(); foreach (Type type3 in types) { if (type3.Name == typeName && type3.Namespace != null && type3.Namespace.Contains("HighDefinition")) { return type3; } } } catch (Exception) { } } catch { } } try { Camera main = Camera.main; if ((Object)(object)main != (Object)null) { Component[] components = ((Component)main).GetComponents<Component>(); foreach (Component val in components) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == typeName) { return ((object)val).GetType(); } } } } catch { } return null; } private void ConfigureHDRPCamera(Camera cam) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { return; } try { Component component = ((Component)cam).GetComponent("HDAdditionalCameraData"); if ((Object)(object)component == (Object)null) { return; } Type type = ((object)component).GetType(); PropertyInfo property = type.GetProperty("volumeLayerMask"); if (property != null && property.CanWrite) { LayerMask val = LayerMask.op_Implicit(0); property.SetValue(component, val, null); } PropertyInfo property2 = type.GetProperty("clearColorMode"); if (property2 != null && property2.CanWrite) { Type propertyType = property2.PropertyType; if (propertyType != null && propertyType.IsEnum) { foreach (object value in Enum.GetValues(propertyType)) { if (value != null && value.ToString() == "Color") { property2.SetValue(component, value, null); break; } } } } PropertyInfo property3 = type.GetProperty("backgroundColorHDR"); if (property3 != null && property3.CanWrite) { Color val2 = default(Color); ((Color)(ref val2))..ctor(0.15f, 0.15f, 0.15f, 1f); property3.SetValue(component, val2, null); } } catch (Exception ex) { StoreValuables.Logger.LogWarning((object)("[ItemPreviewer] HDRP camera configuration failed: " + ex.Message)); } } private bool ConfigureHDRPLight(Light light) { if ((Object)(object)light == (Object)null) { return false; } try { Type hDRPType = GetHDRPType("HDAdditionalLightData"); if (hDRPType == null) { return false; } Component val = ((Component)light).GetComponent(hDRPType); if ((Object)(object)val == (Object)null) { val = ((Component)light).gameObject.AddComponent(hDRPType); } PropertyInfo property = hDRPType.GetProperty("lightUnit"); if (property != null && property.CanWrite) { Type propertyType = property.PropertyType; if (propertyType != null && propertyType.IsEnum) { foreach (object value in Enum.GetValues(propertyType)) { if (value != null && value.ToString() == "Lumens") { property.SetValue(val, value); break; } } } } PropertyInfo property2 = hDRPType.GetProperty("affectDiffuse"); if (property2 != null && property2.CanWrite) { property2.SetValue(val, true); } PropertyInfo property3 = hDRPType.GetProperty("affectSpecular"); if (property3 != null && property3.CanWrite) { property3.SetValue(val, true); } PropertyInfo property4 = hDRPType.GetProperty("shadowResolution"); if (property4 != null && property4.CanWrite) { Type propertyType2 = property4.PropertyType; if (propertyType2 != null && propertyType2.IsEnum) { foreach (object value2 in Enum.GetValues(propertyType2)) { if (value2 != null && (value2.ToString() == "None" || value2.ToString() == "ShadowResolution_None")) { property4.SetValue(val, value2); break; } } } } PropertyInfo property5 = hDRPType.GetProperty("lightlayersMask"); if (property5 != null && property5.CanWrite) { property5.SetValue(val, uint.MaxValue); } light.intensity = 2000f; return true; } catch (Exception ex) { StoreValuables.Logger.LogWarning((object)("[ItemPreviewer] HDRP light configuration failed: " + ex.Message)); return false; } } } [BepInPlugin("Tolga.StoreValuables", "StorableValuables", "1.0.4")] public class StoreValuables : BaseUnityPlugin { internal static StoreValuables Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Config.Initialize(((BaseUnityPlugin)this).Config); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0025: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public class ValuableStorageManager { private static ValuableStorageManager? _instance; private readonly Dictionary<int, ValuableObject> _storedValuables = new Dictionary<int, ValuableObject>(); private readonly Dictionary<int, bool> _originalIsKinematic = new Dictionary<int, bool>(); private readonly Dictionary<int, bool> _originalUseGravity = new Dictionary<int, bool>(); public static ValuableStorageManager Instance { get { if (_instance == null) { _instance = new ValuableStorageManager(); } return _instance; } } private void PruneDestroyedEntries() { if (_storedValuables.Count == 0) { return; } List<int> list = null; foreach (KeyValuePair<int, ValuableObject> storedValuable in _storedValuables) { if ((Object)(object)storedValuable.Value == (Object)null) { if (list == null) { list = new List<int>(); } list.Add(storedValuable.Key); } } if (list == null) { return; } foreach (int item in list) { _storedValuables.Remove(item); _originalIsKinematic.Remove(item); _originalUseGravity.Remove(item); } } public bool IsSlotOccupied(int slotIndex) { if (!_storedValuables.TryGetValue(slotIndex, out ValuableObject value)) { return false; } if ((Object)(object)value == (Object)null) { _storedValuables.Remove(slotIndex); _originalIsKinematic.Remove(slotIndex); _originalUseGravity.Remove(slotIndex); return false; } return true; } public ValuableObject? GetStoredValuable(int slotIndex) { if (!_storedValuables.TryGetValue(slotIndex, out ValuableObject value)) { return null; } if ((Object)(object)value == (Object)null) { _storedValuables.Remove(slotIndex); _originalIsKinematic.Remove(slotIndex); _originalUseGravity.Remove(slotIndex); return null; } return value; } public bool StoreValuable(int slotIndex, ValuableObject? valuable) { StoreValuables.Logger.LogDebug((object)$"[ValuableStorageManager] StoreValuable called for slot {slotIndex}"); if ((Object)(object)valuable == (Object)null) { StoreValuables.Logger.LogError((object)"[ValuableStorageManager] Valuable is null!"); return false; } if (!Config.EnableValuableStorage.Value) { StoreValuables.Logger.LogDebug((object)"[ValuableStorageManager] Valuable storage is disabled"); return false; } if (Config.RequireEmptySlot.Value && IsSlotOccupied(slotIndex)) { StoreValuables.Logger.LogWarning((object)$"[ValuableStorageManager] Slot {slotIndex} is already occupied"); return false; } float weightForValuable = GetWeightForValuable(valuable); StoreValuables.Logger.LogDebug((object)$"[ValuableStorageManager] Valuable weight: {weightForValuable}"); if (Config.MaxWeightPerSlot.Value > 0f && weightForValuable > Config.MaxWeightPerSlot.Value) { StoreValuables.Logger.LogWarning((object)$"[ValuableStorageManager] Valuable weight {weightForValuable} exceeds max per slot {Config.MaxWeightPerSlot.Value}"); return false; } float totalWeight = GetTotalWeight(); StoreValuables.Logger.LogDebug((object)$"[ValuableStorageManager] Current total weight: {totalWeight}, new total would be: {totalWeight + weightForValuable}"); if (Config.MaxTotalWeight.Value > 0f && totalWeight + weightForValuable > Config.MaxTotalWeight.Value) { StoreValuables.Logger.LogWarning((object)$"[ValuableStorageManager] Total weight {totalWeight + weightForValuable} would exceed max {Config.MaxTotalWeight.Value}"); return false; } _storedValuables[slotIndex] = valuable; StoreValuables.Logger.LogDebug((object)"[ValuableStorageManager] Valuable added to storage dictionary"); PhysGrabObject physGrabObject = valuable.physGrabObject; if ((Object)(object)physGrabObject != (Object)null && (Object)(object)physGrabObject.rb != (Object)null) { _originalIsKinematic[slotIndex] = physGrabObject.rb.isKinematic; _originalUseGravity[slotIndex] = physGrabObject.rb.useGravity; StoreValuables.Logger.LogDebug((object)$"[ValuableStorageManager] Saved original physics state - isKinematic: {_originalIsKinematic[slotIndex]}, useGravity: {_originalUseGravity[slotIndex]}"); switch (Config.PhysicsModeOnStore.Value.ToLower()) { case "kinematic": physGrabObject.rb.isKinematic = true; physGrabObject.rb.useGravity = false; StoreValuables.Logger.LogDebug((object)"[ValuableStorageManager] Set physics to kinematic"); break; case "disable": physGrabObject.rb.isKinematic = true; physGrabObject.rb.useGravity = false; StoreValuables.Logger.LogDebug((object)"[ValuableStorageManager] Set physics to disabled"); break; case "keep": StoreValuables.Logger.LogDebug((object)"[ValuableStorageManager] Keeping original physics state"); break; default: if (Config.DebugLogging.Value) { StoreValuables.Logger.LogWarning((object)("[ValuableStorageManager] Unknown PhysicsModeOnStore '" + Config.PhysicsModeOnStore.Value + "', defaulting to Keep.")); } break; } } else { StoreValuables.Logger.LogWarning((object)"[ValuableStorageManager] physGrabObject or rb is null!"); } StoreValuables.Logger.LogInfo((object)$"[ValuableStorageManager] Successfully stored valuable in slot {slotIndex}, weight: {weightForValuable}, total weight: {GetTotalWeight()}"); return true; } public bool RemoveValuable(int slotIndex, bool restorePhysics = true) { StoreValuables.Logger.LogDebug((object)$"[ValuableStorageManager] RemoveValuable called for slot {slotIndex}, restorePhysics: {restorePhysics}"); if (!_storedValuables.TryGetValue(slotIndex, out ValuableObject value)) { StoreValuables.Logger.LogWarning((object)$"[ValuableStorageManager] No valuable found in slot {slotIndex}"); return false; } StoreValuables.Logger.LogDebug((object)("[ValuableStorageManager] Found valuable: " + ((Object)((Component)value).gameObject).name)); if (restorePhysics) { PhysGrabObject physGrabObject = value.physGrabObject; if ((Object)(object)physGrabObject != (Object)null && (Object)(object)physGrabObject.rb != (Object)null) { if (_originalIsKinematic.TryGetValue(slotIndex, out var value2)) { physGrabObject.rb.isKinematic = value2; StoreValuables.Logger.LogDebug((object)$"[ValuableStorageManager] Restored isKinematic to: {value2}"); } if (_originalUseGravity.TryGetValue(slotIndex, out var value3)) { physGrabObject.rb.useGravity = value3; StoreValuables.Logger.LogDebug((object)$"[ValuableStorageManager] Restored useGravity to: {value3}"); } } else { StoreValuables.Logger.LogWarning((object)"[ValuableStorageManager] physGrabObject or rb is null, cannot restore physics"); } } _storedValuables.Remove(slotIndex); _originalIsKinematic.Remove(slotIndex); _originalUseGravity.Remove(slotIndex); StoreValuables.Logger.LogInfo((object)$"[ValuableStorageManager] Removed valuable from slot {slotIndex}"); return true; } public float GetTotalWeight() { PruneDestroyedEntries(); float num = 0f; foreach (ValuableObject value in _storedValuables.Values) { num += GetWeightForValuable(value); } return num; } public float GetWeightForSlot(int slotIndex) { if (!_storedValuables.TryGetValue(slotIndex, out ValuableObject value)) { return 0f; } return GetWeightForValuable(value); } private static float GetWeightForValuable(ValuableObject? valuable) { if ((Object)(object)valuable == (Object)null) { return 0f; } try { if ((Object)(object)((Component)valuable).GetComponentInParent<MapObject>() != (Object)null) { return 0f; } } catch { } return valuable.physAttributePreset?.mass ?? 0f; } public Dictionary<int, ValuableObject> GetAllStoredValuables() { PruneDestroyedEntries(); Dictionary<int, ValuableObject> dictionary = new Dictionary<int, ValuableObject>(); foreach (KeyValuePair<int, ValuableObject> storedValuable in _storedValuables) { if (!((Object)(object)storedValuable.Value == (Object)null)) { dictionary[storedValuable.Key] = storedValuable.Value; } } return dictionary; } public void ClearAll() { foreach (int item in new List<int>(_storedValuables.Keys)) { RemoveValuable(item); } } public int GetStoredCount() { return _storedValuables.Count; } } internal static class ModVersion { public const string Version = "1.0.4"; } } namespace StoreValuables.Patches { [HarmonyPatch(typeof(InventorySpot))] internal static class InventorySpotPatch { [CompilerGenerated] private sealed class <DisableIconAfterUpdate>d__17 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public InventorySpot spot; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DisableIconAfterUpdate>d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: { <>1__state = -1; Image[] componentsInChildren = ((Component)spot).GetComponentsInChildren<Image>(true); foreach (Image val in componentsInChildren) { if (((Object)((Component)val).gameObject).name == "Icon" || ((Object)((Component)val).gameObject).name.Contains("Icon")) { _ = ((Behaviour)val).enabled; _ = ((Component)val).gameObject.activeSelf; ((Behaviour)val).enabled = false; ((Component)val).gameObject.SetActive(false); } } SpriteRenderer[] componentsInChildren2 = ((Component)spot).GetComponentsInChildren<SpriteRenderer>(true); foreach (SpriteRenderer val2 in componentsInChildren2) { if (((Object)((Component)val2).gameObject).name == "Icon" || ((Object)((Component)val2).gameObject).name.Contains("Icon")) { _ = ((Renderer)val2).enabled; ((Renderer)val2).enabled = false; ((Component)val2).gameObject.SetActive(false); } } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string OverlayTextObjectName = "StoreValuables_OverlayText"; [HarmonyPrefix] [HarmonyPatch("SetEmoji")] private static bool SetEmoji_Prefix(InventorySpot __instance, Sprite emoji) { if ((Object)(object)ValuableStorageManager.Instance.GetStoredValuable(__instance.inventorySpotIndex) != (Object)null && (Object)(object)__instance.CurrentItem == (Object)null) { if ((Object)(object)__instance.inventoryIcon != (Object)null) { ((Behaviour)__instance.inventoryIcon).enabled = false; if ((Object)(object)((Component)__instance.inventoryIcon).gameObject != (Object)null) { ((Component)__instance.inventoryIcon).gameObject.SetActive(false); } } if ((Object)(object)__instance.noItem != (Object)null) { ((Behaviour)__instance.noItem).enabled = false; } return false; } return true; } [HarmonyPrefix] [HarmonyPatch("HandleInput")] private static bool HandleInput_Prefix(InventorySpot __instance) { StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] HandleInput called for slot {__instance.inventorySpotIndex}"); if (!Config.EnableValuableStorage.Value) { StoreValuables.Logger.LogDebug((object)"[InventorySpotPatch] Valuable storage disabled, continuing with original method"); return true; } if (SemiFunc.RunIsArena()) { StoreValuables.Logger.LogDebug((object)"[InventorySpotPatch] In arena, continuing with original method"); return true; } if ((Object)(object)PlayerController.instance != (Object)null && PlayerController.instance.InputDisableTimer > 0f) { StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] Input disabled (timer: {PlayerController.instance.InputDisableTimer}), continuing with original method"); return true; } bool flag = __instance.IsOccupied(); StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] Slot {__instance.inventorySpotIndex} IsOccupied: {flag}"); if (flag) { ValuableObject storedValuable = ValuableStorageManager.Instance.GetStoredValuable(__instance.inventorySpotIndex); StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] Slot {__instance.inventorySpotIndex} has stored valuable: {(Object)(object)storedValuable != (Object)null}"); if ((Object)(object)storedValuable != (Object)null) { StoreValuables.Logger.LogInfo((object)$"[InventorySpotPatch] Unequipping valuable from slot {__instance.inventorySpotIndex}"); UnequipValuable(__instance.inventorySpotIndex, storedValuable); return false; } StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] Slot {__instance.inventorySpotIndex} occupied by regular item, continuing with original method"); return true; } if ((Object)(object)PhysGrabber.instance != (Object)null) { StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] PhysGrabber.instance exists, grabbed: {PhysGrabber.instance.grabbed}"); if (PhysGrabber.instance.grabbed) { PhysGrabObject grabbedPhysGrabObject = PhysGrabber.instance.grabbedPhysGrabObject; StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] Grabbed object: {(Object)(object)grabbedPhysGrabObject != (Object)null}"); if ((Object)(object)grabbedPhysGrabObject != (Object)null) { ValuableObject component = ((Component)grabbedPhysGrabObject).GetComponent<ValuableObject>(); StoreValuables.Logger.LogDebug((object)$"[InventorySpotPatch] Grabbed object has ValuableObject: {(Object)(object)component != (Object)null}"); if ((Object)(object)component != (Object)null) { StoreValuables.Logger.LogInfo((object)$"[InventorySpotPatch] Attempting to store valuable in slot {__instance.inventorySpotIndex}"); if (StoreValuable(__instance.inventorySpotIndex, component)) { StoreValuables.Logger.LogInfo((object)"[InventorySpotPatch] Successfully stored valuable, releasing grab"); PhysGrabber.instance.ReleaseObject(-1, 0.1f); return false; } StoreValuables.Logger.LogWarning((object)$"[InventorySpotPatch] Failed to store valuable in slot {__instance.inventorySpotIndex}"); } } } } else { StoreValuables.Logger.LogDebug((object)"[InventorySpotPatch] PhysGrabber.instance is null"); } StoreValuables.Logger.LogDebug((object)"[InventorySpotPatch] No valuable to store, continuing with original method"); return true; } private static bool StoreValuable(int slotIndex, ValuableObject valuable) { StoreValuables.Logger.LogDebug((object)$"[StoreValuable] Starting storage process for slot {slotIndex}"); if ((Object)(object)valuable == (Object)null) { StoreValuables.Logger.LogError((object)"[StoreValuable] Valuable is null!"); return false; } StoreValuables.Logger.LogDebug((object)$"[StoreValuable] Valuable name: {((Object)((Component)valuable).gameObject).name}, value: {valuable.dollarValueCurrent}"); if (ValuableStorageManager.Instance.StoreValuable(slotIndex, valuable)) { StoreValuables.Logger.LogInfo((object)$"[StoreValuable] Successfully stored valuable in slot {slotIndex}, hiding GameObject"); ExtractionHaulSync.RemoveFromHaulList(valuable, "StoreValuable"); ((Component)valuable).gameObject.SetActive(false); StoreValuables.Logger.LogDebug((object)"[StoreValuable] GameObject.SetActive(false) called"); Inventory instance = Inventory.instance; InventorySpot val = ((instance != null) ? instance.GetSpotByIndex(slotIndex) : null); if ((Object)(object)val != (Object)null) { StoreValuables.Logger.LogDebug((object)$"[StoreValuable] Updating inventory UI for slot {slotIndex}"); val.UpdateUI(); } else { StoreValuables.Logger.LogWarning((object)"[StoreValuable] Inventory.instance or GetSpotByIndex returned null"); } return true; } StoreValuables.Logger.LogWarning((object)"[StoreValuable] ValuableStorageManager.StoreValuable returned false"); return false; } private static void UnequipValuable(int slotIndex, ValuableObject valuable) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: 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_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result t