Decompiled source of Architect v3.5.7
Architect/Architect.dll
Decompiled 11 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Architect.Api; using Architect.Behaviour.Abilities; using Architect.Behaviour.Custom; using Architect.Behaviour.Fixers; using Architect.Behaviour.Utility; using Architect.Config; using Architect.Config.Types; using Architect.Content; using Architect.Content.Custom; using Architect.Content.Preloads; using Architect.Editor; using Architect.Events; using Architect.Events.Blocks; using Architect.Events.Blocks.Config; using Architect.Events.Blocks.Config.Types; using Architect.Events.Blocks.Events; using Architect.Events.Blocks.Objects; using Architect.Events.Blocks.Operators; using Architect.Events.Blocks.Outputs; using Architect.Events.Vars; using Architect.Multiplayer; using Architect.Multiplayer.Ssmp; using Architect.Multiplayer.Ssmp.Data; using Architect.Objects; using Architect.Objects.Categories; using Architect.Objects.Groups; using Architect.Objects.Placeable; using Architect.Objects.Tools; using Architect.Placements; using Architect.Storage; using Architect.Storage.Sharer; using Architect.Utils; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GlobalEnums; using GlobalSettings; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using InControl; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using Newtonsoft.Json; using Patchwork.Handlers; using PrepatcherPlugin; using SSMP.Api.Client; using SSMP.Api.Client.Networking; using SSMP.Api.Server; using SSMP.Api.Server.Networking; using SSMP.Math; using SSMP.Networking.Packet; using TMProOld; using TeamCherry.Localization; using TeamCherry.Splines; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Animations; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceProviders; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.Video; [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: AssemblyCompany("Architect")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("3.5.7.0")] [assembly: AssemblyInformationalVersion("3.5.7+2444658e38fb12b28282b6b15b81bf1c5c237b33")] [assembly: AssemblyProduct("Architect")] [assembly: AssemblyTitle("Architect")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.5.7.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Architect { [BepInPlugin("com.cometcake575.architect", "Architect", "3.5.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ArchitectPlugin : BaseUnityPlugin { internal static ArchitectPlugin Instance; internal static ManualLogSource Logger; public static readonly Sprite BlankSprite = ResourceUtils.LoadSpriteResource("blank", (FilterMode)1, default(Vector4), 300f); private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Architect has loaded!"); HookUtils.Init(); TitleUtils.Init(); StorageManager.Init(); Settings.Init(((BaseUnityPlugin)this).Config); MiscFixers.Init(); EnemyFixers.Init(); HazardFixers.Init(); Categories.Init(); PreloadManager.Init(); ActionManager.Init(); CoopManager.Init(); EditManager.Init(); CursorManager.Init(); EditorUI.Init(); VanillaObjects.Init(); SplineObjects.Init(); LegacyObjects.Init(); UtilityObjects.Init(); AbilityObjects.Init(); MiscObjects.Init(); RespawnMarkerManager.Init(); PlacementManager.Init(); BroadcasterHooks.Init(); LevelSharerUI.Init(); } private void Update() { if (Object.op_Implicit((Object)(object)HeroController.instance)) { EditManager.Update(); HazardFixers.UpdateLanterns(); } CursorManager.Update(); LevelSharerUI.Update(); AbilityObjects.Update(); } } } namespace Architect.Utils { public static class FsmUtils { public class CustomFsmAction : FsmStateAction { public bool EveryFrame; private Action _method; public CustomFsmAction(Action method) { _method = method; ((FsmStateAction)this)..ctor(); } public override void Reset() { _method = null; ((FsmStateAction)this).Reset(); } public override void OnEnter() { _method(); if (!EveryFrame) { ((FsmStateAction)this).Finish(); } } public override void OnUpdate() { if (EveryFrame) { _method(); } } } public static void AddState(this PlayMakerFSM fsm, string state) { //IL_003a: 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_0048: Expected O, but got Unknown FsmState[] states = fsm.fsm.States; FsmState[] array = (FsmState[])(object)new FsmState[states.Length + 1]; for (int i = 0; i < states.Length; i++) { array[i] = states[i]; } FsmState val = new FsmState(fsm.fsm) { Name = state }; array[states.Length] = val; fsm.fsm.States = array; } public static FsmState GetState(this PlayMakerFSM fsm, string state) { return fsm.Fsm.GetState(state); } public static void DisableAction(this FsmState state, int index) { state.Actions[index].Enabled = false; } public static void AddAction(this FsmState state, Action action, int index = -1, bool everyFrame = false) { CustomFsmAction customAction = new CustomFsmAction(action) { EveryFrame = everyFrame }; state.AddAction((FsmStateAction)(object)customAction, index); } public static void AddAction(this FsmState state, FsmStateAction customAction, int index = -1) { FsmStateAction[] actions = state.Actions; if (index == -1) { index = actions.Length; } FsmStateAction[] array = (FsmStateAction[])(object)new FsmStateAction[actions.Length + 1]; int num = 0; int num2 = 0; while (num < array.Length) { if (num == index) { array[num] = customAction; num++; } if (num2 < actions.Length) { array[num] = actions[num2]; } num++; num2++; } state.Actions = array; customAction.Init(state); } } public static class HookUtils { public static Action<HeroController> OnHeroUpdate; public static Action<HeroController> OnHeroAwake; public static Action<PlayMakerFSM> OnFsmAwake; public static void Init() { typeof(PlayMakerFSM).Hook("Awake", (Action<Action<PlayMakerFSM>, PlayMakerFSM>)delegate(Action<PlayMakerFSM> orig, PlayMakerFSM self) { orig(self); OnFsmAwake?.Invoke(self); }); typeof(HeroController).Hook("Update", (Action<Action<HeroController>, HeroController>)delegate(Action<HeroController> orig, HeroController self) { orig(self); OnHeroUpdate?.Invoke(self); }); typeof(HeroController).Hook("Awake", (Action<Action<HeroController>, HeroController>)delegate(Action<HeroController> orig, HeroController self) { orig(self); OnHeroAwake?.Invoke(self); }); } public static void Hook(this Type type, string name, Delegate target, params Type[] types) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (Extensions.IsNullOrEmpty<Type>((ICollection<Type>)types)) { new Hook((MethodBase)type.GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), target); } else { new Hook((MethodBase)type.GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, types, null), target); } } } public static class MiscUtils { [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public HeroController hero; public Predicate<HeroController> condition; internal bool <FreeControl>b__0() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return !hero.controlReqlinquished && (int)HeroController.instance.transitionState == 0 && (condition == null || condition(hero)); } } [CompilerGenerated] private sealed class <FreeControl>d__0 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public HeroController hero; public Predicate<HeroController> condition; private <>c__DisplayClass0_0 <>8__1; private PlayMakerFSM <fsm>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FreeControl>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <fsm>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass0_0(); <>8__1.hero = hero; <>8__1.condition = condition; <fsm>5__2 = <>8__1.hero.sprintFSM; if (<fsm>5__2.ActiveStateName.Contains("Sprint")) { <fsm>5__2.SendEvent("SKID END"); } <>8__1.hero.umbrellaFSM.SendEvent("END"); <>2__current = (object)new WaitUntil((Func<bool>)(() => !<>8__1.hero.controlReqlinquished && (int)HeroController.instance.transitionState == 0 && (<>8__1.condition == null || <>8__1.condition(<>8__1.hero)))); <>1__state = 1; return true; case 1: <>1__state = -1; 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(); } } [IteratorStateMachine(typeof(<FreeControl>d__0))] public static IEnumerator FreeControl(this HeroController hero, Predicate<HeroController> condition = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FreeControl>d__0(0) { hero = hero, condition = condition }; } [CanBeNull] public static SavedItem GetSavedItem(string name) { if (((NamedScriptableObjectList<CollectableItem>)(object)ManagerSingleton<CollectableItemManager>.Instance.masterList).dictionary.TryGetValue(name, out var value)) { return (SavedItem)(object)value; } return (SavedItem)(object)((NamedScriptableObjectList<ToolItem>)(object)ManagerSingleton<ToolItemManager>.Instance.toolItems).dictionary.GetValueOrDefault(name); } } public static class ObjectUtils { public static T GetOrAddComponent<T>(this GameObject obj) where T : Component { T component = obj.GetComponent<T>(); return Object.op_Implicit((Object)(object)component) ? component : obj.AddComponent<T>(); } public static void RemoveComponent<T>(this GameObject obj) where T : Component { T component = obj.GetComponent<T>(); if (Object.op_Implicit((Object)(object)component)) { Object.Destroy((Object)(object)component); } } public static T ReplaceComponent<T>(this GameObject obj) where T : Component { obj.RemoveComponent<T>(); return obj.AddComponent<T>(); } public static void BroadcastEvent(this GameObject obj, string triggerName) { EventManager.BroadcastEvent(obj, triggerName); } public static void RemoveComponentsInChildren<T>(this GameObject obj) where T : Component { T[] componentsInChildren = obj.GetComponentsInChildren<T>(true); T[] array = componentsInChildren; foreach (T val in array) { Object.Destroy((Object)(object)val); } } public static string GetPath(this Transform current) { if (!Object.op_Implicit((Object)(object)current.parent)) { return ((Object)current).name; } return current.parent.GetPath() + "/" + ((Object)current).name; } internal static GameObject GetGameObjectFromArray(GameObject[] objects, string objName) { string text = null; int num = objName.IndexOf('/'); string rootName; if (num == -1) { rootName = objName; } else { if (num == 0 || num == objName.Length - 1) { throw new ArgumentException("Invalid GameObject path"); } rootName = objName.Substring(0, num); int num2 = num + 1; text = objName.Substring(num2, objName.Length - num2); } GameObject val = ((IEnumerable<GameObject>)objects).FirstOrDefault((Func<GameObject, bool>)((GameObject o) => ((Object)o).name == rootName)); if (!Object.op_Implicit((Object)(object)val)) { return null; } if (text != null) { Transform val2 = val.transform.Find(text); return (!Object.op_Implicit((Object)(object)val2)) ? null : ((Component)val2).gameObject; } return val; } } public static class PreviewUtils { public static Vector3 FixPreview(SpriteRenderer renderer, PlaceableObject type, bool flipped, float rotation, float scale) { //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_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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_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_010d: 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_0111: Unknown result type (might be due to invalid IL or missing references) if (type.Tk2dRotation / 90 % 2 != 0) { renderer.flipY = flipped != type.FlipX; renderer.flipX = type.LossyScale.x < 0f; } else { renderer.flipX = flipped != type.FlipX; renderer.flipY = type.LossyScale.y < 0f; } Vector3 childOffset = type.ChildOffset; childOffset.x /= type.LossyScale.x; childOffset.y /= type.LossyScale.y; Vector3 val = type.Offset + childOffset; val.x *= type.ParentScale.x; val.y *= type.ParentScale.y; if (flipped) { val.x = 0f - val.x; } return Quaternion.Euler(0f, 0f, rotation) * (val * scale); } public static Sprite ConvertFrom2DToolkit(tk2dSpriteDefinition def, float ppu) { //IL_012f: 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) Texture mainTexture = def.material.mainTexture; Texture2D val = (Texture2D)(object)((mainTexture is Texture2D) ? mainTexture : null); if (val == null) { return null; } float num = def.uvs[0].x; float num2 = def.uvs[0].y; float num3 = def.uvs[0].x; float num4 = def.uvs[0].y; for (int i = 1; i < def.uvs.Length; i++) { num = Mathf.Min(num, def.uvs[i].x); num2 = Mathf.Min(num2, def.uvs[i].y); num3 = Mathf.Max(num3, def.uvs[i].x); num4 = Mathf.Max(num4, def.uvs[i].y); } float num5 = num * (float)((Texture)val).width; float num6 = num2 * (float)((Texture)val).height; float num7 = (num3 - num) * (float)((Texture)val).width; float num8 = (num4 - num2) * (float)((Texture)val).height; return Sprite.Create(val, new Rect(num5, num6, num7, num8), new Vector2(0.5f, 0.5f), ppu); } } public static class ResourceUtils { [CompilerGenerated] private sealed class <LoadClip>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string clipPath; public Action<AudioClip> callback; private UnityWebRequest <www>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadClip>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <www>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0032: 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_006e: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; <www>5__1 = UnityWebRequestMultimedia.GetAudioClip(new Uri(clipPath), GetAudioType(clipPath)); <>2__current = <www>5__1.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((int)<www>5__1.result == 1) { callback(DownloadHandlerAudioClip.GetContent(<www>5__1)); } else { ArchitectPlugin.Logger.LogInfo((object)<www>5__1.error); } 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(); } } internal static Sprite LoadSpriteResource(string spritePath, FilterMode filterMode = 1, Vector4 border = default(Vector4), float ppu = 100f) { //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_0012: Unknown result type (might be due to invalid IL or missing references) return LoadSpriteResource(spritePath, new Vector2(0.5f, 0.5f), filterMode, border, ppu); } internal static Sprite LoadSpriteResource(string spritePath, Vector2 pivot, FilterMode filterMode = 1, Vector4 border = default(Vector4), float ppu = 100f) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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) string name = "Architect.Resources." + spritePath + ".png"; Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(name); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array, true); ((Texture)val).wrapMode = (TextureWrapMode)1; Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), pivot, ppu, 0u, (SpriteMeshType)1, border); ((Texture)val2.texture).filterMode = filterMode; return val2; } [CanBeNull] internal static Sprite[] LoadSprites(string spritePath, bool point, float ppu, int hcount, int vcount) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0087: 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) if (!File.Exists(spritePath)) { return null; } Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, File.ReadAllBytes(spritePath), true); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)((!point) ? 1 : 0); Sprite[] array = (Sprite[])(object)new Sprite[hcount * vcount]; float num = (float)((Texture)val).height / (float)vcount; float num2 = (float)((Texture)val).width / (float)hcount; int num3 = 0; for (int num4 = vcount - 1; num4 >= 0; num4--) { for (int i = 0; i < hcount; i++) { array[num3] = Sprite.Create(val, new Rect(num2 * (float)i, num * (float)num4, num2, num), new Vector2(0.5f, 0.5f), ppu); num3++; } } return array; } [IteratorStateMachine(typeof(<LoadClip>d__3))] internal static IEnumerator LoadClip(string clipPath, Action<AudioClip> callback) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadClip>d__3(0) { clipPath = clipPath, callback = callback }; } internal static void LoadClipResource(string clipPath, Action<AudioClip> callback) { string text = StorageManager.DataPath + "ModAssets/" + clipPath + ".wav"; if (!File.Exists(text)) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream("Architect.Resources." + clipPath + ".wav"); if (stream == null) { return; } using FileStream destination = new FileStream(text, FileMode.Create, FileAccess.Write); stream.CopyTo(destination); } ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(LoadClip(text, callback)); } private static AudioType GetAudioType(string fileName) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) string text = Path.GetExtension(fileName).ToLower(); if (1 == 0) { } AudioType result; switch (text) { case ".wav": result = (AudioType)20; break; case ".mp3": result = (AudioType)13; break; case ".ogg": result = (AudioType)14; break; case ".aif": case ".aiff": result = (AudioType)2; break; default: result = (AudioType)0; break; } if (1 == 0) { } return result; } } public static class SceneUtils { [CompilerGenerated] private sealed class <CreateScene>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string sceneName; private string <current>5__1; private Scene <scene>5__2; private AsyncOperation <unload2>5__3; private GameObject <sm>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CreateScene>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <current>5__1 = null; <unload2>5__3 = null; <sm>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <current>5__1 = GameManager.instance.sceneName; if (<current>5__1 == sceneName) { GameManager.instance.LoadScene("Belltown"); <current>5__1 = "Belltown"; <>2__current = (object)new WaitForSeconds(10f); <>1__state = 1; return true; } goto IL_0090; case 1: <>1__state = -1; goto IL_0090; case 2: { <>1__state = -1; goto IL_00e4; } IL_0090: <scene>5__2 = SceneManager.CreateScene(sceneName); SceneManager.SetActiveScene(<scene>5__2); <unload2>5__3 = SceneManager.UnloadSceneAsync(<current>5__1); if (<unload2>5__3 == null) { break; } goto IL_00e4; IL_00e4: if (!<unload2>5__3.isDone) { <>2__current = null; <>1__state = 2; return true; } break; } <sm>5__4 = Object.Instantiate<GameObject>(_sceneManager); <sm>5__4.AddComponent<HazardRespawnMarker>(); ((Object)<sm>5__4).name = "_SceneManager"; <sm>5__4.SetActive(true); 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 GameObject _sceneManager; public static void Init() { PreloadManager.RegisterPreload(new BasicPreload("Arborium_09", "_SceneManager", delegate(GameObject o) { ((Object)o).name = "[Architect] Scene Manager Preload"; _sceneManager = o; })); typeof(GameManager).Hook("LoadScene", (Action<Action<GameManager, string>, GameManager, string>)delegate(Action<GameManager, string> orig, GameManager self, string destScene) { if (destScene.StartsWith("Architect_")) { ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(CreateScene(destScene)); } else { orig(self, destScene); } }); } [IteratorStateMachine(typeof(<CreateScene>d__2))] private static IEnumerator CreateScene(string sceneName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CreateScene>d__2(0) { sceneName = sceneName }; } } public static class TitleUtils { private static bool _overrideAreaText; private static int _areaType; private static string _areaHeader; private static string _areaBody; private static string _areaFooter; public static void Init() { HookUtils.OnFsmAwake = (Action<PlayMakerFSM>)Delegate.Combine(HookUtils.OnFsmAwake, (Action<PlayMakerFSM>)delegate(PlayMakerFSM fsm) { if (fsm.FsmName == "Area Title Control") { FsmString header = fsm.FsmVariables.FindFsmString("Title Sup"); FsmString footer = fsm.FsmVariables.FindFsmString("Title Sub"); FsmString body = fsm.FsmVariables.FindFsmString("Title Main"); FsmBool right = fsm.FsmVariables.FindFsmBool("Display Right"); fsm.GetState("Init all").AddAction(delegate { if (_overrideAreaText) { header.value = _areaHeader; footer.value = _areaFooter; body.value = _areaBody; } }, -1, everyFrame: false); fsm.GetState("Visited Check").AddAction(delegate { if (_overrideAreaText) { _overrideAreaText = false; right.value = _areaType == 2; fsm.SendEvent((_areaType == 0) ? "UNVISITED" : "VISITED"); } }, 0, everyFrame: false); } }); } public static void DisplayTitle(string header, string body, string footer, int type) { _overrideAreaText = true; _areaType = type; _areaHeader = header; _areaBody = body; _areaFooter = footer; ((Component)ManagerSingleton<AreaTitle>.Instance).gameObject.SetActive(true); } } public static class UIUtils { public class LabelledButton : MonoBehaviour { public Label label; private void Start() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) RectTransform component = ((Component)this).GetComponent<RectTransform>(); component.sizeDelta = new Vector2(label.textComponent.preferredWidth * 3f + 10f, label.textComponent.preferredHeight * 3f); } } public class Label : MonoBehaviour { public string font = "Perpetua"; public Text textComponent; private void Start() { textComponent.font = GetFont(font); } } public static readonly Sprite Square = ResourceUtils.LoadSpriteResource("square", (FilterMode)1); private static readonly Color LightGrey = new Color(0.7f, 0.7f, 0.7f); private static readonly Sprite ButtonSprite = ResourceUtils.LoadSpriteResource("button_outline", new Vector2(0.5f, 0.5f), (FilterMode)1, new Vector4(6f, 5f, 6f, 5f)); private static readonly Sprite ButtonSpriteBlank = ResourceUtils.LoadSpriteResource("button_no_outline", new Vector2(0.5f, 0.5f), (FilterMode)1, new Vector4(6f, 5f, 6f, 5f)); private static readonly Vector2 Centre = new Vector2(0.5f, 0.5f); private static readonly Dictionary<string, Font> Fonts = new Dictionary<string, Font>(); public static (Button, Image, Label) MakeButtonWithImage(string name, GameObject parent, Vector2 pos, Vector2 anchorMin, Vector2 anchorMax, int size, int imageSize, bool doOutline = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00bd: 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: Expected O, but got Unknown //IL_00ec: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); RectTransform val2 = val.AddComponent<RectTransform>(); Button val3 = val.AddComponent<Button>(); Image val4 = val.AddComponent<Image>(); ColorBlock colors = ((Selectable)val3).colors; ((ColorBlock)(ref colors)).pressedColor = LightGrey; ((ColorBlock)(ref colors)).fadeDuration = 0.1f; ((Selectable)val3).colors = colors; ((Selectable)val3).targetGraphic = (Graphic)(object)val4; val4.sprite = (doOutline ? ButtonSprite : ButtonSpriteBlank); val4.type = (Type)1; ((Transform)val2).SetParent(parent.transform, false); val2.anchorMin = anchorMin; val2.anchorMax = anchorMax; val2.sizeDelta = new Vector2((float)size, (float)size); Transform transform = val.transform; transform.localScale /= 3f; val2.anchoredPosition = pos; GameObject val5 = new GameObject("Image"); val5.transform.SetParent((Transform)(object)val2, false); val5.AddComponent<RectTransform>().sizeDelta = new Vector2((float)imageSize, (float)imageSize); Image val6 = val5.AddComponent<Image>(); val6.preserveAspect = true; Label label = MakeLabel(name + " Label", val, Vector2.zero, Centre, Centre, 80f, 80f, (HorizontalWrapMode)1); label.textComponent.alignment = (TextAnchor)4; return (val3, val6, label); } public static (Button, Label) MakeTextButton(string name, string text, GameObject parent, Vector2 pos, Vector2 anchorMin, Vector2 anchorMax, bool hasOutline = true, Vector2 size = default(Vector2)) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_0178: 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) GameObject val = new GameObject(name); RectTransform val2 = val.AddComponent<RectTransform>(); Button val3 = val.AddComponent<Button>(); Label label; if (hasOutline) { label = MakeLabel(name + " Label", parent, pos, anchorMin, anchorMax, 80f, 80f, (HorizontalWrapMode)1); Image val5 = (Image)(object)(((Selectable)val3).targetGraphic = (Graphic)(object)val.AddComponent<Image>()); val5.sprite = ButtonSprite; val5.type = (Type)1; ColorBlock colors = ((Selectable)val3).colors; ((ColorBlock)(ref colors)).pressedColor = LightGrey; ((ColorBlock)(ref colors)).fadeDuration = 0.1f; ((Selectable)val3).colors = colors; label.textComponent.fontSize = 8; } else { label = MakeLabel(name + " Label", val, Vector2.zero, Centre, Centre, 80f, 80f, (HorizontalWrapMode)1); ((Selectable)val3).targetGraphic = (Graphic)(object)label.textComponent; ((Component)label).transform.SetParent((Transform)(object)val2); label.textComponent.fontSize = 44; Transform transform = ((Component)label).transform; transform.localScale /= 3f; } label.textComponent.alignment = (TextAnchor)4; label.textComponent.text = text; ((Transform)val2).SetParent(parent.transform, false); val2.anchorMin = anchorMin; val2.anchorMax = anchorMax; Transform transform2 = val.transform; transform2.localScale /= 3f; val2.anchoredPosition = pos; if (size == Vector2.zero) { val.AddComponent<LabelledButton>().label = label; } else { val2.sizeDelta = size; } return (val3, label); } public static (InputField, Label) MakeTextbox(string name, GameObject parent, Vector2 pos, Vector2 anchorMin, Vector2 anchorMax, float width, float height, int fontSize = 20) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001b: 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_0033: 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_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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0136: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); RectTransform val2 = val.AddComponent<RectTransform>(); InputField val3 = val.AddComponent<InputField>(); val2.sizeDelta = new Vector2(width, height); Label label = MakeLabel(name + " Label", parent, pos, anchorMin, anchorMax, width - 15f, 80f, (HorizontalWrapMode)1); Image val5 = (Image)(object)(((Selectable)val3).targetGraphic = (Graphic)(object)val.AddComponent<Image>()); val5.sprite = ButtonSprite; val5.type = (Type)1; ColorBlock colors = ((Selectable)val3).colors; ((ColorBlock)(ref colors)).selectedColor = LightGrey; ((ColorBlock)(ref colors)).pressedColor = LightGrey; ((ColorBlock)(ref colors)).fadeDuration = 0.1f; ((Selectable)val3).colors = colors; val3.textComponent = label.textComponent; val3.textComponent.supportRichText = false; label.textComponent.fontSize = fontSize; Transform transform = ((Component)label).transform; transform.localScale /= 3f; label.textComponent.alignment = (TextAnchor)3; ((Transform)val2).SetParent(parent.transform, false); val2.anchorMin = anchorMin; val2.anchorMax = anchorMax; Transform transform2 = val.transform; transform2.localScale /= 3f; val2.anchoredPosition = pos; return (val3, label); } public static Label MakeLabel(string name, GameObject parent, Vector2 pos, Vector2 anchorMin, Vector2 anchorMax, float maxWidth = 80f, float maxHeight = 80f, HorizontalWrapMode wrapMode = 1) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0035: 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_005b: 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_0074: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); RectTransform val2 = val.AddComponent<RectTransform>(); Label label = val.AddComponent<Label>(); label.textComponent = val.AddComponent<Text>(); label.textComponent.supportRichText = false; label.textComponent.horizontalOverflow = wrapMode; ((Transform)val2).SetParent(parent.transform, false); ((Transform)val2).SetAsFirstSibling(); val2.anchorMin = anchorMin; val2.anchorMax = anchorMax; val2.sizeDelta = new Vector2(maxWidth, maxHeight); val2.anchoredPosition = pos; return label; } public static Font GetFont(string fontName) { if (Fonts.TryGetValue(fontName, out var value)) { return value; } Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val in array) { if (((Object)val).name == fontName) { Fonts[fontName] = val; return val; } } return Fonts.GetValueOrDefault(fontName); } public static Image MakeImage(string name, GameObject parent, Vector2 pos, Vector2 anchorMin, Vector2 anchorMax, Vector2 size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0023: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchoredPosition = pos; val2.anchorMin = anchorMin; val2.anchorMax = anchorMax; val2.sizeDelta = size; Image val3 = val.AddComponent<Image>(); val3.preserveAspect = false; Transform transform = val.transform; transform.localScale *= 0.5f; return val3; } } public static class ZipUtils { private static void CopyTo(Stream src, Stream dest) { byte[] array = new byte[4096]; int count; while ((count = src.Read(array, 0, array.Length)) != 0) { dest.Write(array, 0, count); } } public static byte[] Zip(string str) { byte[] bytes = Encoding.UTF8.GetBytes(str); using MemoryStream src = new MemoryStream(bytes); using MemoryStream memoryStream = new MemoryStream(); using (GZipStream dest = new GZipStream(memoryStream, CompressionMode.Compress)) { CopyTo(src, dest); } return memoryStream.ToArray(); } public static string Unzip(byte[] bytes) { using MemoryStream stream = new MemoryStream(bytes); using MemoryStream memoryStream = new MemoryStream(); using (GZipStream src = new GZipStream(stream, CompressionMode.Decompress)) { CopyTo(src, memoryStream); } return Encoding.UTF8.GetString(memoryStream.ToArray()); } } } namespace Architect.Storage { public static class CustomAssetManager { [CompilerGenerated] private sealed class <>c__DisplayClass11_0 { public string url; internal bool <LoadSound>b__0() { return !LoadingSounds.Contains(url); } internal void <LoadSound>b__1(AudioClip clip) { if (Object.op_Implicit((Object)(object)clip)) { Sounds[url] = clip; } LoadingSounds.Remove(url); } } [CompilerGenerated] private sealed class <>c__DisplayClass11_1 { public string path; public <>c__DisplayClass11_0 CS$<>8__locals1; internal Task<bool> <LoadSound>b__2() { return SaveFile(CS$<>8__locals1.url, path); } } [CompilerGenerated] private sealed class <>c__DisplayClass7_0 { public string url; public string path; internal Task<bool> <LoadVideo>b__0() { return SaveFile(url, path); } } [CompilerGenerated] private sealed class <>c__DisplayClass9_0 { public string id; public string url; internal bool <LoadSprite>b__0() { return !LoadingSprites.Contains(id); } } [CompilerGenerated] private sealed class <>c__DisplayClass9_1 { public string path; public <>c__DisplayClass9_0 CS$<>8__locals1; internal Task<bool> <LoadSprite>b__1() { return SaveFile(CS$<>8__locals1.url, path); } } [CompilerGenerated] private sealed class <LoadSound>d__11 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string url; public GameObject obj; private <>c__DisplayClass11_0 <>8__1; private AudioClip <sound>5__2; private <>c__DisplayClass11_1 <>8__3; private Task<bool> <task>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSound>d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <sound>5__2 = null; <>8__3 = null; <task>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass11_0(); <>8__1.url = url; if (LoadingSounds.Contains(<>8__1.url)) { <>2__current = (object)new WaitUntil((Func<bool>)(() => !LoadingSounds.Contains(<>8__1.url))); <>1__state = 1; return true; } if (Sounds.ContainsKey(<>8__1.url)) { break; } <>8__3 = new <>c__DisplayClass11_1(); <>8__3.CS$<>8__locals1 = <>8__1; LoadingSounds.Add(<>8__3.CS$<>8__locals1.url); <>8__3.path = GetPath(<>8__3.CS$<>8__locals1.url) + ".wav"; if (!File.Exists(<>8__3.path)) { <task>5__4 = Task.Run(() => SaveFile(<>8__3.CS$<>8__locals1.url, <>8__3.path)); goto IL_01b0; } goto IL_01cc; case 1: <>1__state = -1; if (Object.op_Implicit((Object)(object)obj) && Sounds.TryGetValue(<>8__1.url, out <sound>5__2)) { obj.GetComponent<WavObject>().sound = <sound>5__2; } return false; case 2: <>1__state = -1; goto IL_01b0; case 3: { <>1__state = -1; <>8__3 = null; break; } IL_01b0: if (!<task>5__4.IsCompleted) { <>2__current = null; <>1__state = 2; return true; } <task>5__4 = null; goto IL_01cc; IL_01cc: <>2__current = ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(ResourceUtils.LoadClip(<>8__3.path, delegate(AudioClip clip) { if (Object.op_Implicit((Object)(object)clip)) { Sounds[<>8__3.CS$<>8__locals1.url] = clip; } LoadingSounds.Remove(<>8__3.CS$<>8__locals1.url); })); <>1__state = 3; return true; } if (Object.op_Implicit((Object)(object)obj)) { obj.GetComponent<WavObject>().sound = Sounds[<>8__1.url]; } 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 <LoadSprite>d__9 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string url; public bool point; public float ppu; public int hcount; public int vcount; public Action<Sprite[]> callback; private <>c__DisplayClass9_0 <>8__1; private Sprite[] <sprite>5__2; private <>c__DisplayClass9_1 <>8__3; private Sprite[] <tmp>5__4; private Task<bool> <task>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSprite>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <sprite>5__2 = null; <>8__3 = null; <tmp>5__4 = null; <task>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass9_0(); <>8__1.url = url; <>8__1.id = $"{<>8__1.url}_{point}_{ppu}_{hcount}_{vcount}"; if (LoadingSprites.Contains(<>8__1.id)) { <>2__current = (object)new WaitUntil((Func<bool>)(() => !LoadingSprites.Contains(<>8__1.id))); <>1__state = 1; return true; } if (Sprites.ContainsKey(<>8__1.id)) { break; } <>8__3 = new <>c__DisplayClass9_1(); <>8__3.CS$<>8__locals1 = <>8__1; LoadingSprites.Add(<>8__3.CS$<>8__locals1.id); <>8__3.path = GetPath(<>8__3.CS$<>8__locals1.url) + ".png"; <tmp>5__4 = ResourceUtils.LoadSprites(<>8__3.path, point, ppu, hcount, vcount); if (<tmp>5__4 == null) { <task>5__5 = Task.Run(() => SaveFile(<>8__3.CS$<>8__locals1.url, <>8__3.path)); goto IL_021e; } goto IL_0268; case 1: <>1__state = -1; if (Sprites.TryGetValue(<>8__1.id, out <sprite>5__2)) { callback(<sprite>5__2); } return false; case 2: { <>1__state = -1; goto IL_021e; } IL_0268: LoadingSprites.Remove(<>8__3.CS$<>8__locals1.id); if (<tmp>5__4 == null) { return false; } Sprites[<>8__3.CS$<>8__locals1.id] = <tmp>5__4; <>8__3 = null; <tmp>5__4 = null; break; IL_021e: if (!<task>5__5.IsCompleted) { <>2__current = null; <>1__state = 2; return true; } <tmp>5__4 = ResourceUtils.LoadSprites(<>8__3.path, point, ppu, hcount, vcount); <task>5__5 = null; goto IL_0268; } callback(Sprites[<>8__1.id]); 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 <LoadVideo>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string url; public float? scale; public VideoPlayer player; private <>c__DisplayClass7_0 <>8__1; private Task<bool> <task>5__2; private float <sc>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadVideo>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <task>5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass7_0(); <>8__1.url = url; <>8__1.path = GetPath(<>8__1.url) + ".mov"; if (!File.Exists(<>8__1.path)) { <task>5__2 = Task.Run(() => SaveFile(<>8__1.url, <>8__1.path)); goto IL_00bf; } goto IL_00d9; case 1: <>1__state = -1; goto IL_00bf; case 2: { <>1__state = -1; goto IL_011c; } IL_00d9: if (!Object.op_Implicit((Object)(object)player)) { break; } player.url = <>8__1.path; goto IL_011c; IL_00bf: if (!<task>5__2.IsCompleted) { <>2__current = null; <>1__state = 1; return true; } <task>5__2 = null; goto IL_00d9; IL_011c: if (player.width == 0) { <>2__current = null; <>1__state = 2; return true; } <sc>5__3 = scale.GetValueOrDefault(EditManager.CurrentScale); Extensions.SetScaleX(((Component)player).transform, <sc>5__3 * (float)player.width / 100f); Extensions.SetScaleY(((Component)player).transform, <sc>5__3 * (float)player.height / 100f); break; } 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 static readonly Dictionary<string, Sprite[]> Sprites = new Dictionary<string, Sprite[]>(); public static readonly Dictionary<string, AudioClip> Sounds = new Dictionary<string, AudioClip>(); public static readonly HashSet<string> LoadingSounds = new HashSet<string>(); public static readonly HashSet<string> LoadingSprites = new HashSet<string>(); public static int DownloadingAssets; public static int Downloaded; public static int Failed; public static async Task<bool> SaveFile(string url, string path) { try { WebClient webClient = new WebClient(); await webClient.DownloadFileTaskAsync(url, path); return true; } catch { return false; } } public static void WipeAssets() { foreach (Sprite item in Sprites.Values.SelectMany((Sprite[] spr) => spr)) { Object.Destroy((Object)(object)item); } foreach (AudioClip value in Sounds.Values) { Object.Destroy((Object)(object)value); } Sprites.Clear(); Sounds.Clear(); } public static void DoLoadVideo(VideoPlayer player, float? scale, string url) { ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(LoadVideo(url, scale, player)); } [IteratorStateMachine(typeof(<LoadVideo>d__7))] private static IEnumerator LoadVideo(string url, float? scale, [CanBeNull] VideoPlayer player = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadVideo>d__7(0) { url = url, scale = scale, player = player }; } public static void DoLoadSprite(string url, bool point, float ppu, int hcount, int vcount, Action<Sprite[]> callback) { ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(LoadSprite(url, point, ppu, Mathf.Max(1, hcount), Mathf.Max(1, vcount), callback)); } [IteratorStateMachine(typeof(<LoadSprite>d__9))] private static IEnumerator LoadSprite(string url, bool point, float ppu, int hcount, int vcount, Action<Sprite[]> callback) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSprite>d__9(0) { url = url, point = point, ppu = ppu, hcount = hcount, vcount = vcount, callback = callback }; } public static void DoLoadSound(GameObject obj, string url) { ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(LoadSound(url, obj)); } [IteratorStateMachine(typeof(<LoadSound>d__11))] private static IEnumerator LoadSound(string url, [CanBeNull] GameObject obj = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSound>d__11(0) { url = url, obj = obj }; } public static string GetPath(string url) { string text = Path.GetInvalidFileNameChars().Aggregate(url, (string current, char c) => current.Replace(c, '_')); return StorageManager.DataPath + "Assets/" + text; } public static async Task TryDownloadAssets(StringConfigValue config, Text status, int downloadCount) { string fileType; if (config.GetTypeId().Equals("png_url")) { fileType = ".png"; } else if (config.GetTypeId().Equals("wav_url")) { fileType = ".wav"; } else { if (!config.GetTypeId().Equals("mp4_url")) { return; } fileType = ".mov"; } string url = config.GetValue(); DownloadingAssets++; bool b = await SaveFile(url, GetPath(url) + fileType); DownloadingAssets--; Downloaded++; status.text = "Downloading Assets...\n" + $"{Downloaded}/{downloadCount}"; if (!b) { Failed++; } } } public static class Settings { public class Keybind { [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private ConfigEntry<KeyCode> <code>P; public bool IsPressed => Input.GetKey(<code>P.Value); public bool WasPressed => Input.GetKeyDown(<code>P.Value); public Keybind(ConfigEntry<KeyCode> code) { <code>P = code; base..ctor(); } } public static Keybind ToggleEditor; public static Keybind Rotate; public static Keybind UnsafeRotation; public static Keybind Flip; public static Keybind ScaleUp; public static Keybind ScaleDown; public static Keybind SavePrefab; public static Keybind LockAxis; public static Keybind Undo; public static Keybind Redo; public static Keybind MultiSelect; public static Keybind Copy; public static Keybind Paste; public static Keybind Preview; public static Keybind Overwrite; public static Keybind GrabId; public static Keybind Blank; public static Keybind Cursor; public static Keybind Drag; public static Keybind Eraser; public static Keybind Pick; public static Keybind Reset; public static Keybind Lock; public static Keybind TileChanger; public static ConfigEntry<bool> LegacyEventSystem; public static ConfigEntry<bool> TestMode; public static ConfigEntry<bool> ShowRespawnPoint; public static ConfigEntry<int> SaveSlot; public static ConfigEntry<int> PreloadCount; public static ConfigEntry<Color> EditorBackgroundColour; public static void Init(ConfigFile config) { //IL_03bb: Unknown result type (might be due to invalid IL or missing references) ToggleEditor = new Keybind(config.Bind<KeyCode>("Keybinds", "EditToggle", (KeyCode)101, "Toggles Edit Mode")); Rotate = new Keybind(config.Bind<KeyCode>("Keybinds", "Rotate", (KeyCode)114, "Rotates the object on the cursor")); UnsafeRotation = new Keybind(config.Bind<KeyCode>("Keybinds", "UnsafeRotation", (KeyCode)308, "Allows rotating objects at any angle")); Flip = new Keybind(config.Bind<KeyCode>("Keybinds", "Flip", (KeyCode)102, "Flips the object on the cursor")); ScaleUp = new Keybind(config.Bind<KeyCode>("Keybinds", "ScaleUp", (KeyCode)61, "Increases the scale of the object on the cursor")); ScaleDown = new Keybind(config.Bind<KeyCode>("Keybinds", "ScaleDown", (KeyCode)45, "Decreases the scale of the object on the cursor")); SavePrefab = new Keybind(config.Bind<KeyCode>("Keybinds", "SavePrefab", (KeyCode)13, "Saves the object on the cursor as a prefab")); LockAxis = new Keybind(config.Bind<KeyCode>("Keybinds", "LockAxis", (KeyCode)303, "Locks the current X or Y axis to the axis of the last placed object")); Undo = new Keybind(config.Bind<KeyCode>("Keybinds", "Undo", (KeyCode)122, "Undoes the last action")); Redo = new Keybind(config.Bind<KeyCode>("Keybinds", "Redo", (KeyCode)121, "Redoes the last action")); MultiSelect = new Keybind(config.Bind<KeyCode>("Keybinds", "MultiSelect", (KeyCode)306, "Allows selecting multiple objects with the Drag tool")); Copy = new Keybind(config.Bind<KeyCode>("Keybinds", "Copy", (KeyCode)99, "Copies the current selection of objects")); Paste = new Keybind(config.Bind<KeyCode>("Keybinds", "Paste", (KeyCode)118, "Pastes the objects on the clipboard")); Preview = new Keybind(config.Bind<KeyCode>("Keybinds", "Preview", (KeyCode)112, "Preview objects affected by the Object Anchor")); Overwrite = new Keybind(config.Bind<KeyCode>("Keybinds", "Overwrite", (KeyCode)111, "Overwrites a clicked object with the one on your cursor")); GrabId = new Keybind(config.Bind<KeyCode>("Keybinds", "GrabId", (KeyCode)105, "Sets the ID option of the object on the cursor to the selected object's ID")); Blank = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "Blank", (KeyCode)0, "Clears your current selected item")); Cursor = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "Cursor", (KeyCode)0, "Sets your current selected item to the Cursor tool")); Drag = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "Drag", (KeyCode)0, "Sets your current selected item to the Drag tool")); Eraser = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "Eraser", (KeyCode)0, "Sets your current selected item to the Eraser tool")); Pick = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "Pick", (KeyCode)0, "Sets your current selected item to the Pick tool")); Reset = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "Reset", (KeyCode)0, "Sets your current selected item to the Reset tool")); TileChanger = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "TilemapChanger", (KeyCode)0, "Sets your current selected item to the Tilemap Changer tool")); Lock = new Keybind(config.Bind<KeyCode>("ToolHotkeys", "Lock", (KeyCode)0, "Locks an object in place so it cannot be edited until unlocked")); TestMode = config.Bind<bool>("Options", "TestMode", false, "Stops the game from storing persistent data in such as enemies being killed"); LegacyEventSystem = config.Bind<bool>("Options", "LegacyEventSystem", false, "Enables the Legacy objects tab and the Events and Listeners tabs"); ShowRespawnPoint = config.Bind<bool>("Options", "ShowRespawnPoint", false, "Adds an indicator showing your current hazard respawn point"); SaveSlot = config.Bind<int>("Options", "DownloadSlot", 4, "The save slot to download save files from the level sharer into"); PreloadCount = config.Bind<int>("Options", "PreloadCount", 4, "The maximum number of scenes that can be loaded at once during preloading"); EditorBackgroundColour = config.Bind<Color>("Options", "EditorBackgroundColour", new Color(0.1f, 0.1f, 0.1f), "The background colour of the script editor"); } } public static class StorageManager { [CompilerGenerated] private sealed class <>c__DisplayClass17_0 { public Text status; public int downloadCount; } [CompilerGenerated] private sealed class <>c__DisplayClass17_1 { public StringConfigValue config; public <>c__DisplayClass17_0 CS$<>8__locals1; internal Task <LoadLevelData>b__1() { return CustomAssetManager.TryDownloadAssets(config, CS$<>8__locals1.status, CS$<>8__locals1.downloadCount); } } [CompilerGenerated] private sealed class <LoadLevelData>d__17 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Dictionary<string, LevelData> levels; public string levelId; public Text status; private <>c__DisplayClass17_0 <>8__1; private float <startTime>5__2; private Dictionary<string, StringConfigValue> <downloads>5__3; private float <elapsed>5__4; private string <plural>5__5; private Dictionary<string, LevelData>.Enumerator <>s__6; private string <scene>5__7; private LevelData <data>5__8; private IEnumerator<StringConfigValue> <>s__9; private StringConfigValue <config>5__10; private string <cfg>5__11; private Dictionary<string, StringConfigValue>.ValueCollection.Enumerator <>s__12; private <>c__DisplayClass17_1 <>8__13; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadLevelData>d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>8__1 = null; <downloads>5__3 = null; <plural>5__5 = null; <>s__6 = default(Dictionary<string, LevelData>.Enumerator); <scene>5__7 = null; <data>5__8 = null; <>s__9 = null; <config>5__10 = null; <cfg>5__11 = null; <>s__12 = default(Dictionary<string, StringConfigValue>.ValueCollection.Enumerator); <>8__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass17_0(); <>8__1.status = status; WipeLevelData(); <startTime>5__2 = Time.realtimeSinceStartup; <downloads>5__3 = new Dictionary<string, StringConfigValue>(); <>s__6 = levels.GetEnumerator(); try { while (<>s__6.MoveNext()) { <>s__6.Current.Deconstruct(out var key, out var value); <scene>5__7 = key; <data>5__8 = value; <>s__9 = <data>5__8.Placements.SelectMany((ObjectPlacement obj) => obj.Config).OfType<StringConfigValue>().GetEnumerator(); try { while (<>s__9.MoveNext()) { <config>5__10 = <>s__9.Current; if (<config>5__10.GetTypeId().Contains("_url")) { <cfg>5__11 = <config>5__10.GetValue(); <downloads>5__3.TryAdd(<cfg>5__11, <config>5__10); <cfg>5__11 = null; <config>5__10 = null; } } } finally { if (<>s__9 != null) { <>s__9.Dispose(); } } <>s__9 = null; SaveScene(<scene>5__7, <data>5__8); <scene>5__7 = null; <data>5__8 = null; } } finally { ((IDisposable)<>s__6).Dispose(); } <>s__6 = default(Dictionary<string, LevelData>.Enumerator); CustomAssetManager.DownloadingAssets = 0; CustomAssetManager.Downloaded = 0; CustomAssetManager.Failed = 0; <>8__1.downloadCount = <downloads>5__3.Count; <>s__12 = <downloads>5__3.Values.GetEnumerator(); <>1__state = -3; goto IL_02a7; case 1: <>1__state = -3; goto IL_027a; case 2: <>1__state = -1; goto IL_02e8; case 3: { <>1__state = -1; break; } IL_027a: if (CustomAssetManager.DownloadingAssets > 4) { <>2__current = null; <>1__state = 1; return true; } Task.Run(() => CustomAssetManager.TryDownloadAssets(<>8__13.config, <>8__13.CS$<>8__locals1.status, <>8__13.CS$<>8__locals1.downloadCount)); <>8__13 = null; goto IL_02a7; IL_02a7: if (<>s__12.MoveNext()) { <>8__13 = new <>c__DisplayClass17_1(); <>8__13.CS$<>8__locals1 = <>8__1; <>8__13.config = <>s__12.Current; goto IL_027a; } <>m__Finally1(); <>s__12 = default(Dictionary<string, StringConfigValue>.ValueCollection.Enumerator); goto IL_02e8; IL_02e8: if (CustomAssetManager.Downloaded < <>8__1.downloadCount) { <>2__current = null; <>1__state = 2; return true; } <elapsed>5__4 = Time.realtimeSinceStartup - <startTime>5__2; if (<elapsed>5__4 < 1f) { <>2__current = (object)new WaitForSeconds(1f - <elapsed>5__4); <>1__state = 3; return true; } break; } LevelSharerUI.CurrentlyDownloading = false; LevelSharerUI.RefreshActiveOptions(); <plural>5__5 = ((CustomAssetManager.Failed == 1) ? "" : "s"); <>8__1.status.text = "Download Complete" + ((CustomAssetManager.Failed == 0) ? "" : $"\n{CustomAssetManager.Failed} asset{<plural>5__5} could not be downloaded"); return false; } 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__12).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static readonly LevelData.LevelDataConverter Ldc = new LevelData.LevelDataConverter(); internal static readonly ObjectPlacement.ObjectPlacementConverter Opc = new ObjectPlacement.ObjectPlacementConverter(); public static string DataPath; private static readonly Dictionary<string, List<IScheduledEdit>> ScheduledEdits = new Dictionary<string, List<IScheduledEdit>>(); public static void Init() { DataPath = Path.GetFullPath(Application.persistentDataPath + "/Architect/"); Directory.CreateDirectory(DataPath + "Scenes/"); Directory.CreateDirectory(DataPath + "Assets/"); Directory.CreateDirectory(DataPath + "ModAssets/"); typeof(GameManager).Hook("SaveGame", (Action<Action<GameManager, Action<bool>>, GameManager, Action<bool>>)delegate(Action<GameManager, Action<bool>> orig, GameManager self, Action<bool> callback) { SaveFavourites(FavouritesCategory.Favourites); SavePrefabs(PrefabsCategory.Prefabs); if (EditManager.IsEditing) { SaveScene(GameManager.instance.sceneName, PlacementManager.GetLevelData()); } foreach (var (scene, edits) in ScheduledEdits) { ApplyScheduledEdits(scene, edits); } ScheduledEdits.Clear(); orig(self, callback); }, typeof(Action<bool>)); } public static void SaveScene(string scene, LevelData level) { string path = DataPath + "Scenes/" + scene + ".architect.json"; if (File.Exists(path)) { File.Delete(path); } if (Extensions.IsNullOrEmpty<ObjectPlacement>((ICollection<ObjectPlacement>)level.Placements) && Extensions.IsNullOrEmpty<(int, int)>((ICollection<(int, int)>)level.TilemapChanges) && Extensions.IsNullOrEmpty<ScriptBlock>((ICollection<ScriptBlock>)level.ScriptBlocks)) { return; } string value = SerializeLevel(level, (Formatting)1); using FileStream stream = File.Create(path); using StreamWriter streamWriter = new StreamWriter(stream); streamWriter.Write(value); } public static LevelData LoadScene(string scene) { if (ScheduledEdits.Remove(scene, out var value)) { return ApplyScheduledEdits(scene, value); } string path = DataPath + "Scenes/" + scene + ".architect.json"; return File.Exists(path) ? DeserializeLevel(File.ReadAllText(path)) : new LevelData(new List<ObjectPlacement>(), new List<(int, int)>(), new List<ScriptBlock>()); } public static LevelData DeserializeLevel(string data) { return JsonConvert.DeserializeObject<LevelData>(data); } public static List<ObjectPlacement> DeserializePlacements(string data) { return JsonConvert.DeserializeObject<List<ObjectPlacement>>(data); } public static string SerializeLevel(LevelData level, Formatting formatting) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return JsonConvert.SerializeObject((object)level, formatting, (JsonConverter[])(object)new JsonConverter[2] { (JsonConverter)Ldc, (JsonConverter)Opc }); } public static string SerializePlacements(List<ObjectPlacement> placements) { return JsonConvert.SerializeObject((object)placements, (Formatting)1, (JsonConverter[])(object)new JsonConverter[1] { (JsonConverter)Opc }); } public static void SaveFavourites(List<string> favourites) { string path = DataPath + "favourites.json"; if (File.Exists(path)) { File.Delete(path); } string value = JsonConvert.SerializeObject((object)favourites); using FileStream stream = File.Create(path); using StreamWriter streamWriter = new StreamWriter(stream); streamWriter.Write(value); } public static List<string> LoadFavourites() { string path = DataPath + "favourites.json"; if (File.Exists(path)) { List<string> list = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(path)); if (list != null) { return list; } } return new List<string>(); } public static void SavePrefabs(List<PrefabObject> prefabs) { string path = DataPath + "prefabs.json"; if (File.Exists(path)) { File.Delete(path); } string value = SerializePlacements(prefabs.Select((PrefabObject obj) => obj.Placement).ToList()); using FileStream stream = File.Create(path); using StreamWriter streamWriter = new StreamWriter(stream); streamWriter.Write(value); } public static List<PrefabObject> LoadPrefabs() { string path = DataPath + "prefabs.json"; if (File.Exists(path)) { List<ObjectPlacement> list = DeserializePlacements(File.ReadAllText(path)); if (list != null) { return list.Select((ObjectPlacement obj) => new PrefabObject(obj)).ToList(); } } return new List<PrefabObject>(); } public static string SerializeAllScenes() { Dictionary<string, LevelData> dictionary = new Dictionary<string, LevelData>(); string[] files = Directory.GetFiles(DataPath + "Scenes/"); foreach (string path in files) { string fileName = Path.GetFileName(path); if (fileName.EndsWith(".architect.json")) { string text = fileName.Replace(".architect.json", ""); dictionary[text] = LoadScene(text); } } return JsonConvert.SerializeObject((object)dictionary, (Formatting)0, (JsonConverter[])(object)new JsonConverter[2] { (JsonConverter)Ldc, (JsonConverter)Opc }); } public static void WipeLevelData() { string[] files = Directory.GetFiles(DataPath + "Scenes/"); foreach (string path in files) { File.Delete(path); } string[] files2 = Directory.GetFiles(DataPath + "Assets/"); foreach (string path2 in files2) { File.Delete(path2); } CustomAssetManager.WipeAssets(); } [IteratorStateMachine(typeof(<LoadLevelData>d__17))] public static IEnumerator LoadLevelData(Dictionary<string, LevelData> levels, string levelId, Text status) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadLevelData>d__17(0) { levels = levels, levelId = levelId, status = status }; } public static void SaveApiKey([CanBeNull] string key) { string path = DataPath + "key.txt"; if (File.Exists(path)) { File.Delete(path); } if (key == null) { return; } using FileStream stream = File.Create(path); using StreamWriter streamWriter = new StreamWriter(stream); streamWriter.Write(key); } [CanBeNull] public static string LoadApiKey() { string path = DataPath + "key.txt"; return File.Exists(path) ? File.ReadAllText(path) : null; } public static void ScheduleEdit(string scene, IScheduledEdit edit) { if (!ScheduledEdits.TryGetValue(scene, out var value)) { List<IScheduledEdit> list2 = (ScheduledEdits[scene] = new List<IScheduledEdit>()); value = list2; } value.Add(edit); } public static LevelData ApplyScheduledEdits(string scene, List<IScheduledEdit> edits) { LevelData levelData = LoadScene(scene); foreach (IScheduledEdit edit in edits) { edit.ExecuteScheduled(levelData); } SaveScene(scene, levelData); return levelData; } public static void WipeScheduledEdits(string scene) { ScheduledEdits.Remove(scene); } } } namespace Architect.Storage.Sharer { public static class LevelSharerUI { private class EraseBtn : MonoBehaviour, IPointerDownHandler, IEventSystemHandler { public Action OnClick; public void OnPointerDown(PointerEventData eventData) { OnClick(); } } private enum SortBy { MostDownloads, Newest } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__32_1; public static UnityAction <>9__36_2; public static UnityAction <>9__39_0; public static UnityAction <>9__39_1; public static Func<Dictionary<string, string>, int> <>9__40_0; internal void <SetupSearchArea>b__32_1() { Task.Run((Func<Task?>)PerformSearch); } internal void <SetupLoginArea>b__36_2() { APIKey = null; RefreshActiveOptions(); } internal void <SetupLevelsArea>b__39_0() { _index--; if (_index < 0) { _index = _currentLevels.Count / 6; } RefreshCurrentLevels(); } internal void <SetupLevelsArea>b__39_1() { _index = (_index + 1) % ((_currentLevels.Count - 1) / 6 + 1); RefreshCurrentLevels(); } internal int <RefreshCurrentLevels>b__40_0(Dictionary<string, string> c) { return Convert.ToInt32(c["downloads"]); } } [CompilerGenerated] private sealed class <>c__DisplayClass26_0 { private sealed class <<SetupSwitchArea>g__DoErase|1>d : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public <>c__DisplayClass26_0 <>4__this; private float <time>5__1; private float <t>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <<SetupSwitchArea>g__DoErase|1>d(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; <time>5__1 = Time.time; break; case 1: <>1__state = -1; if (!Input.GetMouseButton(0)) { <>4__this.eraseImg.sprite = <>4__this.eraseAll; return false; } <t>5__2 = Time.time - <time>5__1; <>4__this.eraseImg.sprite = ((<t>5__2 > 2f) ? <>4__this.eraseAll1 : ((<t>5__2 > 1f) ? <>4__this.eraseAll2 : <>4__this.eraseAll3)); break; } if (Time.time - <time>5__1 < 3f) { <>2__current = null; <>1__state = 1; return true; } <>4__this.eraseImg.sprite = <>4__this.eraseAll; StorageManager.WipeLevelData(); PlacementManager.InvalidateScene(); 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 Image img; public Sprite closeEditor; public Sprite openEditor; public Image eraseImg; public Sprite eraseAll; public Sprite eraseAll1; public Sprite eraseAll2; public Sprite eraseAll3; internal void <SetupSwitchArea>b__0() { _viewing = !_viewing; if (_viewing) { img.sprite = closeEditor; ((MonoBehaviour)_uiManager).StartCoroutine(FadeGameTitle()); ((MonoBehaviour)_uiManager).StartCoroutine(_uiManager.FadeOutCanvasGroup(_uiManager.mainMenuScreen, true, false)); _status.text = "Warning!\n\nDownloading a level will overwrite any changes you have made yourself\nDownloading a save will overwrite save slot " + Settings.SaveSlot.Value; PerformSearch(); } else { img.sprite = openEditor; _levelSharerObj.SetActive(false); _backgroundObj.SetActive(false); _uiManager.UIGoToMainMenu(); } } internal void <SetupSwitchArea>b__2() { ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(DoErase()); [IteratorStateMachine(typeof(<<SetupSwitchArea>g__DoErase|1>d))] IEnumerator DoErase() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <<SetupSwitchArea>g__DoErase|1>d(0) { <>4__this = this }; } } } [CompilerGenerated] private sealed class <FadeGameTitle>d__28 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private SpriteRenderer <sprite>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeGameTitle>d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <sprite>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_00d3: 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_010c: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <sprite>5__1 = _uiManager.gameTitle; goto IL_00cd; case 1: <>1__state = -1; goto IL_00cd; case 2: { <>1__state = -1; return false; } IL_00cd: if ((double)<sprite>5__1.color.a > 0.0 && _viewing) { <sprite>5__1.color = new Color(<sprite>5__1.color.r, <sprite>5__1.color.g, <sprite>5__1.color.b, <sprite>5__1.color.a - Time.unscaledDeltaTime * 3.2f); <>2__current = null; <>1__state = 1; return true; } <sprite>5__1.color = new Color(<sprite>5__1.color.r, <sprite>5__1.color.g, <sprite>5__1.color.b, (float)((!_viewing) ? 1 : 0)); if (_viewing) { _levelSharerObj.SetActive(true); _backgroundObj.SetActive(true); } <>2__current = null; <>1__state = 2; return true; } } 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 <GetSprite>d__41 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Image image; public int pageIndex; public string url; private UnityWebRequest <www>5__1; private Texture2D <tex>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GetSprite>d__41(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <www>5__1 = null; <tex>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_00ba: 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_00c7: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <www>5__1 = UnityWebRequestTexture.GetTexture(url); <>2__current = <www>5__1.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if (_index != pageIndex) { return false; } if ((int)<www>5__1.result == 1) { <tex>5__2 = DownloadHandlerTexture.GetContent(<www>5__1); image.sprite = Sprite.Create(<tex>5__2, new Rect(0f, 0f, (float)((Texture)<tex>5__2).width, (float)((Texture)<tex>5__2).height), default(Vector2)); <tex>5__2 = 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(); } } private const float MENU_FADE_SPEED = 3.2f; private const int LEVELS_PER_PAGE = 6; public static bool CurrentlyDownloading; private static int _index; private static List<Dictionary<string, string>> _orderedCurrentLevels; private static List<Dictionary<string, string>> _currentLevels; private static readonly List<(Text, Text, Text, GameObject, GameObject, GameObject, GameObject, Image)> DownloadChoices = new List<(Text, Text, Text, GameObject, GameObject, GameObject, GameObject, Image)>(); [CanBeNull] private static string _apiKey = StorageManager.LoadApiKey(); private static GameObject _canvasObj; private static GameObject _levelSharerObj; private static GameObject _backgroundObj; private static UIManager _uiManager; private static bool _viewing; private static InputField _descriptionInput; private static InputField _creatorInput; private static Text _status; private static readonly List<Selectable> InteractableWhenLoggedIn = new List<Selectable>(); private static readonly List<Selectable> InteractableWhenLoggedOut = new List<Selectable>(); private static readonly List<Selectable> UninteractableWhenDownloading = new List<Selectable>(); private static SortBy _currentSortBy = SortBy.MostDownloads; [CanBeNull] public static string APIKey { get { return _apiKey; } set { StorageManager.SaveApiKey(value); _apiKey = value; } } public static void Init() { SetupCanvas(); SetupBackground(); SetupSwitchArea(); SetupSearchArea(); SetupLevelsArea(); SetupUploadArea(); SetupLoginArea(); RefreshActiveOptions(); } public static void Update() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)_uiManager)) { _uiManager = Object.FindAnyObjectByType<UIManager>(); if (!Object.op_Implicit((Object)(object)_uiManager)) { return; } } _canvasObj.SetActive((int)_uiManager.menuState == 1 && PreloadManager.HasPreloaded); } private static void SetupCanvas() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0085: 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_009d: 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) _canvasObj = new GameObject("[Architect] Level Sharer Canvas"); _canvasObj.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_canvasObj); _canvasObj.AddComponent<Canvas>().renderMode = (RenderMode)0; CanvasScaler val = _canvasObj.AddComponent<CanvasScaler>(); val.uiScaleMode = (ScaleMode)1; val.screenMatchMode = (ScreenMatchMode)1; _canvasObj.AddComponent<GraphicRaycaster>(); _levelSharerObj = new GameObject("Level Sharer"); _levelSharerObj.SetActive(false); RectTransform val2 = _levelSharerObj.AddComponent<RectTransform>(); val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; ((Transform)val2).SetParent(_canvasObj.transform, false); } private static void SetupBackground() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0057: Unknown result type (might be due to invalid IL or missing references) Image val = UIUtils.MakeImage("Background", _canvasObj, Vector2.op_Implicit(Vector3.zero), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(3000f, 3000f)); val.sprite = ResourceUtils.LoadSpriteResource("level_sharer_bg", (FilterMode)1); _backgroundObj = ((Component)val).gameObject; _backgroundObj.SetActive(false); _backgroundObj.transform.SetAsFirstSibling(); } private static void SetupSwitchArea() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f2: 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_0106: 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_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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass26_0 CS$<>8__locals0 = new <>c__DisplayClass26_0(); CS$<>8__locals0.openEditor = ResourceUtils.LoadSpriteResource("level_sharer_open", (FilterMode)1); CS$<>8__locals0.closeEditor = ResourceUtils.LoadSpriteResource("level_sharer_close", (FilterMode)1); Button val; (val, CS$<>8__locals0.img, _) = UIUtils.MakeButtonWithImage("Toggle Sharer UI", _canvasObj, Vector2.op_Implicit(new Vector3(-50f, -50f)), new Vector2(1f, 1f), new Vector2(1f, 1f), 220, 220); CS$<>8__locals0.img.sprite = CS$<>8__locals0.openEditor; UninteractableWhenDownloading.Add((Selectable)(object)val); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { _viewing = !_viewing; if (_viewing) { CS$<>8__locals0.img.sprite = CS$<>8__locals0.closeEditor; ((MonoBehaviour)_uiManager).StartCoroutine(FadeGameTitle()); ((MonoBehaviour)_uiManager).StartCoroutine(_uiManager.FadeOutCanvasGroup(_uiManager.mainMenuScreen, true, false)); _status.text = "Warning!\n\nDownloading a level will overwrite any changes you have made yourself\nDownloading a save will overwrite save slot " + Settings.SaveSlot.Value; PerformSearch(); } else { CS$<>8__locals0.img.sprite = CS$<>8__locals0.openEditor; _levelSharerObj.SetActive(false); _backgroundObj.SetActive(false); _uiManager.UIGoToMainMenu(); } }); (Button, Image, UIUtils.Label) tuple2 = UIUtils.MakeButtonWithImage("Erase Edits", _levelSharerObj, Vector2.op_Implicit(new Vector3(-50f, -140f)), new Vector2(1f, 1f), new Vector2(1f, 1f), 220, 220); Button item = tuple2.Item1; CS$<>8__locals0.eraseImg = tuple2.Item2; CS$<>8__locals0.eraseAll = ResourceUtils.LoadSpriteResource("erase_all", (FilterMode)1); CS$<>8__locals0.eraseAll3 = ResourceUtils.LoadSpriteResource("erase_all_3", (FilterMode)1); CS$<>8__locals0.eraseAll2 = ResourceUtils.LoadSpriteResource("erase_all_2", (FilterMode)1); CS$<>8__locals0.eraseAll1 = ResourceUtils.LoadSpriteResource("erase_all_1", (FilterMode)1); CS$<>8__locals0.eraseImg.sprite = CS$<>8__locals0.eraseAll; UninteractableWhenDownloading.Add((Selectable)(object)item); EraseBtn eraseBtn = ((Component)item).gameObject.AddComponent<EraseBtn>(); eraseBtn.OnClick = (Action)Delegate.Combine(eraseBtn.OnClick, (Action)delegate { ((MonoBehaviour)ArchitectPlugin.Instance).StartCoroutine(DoErase()); }); [IteratorStateMachine(typeof(<>c__DisplayClass26_0.<<SetupSwitchArea>g__DoErase|1>d))] IEnumerator DoErase() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass26_0.<<SetupSwitchArea>g__DoErase|1>d(0) { <>4__this = CS$<>8__locals0 }; } } [IteratorStateMachine(typeof(<FadeGameTitle>d__28))] private static IEnumerator FadeGameTitle() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FadeGameTitle>d__28(0); } private static void MakeTitleText(string text, int xPos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Text textComponent = UIUtils.MakeLabel(text, _levelSharerObj, new Vector2((float)xPos, -25f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), 80f, 80f, (HorizontalWrapMode)1).textComponent; textComponent.text = text; textComponent.fontSize = 18; textComponent.alignment = (TextAnchor)4; } private static InputField MakeTitleOption(string name, int xPos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) return UIUtils.MakeTextbox(name, _levelSharerObj, new Vector2((float)xPos, -50f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), 600f, 60f, 30).Item1; } private static void SetupSearchArea() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_011e: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown MakeTitleText("Name/Description", -220); MakeTitleText("Creator", 0); MakeTitleText("Sort By", 190); _descriptionInput = MakeTitleOption("Description Input", -220); _creatorInput = MakeTitleOption("Creator Input", 0); var (val, label) = UIUtils.MakeTextButton("Sort By Button", "Sort By", _levelSharerObj, new Vector2(189f, -50f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), hasOutline: true, new Vector2(300f, 60f)); label.textComponent.fontSize = 10; label.textComponent.text = GetSortByText(_currentSortBy); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { _currentSortBy = ((_currentSortBy != SortBy.Newest) ? SortBy.Newest : SortBy.MostDownloads); label.textComponent.text = GetSortByText(_currentSortBy); _index = 0; RefreshCurrentLevels(); }); var (val2, label2) = UIUtils.MakeTextButton("Search Button", "Search", _levelSharerObj, new Vector2(0f, -80f), new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), hasOutline: true, new Vector2(140f, 60f)); label2.textComponent.fontSize = 14; ButtonClickedEvent onClick = val2.onClick; object obj = <>c.<>9__32_1; if (obj == null) { UnityAction val3 = delegate { Task.Run((Func<Task?>)PerformSearch); }; <>c.<>9__32_1 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } private static Button MakeLoginButton(string text, Vector2 pos) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) return UIUtils.MakeTextButton(text, text, _levelSharerObj, pos, Vector2.zero, Vector2.zero, hasOutline: true, new Vector2(85f, 40f)).Item1; } private static InputField MakeLoginBox(string name, Vector2 pos) { //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) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return UIUtils.MakeTextbox(name, _levelSharerObj, pos, Vector2.zero, Vector2.zero, 300f, 40f, 24).Item1; } private static void