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 IKEASimulator v1.0.1
IKEASimulator.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("Ticxo")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Let's you sell everything")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("IKEASimulator")] [assembly: AssemblyTitle("IKEASimulator")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] 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; } } } namespace IKEASimulator { [BepInPlugin("Ticxo.IKEASimualtor", "IKEASimulator", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class IKEASimulator : BaseUnityPlugin { private static readonly string BundleName = GetModName(); public static bool PrintDebug = false; public static int ToSpawn = 0; public static int Spawned = 0; public static List<Action> SpawnActions = new List<Action>(); private AssetBundle? assetBundle; private Dictionary<string, GameObject> prefabs = new Dictionary<string, GameObject>(); private NetworkManager networkManager = null; private static IKEASimulator Instance { get; set; } = null; public static ManualLogSource Logger => Instance.logger; public static Dictionary<string, GameObject> Prefabs => Instance.prefabs; public static NetworkManager NetworkManager => Instance.networkManager; public static ConfigEntry<bool> BreakableFurniture { get; private set; } = null; public static ConfigEntry<int> MinValue { get; private set; } = null; public static ConfigEntry<int> MaxValue { get; private set; } = null; public static ConfigEntry<int> FurnitureLimit { get; private set; } = null; private ManualLogSource logger => ((BaseUnityPlugin)this).Logger; private Harmony? Harmony { get; set; } public static GameObject? InstantiateLocal(string assetKey, Transform parent) { return Object.Instantiate<GameObject>(Prefabs[assetKey.ToLower()], parent); } public static GameObject? Instantiate(string assetKey) { //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) return Instantiate(assetKey, Vector3.zero, Quaternion.identity); } public static GameObject? Instantiate(string assetKey, Vector3 position, Quaternion rotation) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return NetworkPrefabs.SpawnNetworkPrefab(assetKey.ToLower(), position, rotation, (byte)0, (object[])null); } private static string GetModName() { object obj = typeof(IKEASimulator).GetCustomAttributes(typeof(BepInPlugin), inherit: false)[0]; BepInPlugin val = (BepInPlugin)((obj is BepInPlugin) ? obj : null); return ((val != null) ? val.Name : null) ?? "IKEASimulator"; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Logger.LogInfo((object)"Initializing IKEASimulator Mod"); Configure(); Patch(); LoadAssetBundle(); LoadResourcesFromBundle(); Logger.LogInfo((object)"IKEASimulator Mod Loaded"); } private void Start() { GameObject val = InstantiateLocal("Managers/IKEASimulatorManager", ((Component)this).gameObject.transform); if (val != null) { networkManager = val.GetComponent<NetworkManager>(); val.transform.parent = null; ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); Logger.LogInfo((object)"IKEASimulatorManager instantiated"); } } private void Configure() { BreakableFurniture = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "BreakableFurniture", true, "If true, furniture will be breakable"); MinValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MinValue", 300, "Min value of furniture"); MaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxValue", 450, "Max value of furniture"); FurnitureLimit = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FurnitureLimit", -1, "Max amount of furniture that can be converted. -1 for no limit."); } private void LoadAssetBundle() { if ((Object)(object)assetBundle != (Object)null) { return; } string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); if (directoryName != null) { string text = Path.Combine(directoryName, BundleName + ".bundle"); assetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)assetBundle == (Object)null) { Logger.LogError((object)("Failed to load bundle from " + text)); } } } private void LoadResourcesFromBundle() { if ((Object)(object)assetBundle == (Object)null) { return; } string[] allAssetNames = assetBundle.GetAllAssetNames(); foreach (string text in allAssetNames) { bool flag = text.EndsWith(".prefab"); bool flag2 = text.EndsWith(".asset"); if (flag && text.Contains("/assets/")) { string text2 = text.Split("/assets/")[1].Replace(".prefab", ""); GameObject val = assetBundle.LoadAsset<GameObject>(text); if ((Object)(object)val != (Object)null) { NetworkPrefabs.RegisterNetworkPrefab(text2, val); prefabs[text2] = val; } } else if (flag && text.Contains("/valuables/")) { Valuables.RegisterValuable(assetBundle.LoadAsset<GameObject>(text)); } else if (flag2 && text.Contains("/items/")) { Items.RegisterItem(assetBundle.LoadAsset<Item>(text)); } else if (flag && text.Contains("/enemies/")) { GameObject val2 = assetBundle.LoadAsset<GameObject>(text); EnemySetup component = val2.GetComponent<EnemySetup>(); if ((Object)(object)component != (Object)null) { Enemies.RegisterEnemy(component); } } } } private void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } private void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(LevelGenerator))] [HarmonyPatch("ModuleGeneration")] public static class ModuleGenerationPatch { [CompilerGenerated] private sealed class <RunPrefabSpawning>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public LevelGenerator __instance; public IEnumerator original; private int <counter>5__1; private List<Action> <actionsToRun>5__2; private int <subCounter>5__3; private List<Action>.Enumerator <>s__4; private Action <action>5__5; private decimal <spawned>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunPrefabSpawning>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 2) <= 1u) { try { } finally { <>m__Finally1(); } } <actionsToRun>5__2 = null; <>s__4 = default(List<Action>.Enumerator); <action>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_0066; case 1: <>1__state = -1; goto IL_0066; case 2: <>1__state = -3; goto IL_01d3; case 3: { <>1__state = -3; goto IL_01d3; } IL_01d3: <action>5__5 = null; goto IL_01db; IL_0066: if (original.MoveNext()) { <>2__current = original.Current; <>1__state = 1; return true; } <counter>5__1 = 0; goto IL_0274; IL_0274: if (IKEASimulator.ToSpawn > IKEASimulator.Spawned) { <actionsToRun>5__2 = new List<Action>(IKEASimulator.SpawnActions); IKEASimulator.SpawnActions.Clear(); <subCounter>5__3 = 0; <>s__4 = <actionsToRun>5__2.GetEnumerator(); <>1__state = -3; goto IL_01db; } IKEASimulator.Spawned = 0; IKEASimulator.ToSpawn = 0; IKEASimulator.NetworkManager.PathMapper?.ClearAllPaths(); return false; IL_01db: if (<>s__4.MoveNext()) { <action>5__5 = <>s__4.Current; <action>5__5(); <subCounter>5__3++; <counter>5__1++; if (<counter>5__1 >= 30) { <spawned>5__6 = IKEASimulator.Spawned + <subCounter>5__3; IKEASimulator.Logger.LogInfo((object)$"Syncing props: [{<spawned>5__6}/{IKEASimulator.ToSpawn}] {Math.Round(<spawned>5__6 / (decimal)IKEASimulator.ToSpawn * 100m)}%"); <counter>5__1 = 0; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 2; return true; } <>2__current = null; <>1__state = 3; return true; } <>m__Finally1(); <>s__4 = default(List<Action>.Enumerator); IKEASimulator.Spawned += <actionsToRun>5__2.Count; IKEASimulator.Logger.LogInfo((object)$"Syncing props: [{IKEASimulator.Spawned}/{IKEASimulator.ToSpawn}] {Math.Round((decimal)IKEASimulator.Spawned / (decimal)IKEASimulator.ToSpawn * 100m)}%"); <actionsToRun>5__2 = null; goto IL_0274; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__4).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPostfix] private static void Postfix(LevelGenerator __instance, ref IEnumerator __result) { __result = RunPrefabSpawning(__instance, __result); } [IteratorStateMachine(typeof(<RunPrefabSpawning>d__1))] private static IEnumerator RunPrefabSpawning(LevelGenerator __instance, IEnumerator original) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RunPrefabSpawning>d__1(0) { __instance = __instance, original = original }; } } [HarmonyPatch(typeof(Module))] [HarmonyPatch("Start")] public static class ModuleStartPrePatch { [HarmonyPrefix] public static void Prefix(Module __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { if (!SemiFunc.IsMultiplayer()) { IKEASimulator.NetworkManager.SingleplayerRoomData(); } PropSwitchContext propSwitchContext = ((Component)__instance).gameObject.AddComponent<PropSwitchContext>(); propSwitchContext.ModuleName = ((Object)__instance).name; propSwitchContext.PathId = IKEASimulator.NetworkManager.PathMapper?.MapPath(((Object)__instance).name); } } } [HarmonyPatch(typeof(Module))] [HarmonyPatch("Start")] public static class ModuleStartPostPatch { [HarmonyPostfix] public static void Postfix(Module __instance) { //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel()) { return; } ValuableObject wrapper = PropUtils.GetWrapper(); if ((Object)(object)wrapper == (Object)null) { IKEASimulator.Logger.LogError((object)"FurnitureWrapper not found"); return; } PropSwitchContext context = ((Component)__instance).gameObject.GetComponent<PropSwitchContext>(); if ((Object)(object)context == (Object)null || context.ModuleName == null || !context.PathId.HasValue) { IKEASimulator.Logger.LogError((object)"ModulePatch: PropSwitchContext not found"); return; } PropUtils.ModuleName = context.ModuleName; PropUtils.PathId = context.PathId; Transform val = ((IEnumerable)((Component)__instance).transform).Cast<Transform>().FirstOrDefault((Func<Transform, bool>)((Transform child) => ((Object)child).name.Contains(" Props ") && ((Object)child).name.StartsWith("-") && ((Object)child).name.EndsWith("-"))); if ((Object)(object)val == (Object)null) { return; } Transform val2 = ((IEnumerable)val).Cast<Transform>().FirstOrDefault((Func<Transform, bool>)((Transform child) => ((Object)child).name == "Props")); if ((Object)(object)val2 == (Object)null) { return; } int num = 0; foreach (Transform item in val2) { Transform child2 = item; if (IKEASimulator.FurnitureLimit.Value != -1 && IKEASimulator.ToSpawn >= IKEASimulator.FurnitureLimit.Value) { break; } if (!PropUtils.HasCollider(child2) || !PropUtils.HasMeshRenderer(child2)) { continue; } IKEASimulator.ToSpawn++; IKEASimulator.SpawnActions.Add(delegate { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) GameObject val3 = Valuables.SpawnValuable(wrapper, child2.position, child2.rotation); if (val3 != null) { val3.GetComponent<PropsParenting>().SetPropPath(context.PathId.Value, ((Object)child2).name); } }); num++; } IKEASimulator.Logger.LogInfo((object)$"Found {num} Props object in {((Object)__instance).name}"); } } [HarmonyPatch(typeof(PhysGrabObject))] [HarmonyPatch("GrabStarted")] public static class PhysGrabObjectGrabStartPatch { [HarmonyPostfix] private static void Postfix(PhysGrabObject __instance) { if (!SemiFunc.IsMultiplayer()) { ((Component)__instance).gameObject.GetComponent<PropsParenting>()?.OnGrabStarted(); } } } [HarmonyPatch(typeof(PhysGrabObject))] [HarmonyPatch("GrabStartedRPC")] public static class PhysGrabObjectGrabStartRPCPatch { [HarmonyPostfix] private static void Postfix(PhysGrabObject __instance) { ((Component)__instance).gameObject.GetComponent<PropsParenting>()?.OnGrabStarted(); } } [HarmonyPatch(typeof(ValuableObject))] [HarmonyPatch("DollarValueSetLogic")] public static class ValuableObjectStartPatch { [HarmonyPostfix] private static void Postfix(ValuableObject __instance) { if (__instance.dollarValueOverride == 0 && !((Object)(object)((Component)__instance).gameObject.GetComponent<PropsParenting>() == (Object)null)) { float num = Mathf.Round((float)Random.Range(IKEASimulator.MinValue.Value, IKEASimulator.MaxValue.Value + 1)); num = ((num < 100f) ? Mathf.Round(num) : (Mathf.Round(num / 100f) * 100f)); __instance.dollarValueOriginal = (IKEASimulator.BreakableFurniture.Value ? Mathf.Max(num, 100f) : 0f); __instance.dollarValueCurrent = num; } } } [HarmonyPatch(typeof(ValuablePropSwitch))] [HarmonyPatch("Start")] public static class ValuablePropSwitchStartPatch { [HarmonyPostfix] private static void Postfix(ValuablePropSwitch __instance) { if (SemiFunc.IsMasterClientOrSingleplayer()) { PropSwitchContext propSwitchContext = ((Component)__instance).gameObject.AddComponent<PropSwitchContext>(); propSwitchContext.ModuleName = PropUtils.ModuleName; propSwitchContext.PathId = PropUtils.PathId; } } } [HarmonyPatch(typeof(ValuablePropSwitch))] [HarmonyPatch("Setup")] public static class ValuablePropSwitchSetupPatch { [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public ValuableObject wrapper; public PropSwitchContext context; } [CompilerGenerated] private sealed class <>c__DisplayClass1_1 { public Transform child; public <>c__DisplayClass1_0 CS$<>8__locals1; internal void <Setup>b__0() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) GameObject val = Valuables.SpawnValuable(CS$<>8__locals1.wrapper, child.position, child.rotation); if (val != null) { val.GetComponent<PropsParenting>().SetPropPath(-CS$<>8__locals1.context.PathId.Value, getFullPath(CS$<>8__locals1.context.ModuleName, child)); } } } [CompilerGenerated] private sealed class <Setup>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ValuablePropSwitch __instance; private <>c__DisplayClass1_0 <>8__1; private int <tries>5__2; private <>c__DisplayClass1_1 <>8__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Setup>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>8__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass1_0(); <tries>5__2 = 10; <>8__1.context = null; break; case 1: <>1__state = -1; break; } if ((Object)(object)<>8__1.context == (Object)null && <tries>5__2 > 0) { <>8__1.context = ((Component)__instance).gameObject.GetComponent<PropSwitchContext>(); <tries>5__2--; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } if ((Object)(object)<>8__1.context == (Object)null) { IKEASimulator.Logger.LogError((object)"PropSwitchContext not found"); return false; } if (<>8__1.context.ModuleName == null || !<>8__1.context.PathId.HasValue) { IKEASimulator.Logger.LogError((object)"PropSwitchContext is missing ModuleName or PathId"); return false; } <>8__1.wrapper = PropUtils.GetWrapper(); if ((Object)(object)<>8__1.wrapper == (Object)null) { IKEASimulator.Logger.LogError((object)"FurnitureWrapper not found"); return false; } if (__instance.PropParent.activeInHierarchy) { <>8__3 = new <>c__DisplayClass1_1(); <>8__3.CS$<>8__locals1 = <>8__1; if (IKEASimulator.PrintDebug) { IKEASimulator.Logger.LogInfo((object)("Spawning " + <>8__3.CS$<>8__locals1.context.ModuleName + "/" + ((Object)__instance).name)); } <>8__3.child = __instance.PropParent.gameObject.transform; if (!PropUtils.HasCollider(<>8__3.child) || !PropUtils.HasMeshRenderer(<>8__3.child)) { return false; } if (IKEASimulator.FurnitureLimit.Value != -1 && IKEASimulator.ToSpawn >= IKEASimulator.FurnitureLimit.Value) { return false; } IKEASimulator.ToSpawn++; IKEASimulator.SpawnActions.Add(delegate { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) GameObject val = Valuables.SpawnValuable(<>8__3.CS$<>8__locals1.wrapper, <>8__3.child.position, <>8__3.child.rotation); if (val != null) { val.GetComponent<PropsParenting>().SetPropPath(-<>8__3.CS$<>8__locals1.context.PathId.Value, getFullPath(<>8__3.CS$<>8__locals1.context.ModuleName, <>8__3.child)); } }); <>8__3 = null; } 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(); } } [HarmonyPostfix] private static void Postfix(ValuablePropSwitch __instance) { if (SemiFunc.IsMasterClientOrSingleplayer()) { ((MonoBehaviour)__instance).StartCoroutine(Setup(__instance)); } } [IteratorStateMachine(typeof(<Setup>d__1))] private static IEnumerator Setup(ValuablePropSwitch __instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Setup>d__1(0) { __instance = __instance }; } private static string getFullPath(string terminate, Transform child) { string text = ((Object)child).name; Transform parent = child.parent; while ((Object)(object)parent != (Object)null && !(((Object)parent).name == terminate)) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } } public class NetworkManager : MonoBehaviourPunCallbacks { [CompilerGenerated] private sealed class <InstantiateRoomData>d__11 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkManager <>4__this; object? IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InstantiateRoomData>d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!SemiFunc.IsMasterClientOrSingleplayer() || ((Object)(object)<>4__this.roomData != (Object)null && !<>4__this.isSingleplayer)) { return false; } <>4__this.retryCount = 10; break; case 1: <>1__state = -1; <>4__this.retryCount--; if (<>4__this.retryCount == 0) { IKEASimulator.Logger.LogError((object)"Failed to connect to room"); return false; } break; } if ((!PhotonNetwork.InRoom || !PhotonNetwork.IsConnectedAndReady) && <>4__this.retryCount > 0) { IKEASimulator.Logger.LogInfo((object)"Waiting for room"); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } IKEASimulator.Logger.LogInfo((object)"Trying to instantiate room data"); PhotonNetwork.InstantiateRoomObject("Managers/RoomData", Vector3.zero, Quaternion.identity, (byte)0, (object[])null); <>4__this.isSingleplayer = 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(); } } [CompilerGenerated] private sealed class <QueueRoomAfterDelay>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkManager <>4__this; object? IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <QueueRoomAfterDelay>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; if (SemiFunc.IsMainMenu()) { return false; } ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.InstantiateRoomData()); 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 bool isSingleplayer = false; private GameObject? roomData; private int retryCount = 0; public PathMapper? PathMapper { get; private set; } public override void OnCreatedRoom() { IKEASimulator.Logger.LogInfo((object)"Created room"); ((MonoBehaviour)this).StartCoroutine(InstantiateRoomData()); } public void SingleplayerRoomData() { isSingleplayer = true; if (!((Object)(object)roomData != (Object)null)) { roomData = IKEASimulator.Instantiate("Managers/RoomData"); PathMapper = roomData.GetComponent<PathMapper>(); } } public void QueueRoomData() { ((MonoBehaviour)this).StartCoroutine(QueueRoomAfterDelay()); } [IteratorStateMachine(typeof(<QueueRoomAfterDelay>d__10))] private IEnumerator QueueRoomAfterDelay() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <QueueRoomAfterDelay>d__10(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<InstantiateRoomData>d__11))] private IEnumerator InstantiateRoomData() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InstantiateRoomData>d__11(0) { <>4__this = this }; } public override void OnLeftRoom() { IKEASimulator.Logger.LogInfo((object)"Left room"); ClearRoomData(); } public void SetRoomData(GameObject data) { roomData = data; PathMapper = roomData.GetComponent<PathMapper>(); } public void ClearRoomData() { roomData = null; } } public class PathMapper : MonoBehaviour { public PhotonView photonView = null; private int nextPathId = 0; private Dictionary<int, string> pathMap = new Dictionary<int, string>(); public int MapPath(string path) { int num = nextPathId; if (SemiFunc.IsMultiplayer()) { photonView.RPC("MapPathRPC", (RpcTarget)0, new object[2] { num, path }); } else { pathMap[num] = path; } nextPathId++; return num; } [PunRPC] public void MapPathRPC(int pathId, string path) { pathMap[pathId] = path; if (IKEASimulator.PrintDebug) { IKEASimulator.Logger.LogInfo((object)$"Mapped path {pathId} to {path}"); } } public string GetPath(int pathId) { return pathMap[pathId]; } public void ClearAllPaths() { nextPathId = 0; } private void Start() { IKEASimulator.Logger.LogInfo((object)"PathMapper started"); IKEASimulator.NetworkManager.SetRoomData(((Component)this).gameObject); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void OnDestroy() { IKEASimulator.Logger.LogInfo((object)"PathMapper destroyed"); if (SemiFunc.IsMasterClientOrSingleplayer()) { IKEASimulator.Logger.LogInfo((object)"Queue room data"); IKEASimulator.NetworkManager.QueueRoomData(); } } } public class PropsParenting : MonoBehaviourPunCallbacks, IPunObservable { [CompilerGenerated] private sealed class <>c__DisplayClass11_0 { public PropsParenting <>4__this; public bool failed; internal bool <ParentPropEnumerator>b__0() { return <>4__this.fullPath != null; } internal void <ParentPropEnumerator>b__1() { <>4__this.fullPath = IKEASimulator.NetworkManager.PathMapper?.GetPath(<>4__this.pathId.Value); } internal void <ParentPropEnumerator>b__2() { failed = true; } internal bool <ParentPropEnumerator>b__3() { return (Object)(object)<>4__this.propObject != (Object)null; } internal void <ParentPropEnumerator>b__4() { <>4__this.propObject = GameObject.Find(<>4__this.fullPath); } internal void <ParentPropEnumerator>b__5() { failed = true; } } [CompilerGenerated] private sealed class <ParentPropEnumerator>d__11 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PropsParenting <>4__this; private <>c__DisplayClass11_0 <>8__1; private Transform <child>5__2; private MonoBehaviour[] <>s__3; private int <>s__4; private MonoBehaviour <component>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ParentPropEnumerator>d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <child>5__2 = null; <>s__3 = null; <component>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass11_0(); <>8__1.<>4__this = <>4__this; <>8__1.failed = false; <>4__this.fullPath = null; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.TryAction(() => <>8__1.<>4__this.fullPath != null, delegate { <>8__1.<>4__this.fullPath = IKEASimulator.NetworkManager.PathMapper?.GetPath(<>8__1.<>4__this.pathId.Value); }, $"Missing prop path after {MAX_TRIES} tries. Returning.", delegate { <>8__1.failed = true; })); <>1__state = 1; return true; case 1: <>1__state = -1; if (<>8__1.failed) { return false; } <>4__this.fullPath = (<>4__this.isSwitched ? ("Level Generator/Level/" + <>4__this.fullPath + "/" + <>4__this.propPath) : ("Level Generator/Level/" + <>4__this.fullPath + "/---- Props ------------/Props/" + <>4__this.propPath)); <>4__this.propObject = null; <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.TryAction(() => (Object)(object)<>8__1.<>4__this.propObject != (Object)null, delegate { <>8__1.<>4__this.propObject = GameObject.Find(<>8__1.<>4__this.fullPath); }, $"Could not find prop at path {<>4__this.fullPath} ({<>4__this.propPath}) after {MAX_TRIES} tries. Returning.", delegate { <>8__1.failed = true; })); <>1__state = 2; return true; case 2: <>1__state = -1; if (<>8__1.failed) { return false; } <child>5__2 = <>4__this.propObject.transform; ((Component)<child>5__2).gameObject.SetActive(false); <child>5__2.SetParent(((Component)<>4__this).transform); <child>5__2.localPosition = Vector3.zero; <child>5__2.localRotation = Quaternion.identity; AddPhysGrabComponents(<child>5__2); ((Component)<child>5__2).gameObject.SetActive(true); <>4__this.rigidbody.isKinematic = true; <>s__3 = <>4__this.componentsToEnable; for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++) { <component>5__5 = <>s__3[<>s__4]; ((Behaviour)<component>5__5).enabled = true; <component>5__5 = null; } <>s__3 = null; 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 <TryAction>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Func<bool> predicate; public Action action; public string message; public Action onFail; public PropsParenting <>4__this; private int <tries>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TryAction>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <tries>5__1 = MAX_TRIES; break; case 1: <>1__state = -1; action?.Invoke(); <tries>5__1--; break; } if (!predicate() && <tries>5__1 > 0) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } if (!predicate()) { if (IKEASimulator.PrintDebug) { IKEASimulator.Logger.LogWarning((object)message); } onFail?.Invoke(); return 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 static readonly int MAX_TRIES = 10; public Rigidbody rigidbody = null; public MonoBehaviour[] componentsToEnable = null; private int? pathId = null; private string? propPath = null; private bool isSwitched = false; private string? fullPath = null; private GameObject? propObject = null; private bool allowMovement = false; public void SetPropPath(int pathId, string propPath) { if (SemiFunc.IsMultiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("SetPropPathRPC", (RpcTarget)0, new object[2] { pathId, propPath }); } else { SetPropPathRPC(pathId, propPath); } } [PunRPC] private void SetPropPathRPC(int pathId, string propPath) { this.propPath = propPath; this.pathId = Mathf.Abs(pathId); isSwitched = pathId < 0; ((MonoBehaviour)this).StartCoroutine(ParentPropEnumerator()); } [IteratorStateMachine(typeof(<ParentPropEnumerator>d__11))] public IEnumerator ParentPropEnumerator() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ParentPropEnumerator>d__11(0) { <>4__this = this }; } private void FixedUpdate() { if (!allowMovement && !rigidbody.isKinematic) { rigidbody.isKinematic = true; } else if (allowMovement && rigidbody.isKinematic) { rigidbody.isKinematic = false; } } public void OnGrabStarted() { allowMovement = true; } [IteratorStateMachine(typeof(<TryAction>d__14))] private IEnumerator TryAction(Func<bool> predicate, Action? action, string message, Action? onFail = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TryAction>d__14(0) { <>4__this = this, predicate = predicate, action = action, message = message, onFail = onFail }; } private static void AddPhysGrabComponents(Transform transform) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown bool flag = false; if ((Object)(object)((Component)transform).GetComponent<BoxCollider>() != (Object)null && (Object)(object)((Component)transform).GetComponent<PhysGrabObjectBoxCollider>() == (Object)null) { ((Component)transform).gameObject.AddComponent<PhysGrabObjectBoxCollider>(); flag = true; } else if ((Object)(object)((Component)transform).GetComponent<SphereCollider>() != (Object)null && (Object)(object)((Component)transform).GetComponent<PhysGrabObjectSphereCollider>() == (Object)null) { ((Component)transform).gameObject.AddComponent<PhysGrabObjectSphereCollider>(); flag = true; } else if ((Object)(object)((Component)transform).GetComponent<CapsuleCollider>() != (Object)null && (Object)(object)((Component)transform).GetComponent<PhysGrabObjectCapsuleCollider>() == (Object)null) { ((Component)transform).gameObject.AddComponent<PhysGrabObjectCapsuleCollider>(); flag = true; } if (flag && (Object)(object)((Component)transform).GetComponent<PhysGrabObjectCollider>() == (Object)null) { ((Component)transform).gameObject.AddComponent<PhysGrabObjectCollider>(); ((Component)transform).gameObject.tag = "Phys Grab Object"; ((Component)transform).gameObject.layer = LayerMask.NameToLayer("PhysGrabObject"); } foreach (Transform item in transform) { Transform transform2 = item; AddPhysGrabComponents(transform2); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { stream.SendNext((object)propPath); } else { propPath = (string)stream.ReceiveNext(); } } } public class PropSwitchContext : MonoBehaviour { public string? ModuleName; public int? PathId = null; } public static class PropUtils { public static string ModuleName = ""; public static int? PathId = null; private static ValuableObject? wrapper; private static bool wrapperInitialized = false; public static ValuableObject? GetWrapper() { if (!wrapperInitialized) { wrapper = Valuables.GetValuableThatContainsName("FurnitureWrapper"); wrapperInitialized = true; } return wrapper; } public static bool HasCollider(Transform transform) { MeshCollider component = ((Component)transform).GetComponent<MeshCollider>(); if ((Object)(object)component != (Object)null && !component.convex) { return false; } if (((IEnumerable)transform).Cast<Transform>().Any(delegate(Transform child) { MeshCollider component2 = ((Component)child).GetComponent<MeshCollider>(); return (Object)(object)component2 != (Object)null && !component2.convex; })) { return false; } if ((Object)(object)((Component)transform).GetComponent<BoxCollider>() != (Object)null || (Object)(object)((Component)transform).GetComponent<SphereCollider>() != (Object)null || (Object)(object)((Component)transform).GetComponent<CapsuleCollider>() != (Object)null) { return transform.childCount <= 0 || ((IEnumerable)transform).Cast<Transform>().Any((Transform child) => HasCollider(child)); } return ((IEnumerable)transform).Cast<Transform>().Any((Transform child) => HasCollider(child)); } public static bool HasMeshRenderer(Transform transform) { if ((Object)(object)((Component)transform).GetComponent<MeshRenderer>() != (Object)null) { return true; } return ((IEnumerable)transform).Cast<Transform>().Any((Transform child) => HasMeshRenderer(child)); } } }