Decompiled source of EvenMoreMaps v0.7.6
plugins/EvenMoreMaps.dll
Decompiled a month 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameEvent; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.7.6.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EvenMoreMaps { public class Ambience : MonoBehaviour { public string kind; public float param; private Vector3 basePos; private Vector3 baseScale; private Vector3 baseWorld; private float fallTop; private float fallBottom; private float ka; private float kb; private float tileW; private Quaternion baseRot; private SpriteRenderer sr; private Color baseColor; private float seed; public static void Attach(GameObject go, string kind) { Ambience ambience = go.AddComponent<Ambience>(); string[] array = kind.Split(new char[1] { ':' }); ambience.kind = array[0]; if (array.Length > 1) { float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out ambience.param); } } private void Start() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) basePos = ((Component)this).transform.localPosition; baseScale = ((Component)this).transform.localScale; baseRot = ((Component)this).transform.localRotation; sr = ((Component)this).GetComponent<SpriteRenderer>(); if ((Object)(object)sr != (Object)null) { baseColor = sr.color; } seed = (float)Mathf.Abs(((Object)this).name.GetHashCode() % 1000) * 0.137f; if (kind == "scroll") { float num; if (!((Object)(object)sr != (Object)null)) { num = 1f; } else { Bounds bounds = ((Renderer)sr).bounds; num = Mathf.Max(0.01f, ((Bounds)(ref bounds)).size.x); } tileW = num; } if (kind == "fall") { baseWorld = ((Component)this).transform.position; StageData data = StageBuilder.Data; if (data != null && data.camera != null) { Rect val = data.WorldRect(data.camera); fallTop = ((Rect)(ref val)).yMax + 2f; fallBottom = ((Rect)(ref val)).yMin - 2f; } else { fallTop = baseWorld.y + 20f; fallBottom = baseWorld.y - 20f; } ka = Mathf.Repeat(seed * 7.31f, 1f); kb = Mathf.Repeat(seed * 3.17f, 1f); } } private void Update() { //IL_08fe: Unknown result type (might be due to invalid IL or missing references) //IL_0924: Unknown result type (might be due to invalid IL or missing references) //IL_0929: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0cf1: Unknown result type (might be due to invalid IL or missing references) //IL_0cf6: Unknown result type (might be due to invalid IL or missing references) //IL_0d07: Unknown result type (might be due to invalid IL or missing references) //IL_0752: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0ec3: Unknown result type (might be due to invalid IL or missing references) //IL_0ef1: Unknown result type (might be due to invalid IL or missing references) //IL_0ef6: Unknown result type (might be due to invalid IL or missing references) //IL_099e: Unknown result type (might be due to invalid IL or missing references) //IL_09ca: Unknown result type (might be due to invalid IL or missing references) //IL_09cf: Unknown result type (might be due to invalid IL or missing references) //IL_09e0: Unknown result type (might be due to invalid IL or missing references) //IL_09f3: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_07eb: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_0f59: Unknown result type (might be due to invalid IL or missing references) //IL_0a5e: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_08ae: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_08e7: Unknown result type (might be due to invalid IL or missing references) //IL_08ec: Unknown result type (might be due to invalid IL or missing references) //IL_0de3: Unknown result type (might be due to invalid IL or missing references) //IL_0e10: Unknown result type (might be due to invalid IL or missing references) //IL_0e15: Unknown result type (might be due to invalid IL or missing references) //IL_0e26: Unknown result type (might be due to invalid IL or missing references) //IL_0e4e: Unknown result type (might be due to invalid IL or missing references) //IL_0e53: Unknown result type (might be due to invalid IL or missing references) //IL_0eb1: Unknown result type (might be due to invalid IL or missing references) //IL_0d2d: Unknown result type (might be due to invalid IL or missing references) //IL_0672: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0aaf: Unknown result type (might be due to invalid IL or missing references) //IL_0ade: Unknown result type (might be due to invalid IL or missing references) //IL_0ae3: Unknown result type (might be due to invalid IL or missing references) //IL_0af4: Unknown result type (might be due to invalid IL or missing references) //IL_0b07: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_0d8e: Unknown result type (might be due to invalid IL or missing references) //IL_0b62: Unknown result type (might be due to invalid IL or missing references) //IL_0bd8: Unknown result type (might be due to invalid IL or missing references) //IL_0beb: Unknown result type (might be due to invalid IL or missing references) //IL_0bfc: Unknown result type (might be due to invalid IL or missing references) //IL_0c13: Unknown result type (might be due to invalid IL or missing references) //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c68: Unknown result type (might be due to invalid IL or missing references) float num = Time.time + seed; string text = kind; if (text == null) { return; } switch (text.Length) { case 7: switch (text[3]) { case 'c': if (text == "flicker") { float num5 = 0.85f + 0.1f * Mathf.PerlinNoise(num * 3.1f, seed) + 0.05f * Mathf.Sin(num * 17f); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * num5); } ((Component)this).transform.localScale = baseScale * (0.97f + 0.05f * num5); } break; case 't': if (text == "flutter") { ((Component)this).transform.localRotation = baseRot * Quaternion.Euler(0f, 0f, 7f * Mathf.Sin(num * 2.3f) + 3f * Mathf.Sin(num * 5.3f + seed)); ((Component)this).transform.localScale = new Vector3(baseScale.x * (1f + 0.08f * Mathf.Sin(num * 6.1f + seed)), baseScale.y, baseScale.z); } break; case 'n': if (text == "twinkle") { float num2 = 3f + 3f * Mathf.Repeat(seed * 3.37f, 1f); float num3 = Mathf.Repeat(Time.time / num2 + seed, 1f); float num4 = ((num3 < 0.12f) ? Mathf.Sin((float)Math.PI * num3 / 0.12f) : 0f); ((Component)this).transform.localScale = baseScale * (0.3f + 0.9f * num4); ((Component)this).transform.localRotation = baseRot * Quaternion.Euler(0f, 0f, 40f * num3); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * num4); } } break; } break; case 3: switch (text[0]) { case 'b': if (text == "bob") { ((Component)this).transform.localPosition = basePos + new Vector3(0f, 0.25f * Mathf.Sin(num * 1.3f), 0f); } break; case 'f': if (text == "fly") { float num25 = Mathf.Repeat(basePos.x + 15f + Time.time * 1.6f, 85f) - 15f; ((Component)this).transform.localPosition = new Vector3(num25, basePos.y + 0.6f * Mathf.Sin(num * 0.4f) + 0.15f * Mathf.Sin(num * 2.1f), basePos.z); float num26 = ((Mathf.Repeat(num, 5f) < 1.6f) ? Mathf.Cos(num * 9f) : 1f); ((Component)this).transform.localScale = new Vector3(baseScale.x, baseScale.y * (0.35f + 0.65f * num26), baseScale.z); } break; } break; case 4: switch (text[3]) { case 'y': if (text == "sway") { ((Component)this).transform.localRotation = baseRot * Quaternion.Euler(0f, 0f, 1.2f * Mathf.Sin(num * 0.9f)); } break; case 'n': if (text == "spin") { ((Component)this).transform.localRotation = baseRot * Quaternion.Euler(0f, 0f, Mathf.Repeat(param * num, 360f)); } break; case 'w': if (text == "flow") { float num16 = Mathf.Repeat(Time.time / 1.8f + param, 1f); ((Component)this).transform.localPosition = basePos + new Vector3(0f, -1.4f * num16, 0f); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * Mathf.Sin((float)Math.PI * num16)); } } break; case 't': if (text == "mist") { ((Component)this).transform.localPosition = basePos + new Vector3(4f * Mathf.Sin(num * 0.08f), 0.2f * Mathf.Sin(num * 0.3f), 0f); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * (0.6f + 0.4f * Mathf.Sin(num * 0.13f))); } } break; case 'l': if (text == "fall") { float num21 = ((param > 0f) ? param : 0.8f); float num22 = fallTop - fallBottom; float num23 = fallBottom + Mathf.Repeat(baseWorld.y - fallBottom - Time.time * num21, num22); float num24 = baseWorld.x + (0.2f + 0.3f * ka) * Mathf.Sin(num * (0.6f + 0.7f * kb)) + 0.06f * Mathf.Sin(num * 2.3f); ((Component)this).transform.position = new Vector3(num24, num23, baseWorld.z); ((Component)this).transform.localRotation = baseRot * Quaternion.Euler(0f, 0f, 18f * Mathf.Sin(num * (0.8f + kb))); } break; case 'p': if (text == "drip") { float num17 = 2.5f + 2f * Mathf.Repeat(seed * 4.19f, 1f); float num18 = Mathf.Repeat(Time.time / num17 + seed, 1f) * num17; float num19 = num17 - 0.7f; float num20 = Mathf.Max(0f, num18 - num19); ((Component)this).transform.localPosition = basePos + new Vector3(0f, -11f * num20 * num20, 0f); ((Component)this).transform.localScale = baseScale * ((num20 > 0f) ? 1f : (0.4f + 0.6f * num18 / num19)); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * (1f - Mathf.Clamp01(num20 / 0.7f))); } } break; case 'm': if (text == "swim") { float num13 = ((param > 0f) ? param : 0.35f); float num14 = num + basePos.x * 0.73f + basePos.y * 0.41f; ((Component)this).transform.localPosition = basePos + new Vector3(num13 * Mathf.Sin(num14 * 0.4f), 0.07f * Mathf.Sin(num14 * 1.3f), 0f); ((Component)this).transform.localRotation = baseRot * Quaternion.Euler(0f, 0f, 2.5f * Mathf.Sin(num14 * 0.4f + 1f)); float num15 = Mathf.Sin(num14 * 4.5f); ((Component)this).transform.localScale = new Vector3(baseScale.x * (1f + 0.04f * num15), baseScale.y * (1f - 0.02f * num15), baseScale.z); } break; } break; case 5: switch (text[0]) { case 'p': if (text == "pulse" && (Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * (0.65f + 0.35f * Mathf.Sin(num * 1.1f))); } break; case 'c': if (text == "cloud") { ((Component)this).transform.localPosition = basePos + new Vector3(2.5f * Mathf.Sin(num * 0.045f + seed), 0f, 0f); } break; case 'g': if (text == "glide") { float num11 = ((param > 0f) ? param : 1.6f); float num12 = Mathf.Repeat(basePos.x + 15f + Time.time * num11, 85f) - 15f; ((Component)this).transform.localPosition = new Vector3(num12, basePos.y + 0.7f * Mathf.Sin(num * 0.35f) + 0.12f * Mathf.Sin(num * 1.7f), basePos.z); ((Component)this).transform.localRotation = baseRot * Quaternion.Euler(0f, 0f, 4f * Mathf.Cos(num * 0.35f)); } break; case 'e': if (text == "ember") { float num6 = 2.2f + 1.8f * Mathf.Repeat(seed * 5.13f, 1f); float num7 = Mathf.Repeat(Time.time / num6 + seed, 1f); float num8 = 3.5f + 3f * Mathf.Repeat(seed * 2.71f, 1f); ((Component)this).transform.localPosition = basePos + new Vector3(0.45f * Mathf.Sin(num7 * 7f + seed) * num7, num8 * num7, 0f); ((Component)this).transform.localScale = baseScale * (1f - 0.6f * num7); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * Mathf.Sin((float)Math.PI * Mathf.Min(1f, num7 * 1.3f))); } } break; case 's': if (text == "steam") { float num9 = 4f + 2.5f * Mathf.Repeat(seed * 6.07f, 1f); float num10 = Mathf.Repeat(Time.time / num9 + seed, 1f); ((Component)this).transform.localPosition = basePos + new Vector3(0.6f * Mathf.Sin(num10 * 4f + seed) * num10, 3f * num10, 0f); ((Component)this).transform.localScale = baseScale * (0.5f + 1.1f * num10); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * Mathf.Sin((float)Math.PI * num10)); } } break; case 'd': if (text == "drift") { ((Component)this).transform.localPosition = basePos + new Vector3(1.5f * Mathf.Sin(num * 0.21f), 0.3f * Mathf.Sin(num * 1.1f), 0f); if ((Object)(object)sr != (Object)null) { sr.color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a * (0.55f + 0.35f * Mathf.Sin(num * 0.37f))); } } break; } break; case 6: if (text == "scroll") { ((Component)this).transform.localPosition = basePos + new Vector3(Mathf.Repeat(Time.time * param, tileW), 0f, 0f); } break; } } } public class DevTools : MonoBehaviour { public static DevTools Instance; private float nextPoll; private string lastStageFile; private DateTime lastStageWrite; private GameObject overlay; public static readonly string[] DefaultTourScenes = new string[9] { "Farm", "Iceberg", "JungleTemple", "Waterfall", "WindMill", "CrumblingBridge", "Volcano", "Pier", "Raft" }; private bool touring; private static string[] TourScenes => (from s in Plugin.DevTourScenes.Value.Split(new char[1] { ',' }) select s.Trim() into s where s.Length > 0 select s).ToArray(); private void Awake() { Instance = this; } public void LogLater(float delay, Func<string> msg) { ((MonoBehaviour)this).StartCoroutine(LogAfter(delay, msg)); } private IEnumerator LogAfter(float delay, Func<string> msg) { yield return (object)new WaitForSecondsRealtime(delay); Safe(delegate { Plugin.Log.LogInfo((object)msg()); }); } public void OnSceneLoaded(Scene scene) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((from s in Plugin.DevDumpScenes.Value.Split(new char[1] { ',' }) select s.Trim()).Contains(((Scene)(ref scene)).name)) { ((MonoBehaviour)this).StartCoroutine(DumpLater(scene, 2f)); } } private IEnumerator DumpLater(Scene scene, float delay) { //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) yield return (object)new WaitForSecondsRealtime(delay); if (((Scene)(ref scene)).isLoaded) { Safe(delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SceneDumper.Dump(scene); }); } } public static void TakeScreenshot(string tag) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string text = $"shot_{((Scene)(ref activeScene)).name}_{tag}_{DateTime.Now:HHmmss}.png"; string text2 = Path.Combine(Plugin.DevDir, text); ScreenCapture.CaptureScreenshot(text2); File.WriteAllText(Path.Combine(Plugin.DevDir, "last_screenshot.txt"), text); Plugin.Log.LogInfo((object)("Screenshot -> " + text2)); } private void Update() { if (!Plugin.DevMode.Value) { return; } if (Input.GetKeyDown((KeyCode)286)) { ((MonoBehaviour)this).StartCoroutine(Tour()); } if (Input.GetKeyDown((KeyCode)287)) { ReloadStage("key"); } if (Input.GetKeyDown((KeyCode)288)) { ((MonoBehaviour)this).StartCoroutine(QuickLaunch()); } if (Input.GetKeyDown((KeyCode)289)) { ToggleOverlay(); } if (Input.GetKeyDown((KeyCode)290)) { Safe(delegate { //IL_0000: Unknown result type (might be due to invalid IL or missing references) SceneDumper.Dump(SceneManager.GetActiveScene()); }); } if (Input.GetKeyDown((KeyCode)291)) { TakeScreenshot("key"); } if (!(Time.unscaledTime >= nextPoll)) { return; } nextPoll = Time.unscaledTime + 0.5f; string text = ((StageBuilder.StageDir == null) ? null : Path.Combine(StageBuilder.StageDir, "stage.json")); if (text == null || !File.Exists(text)) { return; } DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(text); if (text != lastStageFile) { lastStageFile = text; lastStageWrite = lastWriteTimeUtc; } else if (lastWriteTimeUtc != lastStageWrite) { lastStageWrite = lastWriteTimeUtc; if (StageBuilder.Active) { ReloadStage("hot"); } } } private void ReloadStage(string why) { if (StageBuilder.Active) { StageBuilder.Rebuild(); if ((Object)(object)overlay != (Object)null) { Object.Destroy((Object)(object)overlay); overlay = null; ToggleOverlay(); } } } private IEnumerator Tour() { if (touring) { yield break; } touring = true; CustomMap home = QuickLaunchTarget(); if (home == null) { Plugin.Log.LogWarning((object)"Tour: no enabled map"); touring = false; yield break; } Scene activeScene; if ((Object)(object)Object.FindObjectOfType<GameControl>() == (Object)null && (Object)(object)Object.FindObjectOfType<LevelSelectController>() != (Object)null) { yield return QuickLaunch(); float tl = Time.realtimeSinceStartup; while (true) { activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != home.HostScene) || !(Time.realtimeSinceStartup - tl < 30f)) { break; } yield return null; } yield return (object)new WaitForSecondsRealtime(4f); } foreach (string scene in TourScenes.Concat(new string[1] { home.HostScene })) { GameControl val = Object.FindObjectOfType<GameControl>(); if ((Object)(object)val == (Object)null || !((NetworkBehaviour)val).isServer) { Plugin.Log.LogWarning((object)"Tour: start it from inside a level, as host"); break; } Plugin.Log.LogInfo((object)("Tour: -> " + scene)); val.CallRpcStartFadingOut(false, scene); float tl = Time.realtimeSinceStartup; while (true) { activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != scene) || !(Time.realtimeSinceStartup - tl < 30f)) { break; } yield return null; } activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != scene) { Plugin.Log.LogWarning((object)("Tour: " + scene + " did not load")); break; } float[] array = new float[3] { 2.5f, 3.5f, 5f }; foreach (float num in array) { yield return (object)new WaitForSecondsRealtime(num); List<Renderer> hidden = (from r in Object.FindObjectsOfType<PartyBox>().SelectMany((PartyBox b) => ((Component)b).GetComponentsInChildren<Renderer>()).Concat(Object.FindObjectsOfType<PiecePlacementCursor>().SelectMany((PiecePlacementCursor c) => ((Component)c).GetComponentsInChildren<Renderer>())) where r.enabled select r).ToList(); hidden.ForEach(delegate(Renderer r) { r.enabled = false; }); TakeScreenshot("tour"); yield return null; yield return (object)new WaitForEndOfFrame(); yield return null; hidden.ForEach(delegate(Renderer r) { if ((Object)(object)r != (Object)null) { r.enabled = true; } }); } } touring = false; } private void ToggleOverlay() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025a: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)overlay != (Object)null) { Object.Destroy((Object)(object)overlay); overlay = null; return; } overlay = new GameObject("CS_ColliderOverlay"); Material sharedMaterial = new Material(Shader.Find("Sprites/Default")); int num = 0; foreach (KeyValuePair<Collider2D, CollisionTag> allTag in CollisionTag.AllTags) { Collider2D key = allTag.Key; if (!((Object)(object)key == (Object)null) && ((Behaviour)key).enabled && ((Component)key).gameObject.activeInHierarchy && !((Object)(object)((Component)key).GetComponentInParent<Character>() != (Object)null) && !((Object)(object)((Component)key).GetComponentInParent<PiecePlacementCursor>() != (Object)null)) { Tag bitMask = allTag.Value.bitMask; Color val = Color.cyan; if ((bitMask & 0x100) != 0) { val = Color.red; } else if ((bitMask & 0x80000) != 0) { val = Color.magenta; } else if ((bitMask & 0x400000) != 0) { val = Color.green; } else if ((bitMask & 0x200) != 0) { val = Color.yellow; } else if ((bitMask & 0x1000) != 0) { val = Color.white; } else if ((bitMask & 0x80) == 0) { ((Color)(ref val))..ctor(1f, 0.5f, 0f); } Bounds bounds = key.bounds; GameObject val2 = new GameObject("o"); val2.transform.SetParent(overlay.transform, false); LineRenderer val3 = val2.AddComponent<LineRenderer>(); ((Renderer)val3).sharedMaterial = sharedMaterial; val3.useWorldSpace = true; val3.loop = true; val3.positionCount = 4; val3.SetPositions((Vector3[])(object)new Vector3[4] { new Vector3(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).min.y), new Vector3(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).min.y), new Vector3(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).max.y), new Vector3(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.y) }); float startWidth = (val3.endWidth = 0.08f); val3.startWidth = startWidth; Color startColor = (val3.endColor = val); val3.startColor = startColor; ((Renderer)val3).sortingLayerName = "UI 1"; num++; } } Plugin.Log.LogInfo((object)$"Collider overlay on ({num} colliders)"); } private static CustomMap QuickLaunchTarget() { string value = Plugin.DevQuickLaunchMap.Value; return (string.IsNullOrEmpty(value) ? null : MapRegistry.Get(value)) ?? MapRegistry.Enabled.FirstOrDefault(); } private IEnumerator QuickLaunch() { LevelSelectController lsc = Object.FindObjectOfType<LevelSelectController>(); if ((Object)(object)lsc == (Object)null || !lsc.HostIsLoaded) { Plugin.Log.LogWarning((object)"F7: not in a loaded Treehouse (host)."); yield break; } Plugin.Log.LogInfo((object)$"F7: game mode {GameSettings.GetInstance().GameMode}"); NetworkLobbyPlayer[] lobbySlots = ((NetworkLobbyManager)LobbyManager.instance).lobbySlots; foreach (NetworkLobbyPlayer obj in lobbySlots) { LobbyPlayer val = (LobbyPlayer)(object)((obj is LobbyPlayer) ? obj : null); if (!((Object)(object)val == (Object)null) && (int)val.PickedAnimal == 0) { Character free = (from c in Object.FindObjectsOfType<Character>() where !c.Picked && (int)c.CharacterSprite > 0 orderby (int)c.CharacterSprite select c).FirstOrDefault(); if ((Object)(object)free == (Object)null) { break; } Plugin.Log.LogInfo((object)$"F7: picking {free.CharacterSprite} for lobby player"); val.RequestPickCharacter(free); float t = 0f; while (!free.Picked && t < 3f) { t += Time.unscaledDeltaTime; yield return null; } } } if (!((NetworkLobbyManager)LobbyManager.instance).lobbySlots.OfType<LobbyPlayer>().Any((LobbyPlayer p) => (Object)(object)p != (Object)null && (int)p.PickedAnimal > 0)) { Plugin.Log.LogWarning((object)"F7: no player with a character — join with a controller/keyboard first."); yield break; } CustomMap map = QuickLaunchTarget(); CustomMapDoor? customMapDoor = Object.FindObjectsOfType<CustomMapDoor>().FirstOrDefault((CustomMapDoor d) => d.Map == map); LevelPortal val2 = ((customMapDoor != null) ? ((Component)customMapDoor).GetComponent<LevelPortal>() : null); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)("F7: no door for map " + (map?.Id ?? "(none)"))); yield break; } Plugin.Log.LogInfo((object)("F7: launching " + map.Name + " via its door")); lsc.LaunchLevel(val2); } public static void Safe(Action a) { try { a(); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } public class AmbientSound : MonoBehaviour { public string sound; public string stopSound; public float volume; private bool alive = true; private void Start() { if (!string.IsNullOrEmpty(sound)) { Play(); if (volume < 0.999f) { FxSound.SetVolume(((Component)this).gameObject, volume); } } } private void Play() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (alive) { AkSoundEngine.PostEvent(sound, ((Component)this).gameObject, 1u, new EventCallback(OnEnd), (object)null); } } private void OnEnd(object cookie, AkCallbackType type, AkCallbackInfo info) { if (alive && (Object)(object)this != (Object)null) { Play(); } } private void OnDestroy() { alive = false; if (!string.IsNullOrEmpty(sound)) { if (!string.IsNullOrEmpty(stopSound)) { AkSoundEngine.PostEvent(stopSound, ((Component)this).gameObject); } else { AkSoundEngine.StopAll(((Component)this).gameObject); } } } } public sealed class AmbientFeature : ListFeature { public override string Key => "ambient"; protected override void BuildItem(Dictionary<string, object> a, FeatureContext ctx) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) AmbientSound ambientSound = StageFx.Child(ctx.Fx, "Sound_" + a.S("name"), ctx.Data.World(a.F("x"), a.F("y"))).AddComponent<AmbientSound>(); ambientSound.sound = a.S("sound"); ambientSound.stopSound = a.S("stopSound"); ambientSound.volume = a.F("volume"); } } public class Bubbles : MonoBehaviour { private sealed class Bubble { public SpriteRenderer r; public float x; public float y; public float size; public float speed; public float phase; public float age; } public Sprite sprite; public string layer; public int order; public Color color; public float x0; public float x1; public float bottom; public float top; public float rate; public float sizeMin; public float sizeMax; public float speedMin; public float speedMax; public float offsetY; private readonly List<Bubble> live = new List<Bubble>(); private readonly Stack<SpriteRenderer> spare = new Stack<SpriteRenderer>(); private float due; private void Start() { if ((Object)(object)sprite == (Object)null || rate <= 0f || top <= bottom) { ((Behaviour)this).enabled = false; return; } float num = (top - bottom) / Mathf.Max(0.05f, (speedMin + speedMax) / 2f); int num2 = Mathf.Min(200, Mathf.RoundToInt(rate * num)); for (int i = 0; i < num2; i++) { Spawn(Random.Range(bottom, top)); } } private void Update() { //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; due += rate * deltaTime; while (due >= 1f && live.Count < 400) { due -= 1f; Spawn(bottom); } for (int num = live.Count - 1; num >= 0; num--) { Bubble bubble = live[num]; bubble.age += deltaTime; bubble.y += bubble.speed * deltaTime; if (bubble.y + bubble.size / 2f >= top) { ((Component)bubble.r).gameObject.SetActive(false); spare.Push(bubble.r); live.RemoveAt(num); } else { float num2 = 0.04f * Mathf.Sin(bubble.age * 5f + bubble.phase); ((Component)bubble.r).transform.position = new Vector3(bubble.x + num2, bubble.y + offsetY, 0f); bubble.r.color = new Color(color.r, color.g, color.b, color.a * Mathf.Clamp01(bubble.age / 0.25f)); } } } private void Spawn(float y) { //IL_0085: 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_0168: Unknown result type (might be due to invalid IL or missing references) float num = Random.Range(sizeMin, sizeMax); float num2 = x0 + num / 2f; float num3 = x1 - num / 2f; if (num3 < num2) { num2 = (num3 = (x0 + x1) / 2f); } SpriteRenderer val = ((spare.Count > 0) ? spare.Pop() : NewRenderer()); ((Component)val).gameObject.SetActive(true); ((Component)val).transform.localScale = new Vector3(num, num, 1f); Bubble bubble = new Bubble { r = val, x = Random.Range(num2, num3), y = y, size = num, speed = Random.Range(speedMin, speedMax), phase = Random.value * 6.3f }; bubble.age = ((y > bottom) ? 1f : 0f); ((Component)val).transform.position = new Vector3(bubble.x, bubble.y + offsetY, 0f); val.color = new Color(color.r, color.g, color.b, (bubble.age > 0f) ? color.a : 0f); live.Add(bubble); } private SpriteRenderer NewRenderer() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("bubble"); val.transform.SetParent(((Component)this).transform, false); SpriteRenderer obj = val.AddComponent<SpriteRenderer>(); obj.sprite = sprite; ((Renderer)obj).sortingLayerName = layer; ((Renderer)obj).sortingOrder = order; return obj; } } public sealed class VesselsFeature : ListFeature { public override string Key => "vessels"; protected override void BuildItem(Dictionary<string, object> v, FeatureContext ctx) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) StageData data = ctx.Data; string text = ctx.Source.S("bubbleSprite"); float[] array = v.FA("poly"); if (array == null || array.Length < 4) { throw new Exception("fx.json: vessel " + v.S("name") + " has no poly"); } if (string.IsNullOrEmpty(text)) { throw new Exception("fx.json: vessels need a bubbleSprite"); } float num = float.MaxValue; float num2 = float.MinValue; for (int i = 0; i < array.Length; i += 2) { num = Mathf.Min(num, array[i]); num2 = Mathf.Max(num2, array[i]); } Bubbles bubbles = StageFx.Child(ctx.Fx, "Bubbles_" + v.S("name"), data.World(0f, 0f)).AddComponent<Bubbles>(); bubbles.sprite = StageBuilder.LoadSprite(text, new Vector2(0.5f, 0.5f), 1f, 0, unitWide: true); bubbles.x0 = num + data.origin[0]; bubbles.x1 = num2 + data.origin[0]; bubbles.top = v.F("top") + data.origin[1]; bubbles.bottom = v.F("bottom") + data.origin[1]; bubbles.layer = v.S("layer"); bubbles.order = v.I("order"); float[] array2 = v.FA("color"); bubbles.color = ((array2 != null && array2.Length >= 3) ? StageBuilder.ToColor(array2) : Color.white); bubbles.rate = v.F("rate"); float[] array3 = v.FA("size"); if (array3 != null && array3.Length == 2) { bubbles.sizeMin = array3[0]; bubbles.sizeMax = array3[1]; } float[] array4 = v.FA("speed"); if (array4 != null && array4.Length == 2) { bubbles.speedMin = array4[0]; bubbles.speedMax = array4[1]; } ctx.Vessels.Add(bubbles); } } public class Conveyor : MonoBehaviour { public Collider2D belt; public float speed; public float direction; public Transform[] rollers = (Transform[])(object)new Transform[0]; public float rollerRadius; private void FixedUpdate() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown GameControl val = (((Object)(object)LobbyManager.instance != (Object)null) ? LobbyManager.instance.CurrentGameController : null); if ((Object)(object)belt == (Object)null || (Object)(object)val == (Object)null || val.CurrentPlayerQueue == null) { return; } Modifiers instance = Modifiers.GetInstance(); float num = speed * (((Object)(object)instance != (Object)null) ? instance.RotatorSpeed : 1f); foreach (GamePlayer item in val.CurrentPlayerQueue) { Character val2 = (((Object)(object)item != (Object)null) ? item.CharacterInstance : null); if (!((Object)(object)val2 == (Object)null) && !val2.Waiting && val2.OnGround && OnBelt(val2)) { val2.ApplyPhysicsModifier(new PhysicsModifier((ModType)11, num, new Vector2(direction, 0f), ((Component)this).gameObject)); } } } private bool OnBelt(Character c) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0084: 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_009a: Unknown result type (might be due to invalid IL or missing references) CharacterRaycaster feet = c.Feet; if ((Object)(object)feet == (Object)null || (Object)(object)feet.raycastStartAnchor == (Object)null || (Object)(object)feet.raycastEndAnchor == (Object)null) { return false; } float num = feet.raycastLength * Modifiers.GetInstance().CharacterRelativeScale + 0.05f; bool queriesHitTriggers = Physics2D.queriesHitTriggers; Physics2D.queriesHitTriggers = false; try { for (int i = 0; i < 3; i++) { RaycastHit2D val = Physics2D.Raycast(Vector2.op_Implicit(Vector3.Lerp(feet.raycastStartAnchor.position, feet.raycastEndAnchor.position, (float)i / 2f)), Vector2.op_Implicit(feet.raycastDirection), num, ((LayerMask)(ref feet.layerMask)).value); if ((Object)(object)((RaycastHit2D)(ref val)).collider == (Object)(object)belt) { return true; } } } finally { Physics2D.queriesHitTriggers = queriesHitTriggers; } return false; } private void Update() { float num = (0f - direction) * speed / rollerRadius * 57.29578f * Time.deltaTime; Transform[] array = rollers; foreach (Transform val in array) { if ((Object)(object)val != (Object)null) { val.Rotate(0f, 0f, num); } } } } public sealed class ConveyorsFeature : ListFeature { public override string Key => "conveyors"; protected override void BuildItem(Dictionary<string, object> c, FeatureContext ctx) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Transform val = StageFx.Collider(ctx.Colliders, c.S("collider")); Conveyor conveyor = StageFx.Child(ctx.Fx, "Conveyor_" + ((Object)val).name, Vector2.op_Implicit(val.position)).AddComponent<Conveyor>(); conveyor.belt = ((Component)val).GetComponent<Collider2D>(); conveyor.speed = c.F("speed"); conveyor.direction = Mathf.Sign(c.F("direction")); conveyor.rollers = (from g in StageFx.Art(c.S("rollers")) select g.transform).ToArray(); conveyor.rollerRadius = Mathf.Max(0.05f, c.F("rollerRadius")); } } public sealed class FeatureContext { public StageData Data; public Transform Root; public Transform Colliders; public Dictionary<string, object> Source; public readonly List<Bubbles> Vessels = new List<Bubbles>(); private Transform fx; public Transform Fx { get { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fx == (Object)null) { fx = new GameObject("Fx").transform; fx.SetParent(Root, false); } return fx; } } public bool HasFx => (Object)(object)fx != (Object)null; } public abstract class Feature { public abstract string Key { get; } public abstract void Build(object cfg, FeatureContext ctx); } public abstract class ObjectFeature : Feature { public override void Build(object cfg, FeatureContext ctx) { if (cfg is Dictionary<string, object> d) { Build(d, ctx); } } protected abstract void Build(Dictionary<string, object> d, FeatureContext ctx); } public abstract class ListFeature : Feature { public override void Build(object cfg, FeatureContext ctx) { if (!(cfg is List<object> list)) { return; } foreach (object item in list) { Dictionary<string, object> d = item as Dictionary<string, object>; if (d != null) { DevTools.Safe(delegate { BuildItem(d, ctx); }); } } } protected abstract void BuildItem(Dictionary<string, object> d, FeatureContext ctx); } public static class Features { public static readonly Feature[] All = new Feature[14] { new PressFeature(), new SyncFramesFeature(), new SwayFeature(), new VesselsFeature(), new ZapFeature(), new ConveyorsFeature(), new RisingFeature(), new AmbientFeature(), new SplashFeature(), new ShapesFeature(), new GearsFeature(), new SpinFeature(), new MusicStateFeature(), new SweepFeature() }; private static readonly HashSet<string> StageKeys = new HashSet<string> { "version", "name", "map", "host", "ppu", "origin", "camera", "cursor", "thumbnail", "killY", "start1", "start2", "startZone", "goal", "cursorSpawn", "unlockSpawns", "graybox", "colliders", "sprites", "sortingOrder", "light", "gradient", "placement", "outside" }; private static Dictionary<string, object> spec; private static Dictionary<string, object> Spec { get { if (spec != null) { return spec; } using (Stream stream = typeof(Features).Assembly.GetManifestResourceStream("features.json")) { using StreamReader streamReader = new StreamReader(stream); spec = (MiniJson.Parse(streamReader.ReadToEnd()) as Dictionary<string, object>) ?? new Dictionary<string, object>(); } return spec; } } private static Dictionary<string, object> SpecOf(string key) { return Spec.O(key) ?? new Dictionary<string, object>(); } public static object Merged(string key, object given) { Dictionary<string, object> d = SpecOf(key).O("defaults"); if (d == null) { return given; } if (given is Dictionary<string, object> a) { return Merge(d, a); } if (given is List<object> source) { return source.Select((object x) => (!(x is Dictionary<string, object> a2)) ? x : Merge(d, a2)).ToList(); } return given; } private static Dictionary<string, object> Merge(Dictionary<string, object> d, Dictionary<string, object> a) { Dictionary<string, object> dictionary = new Dictionary<string, object>(d); foreach (KeyValuePair<string, object> item in a) { dictionary[item.Key] = item.Value; } foreach (KeyValuePair<string, object> item2 in d) { if (!(item2.Value is Dictionary<string, object> dictionary2)) { continue; } Dictionary<string, object> dictionary3 = new Dictionary<string, object>(dictionary2); Dictionary<string, object> dictionary4 = a.O(item2.Key); if (dictionary4 != null) { foreach (KeyValuePair<string, object> item3 in dictionary4) { dictionary3[item3.Key] = item3.Value; } } dictionary[item2.Key] = dictionary3; } return dictionary; } public static void BuildAll(StageData data, Transform root, Dictionary<string, object> fx) { Dictionary<string, object> dictionary = data.raw ?? new Dictionary<string, object>(); FeatureContext ctx = new FeatureContext { Data = data, Root = root, Colliders = root.Find("Colliders") }; Feature[] all = All; foreach (Feature f in all) { Dictionary<string, object> dictionary2 = (dictionary.ContainsKey(f.Key) ? dictionary : ((fx != null && fx.ContainsKey(f.Key)) ? fx : null)); if (dictionary2 != null && dictionary2[f.Key] != null) { ctx.Source = dictionary2; object cfg = Merged(f.Key, dictionary2[f.Key]); DevTools.Safe(delegate { f.Build(cfg, ctx); }); } } HashSet<string> known = new HashSet<string>(All.Select((Feature feature) => feature.Key)); all = All; for (int i = 0; i < all.Length; i++) { string[] array = SpecOf(all[i].Key).SA("with"); foreach (string item in array) { known.Add(item); } } foreach (string item2 in dictionary.Keys.Where((string k) => !known.Contains(k) && !StageKeys.Contains(k))) { Plugin.Log.LogWarning((object)("stage.json '" + item2 + "': not a feature or setting the plugin knows - ignored")); } if (fx == null) { return; } foreach (string item3 in fx.Keys.Where((string k) => !known.Contains(k))) { Plugin.Log.LogWarning((object)("fx.json '" + item3 + "': not a feature the plugin knows - ignored")); } Plugin.Log.LogInfo((object)$"fx.json: {ctx.Fx.childCount} effect object(s)"); } } public abstract class RoundTimer : PhaseClock { protected float RoundTime; protected static bool IsPlay(GamePhase p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)p != 2) { return (int)p == 4; } return true; } protected override void OnPhase(GamePhase from, GamePhase to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (IsPlay(from) != IsPlay(to)) { RoundTime = 0f; } } protected void Tick(float dt) { if (base.Playing && !base.Paused) { RoundTime += dt; } } } public static class Escapement { public static float At(float t, float[] tick, out float rate) { rate = 1f; if (tick == null || tick.Length != 2 || tick[0] <= 0f || tick[1] <= 0f) { return t; } float num = tick[0]; float num2 = Mathf.Min(tick[1], num); float num3 = Mathf.Floor(t / num); float num4 = Mathf.Clamp01((t - num3 * num) / num2); rate = ((num4 < 1f) ? (num * (6f * num4 - 6f * num4 * num4) / num2) : 0f); return num * (num3 + num4 * num4 * (3f - 2f * num4)); } } public class GearSet : RoundTimer { public class Part { public string name; public string tickSound; public float speed; public float carry; public float[] tick; public GameObject go; public Rigidbody2D body; public PolygonCollider2D shape; public float sign; public float omega; public int lastTick = -1; } public readonly List<Part> Parts = new List<Part>(); private int carried; private int squeezed; private void FixedUpdate() { //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) if (Parts.Count == 0) { return; } Tick(Time.fixedDeltaTime); bool flag = base.Playing && RoundTime > 0f; foreach (Part part2 in Parts) { float rate; float num = Escapement.At(RoundTime, part2.tick, out rate); part2.body.MoveRotation(part2.sign * part2.speed * num); part2.omega = (flag ? (part2.sign * part2.speed * rate) : 0f); float num2 = ((part2.tick != null && part2.tick.Length == 2) ? part2.tick[0] : 0f); if (flag && num2 > 0f) { int num3 = Mathf.FloorToInt(RoundTime / num2); if (num3 != part2.lastTick) { part2.lastTick = num3; FxSound.Post(part2.tickSound, part2.go); } } else { part2.lastTick = -1; } } if (!flag) { return; } GameControl val = (((Object)(object)LobbyManager.instance != (Object)null) ? LobbyManager.instance.CurrentGameController : null); if ((Object)(object)val == (Object)null || val.CurrentPlayerQueue == null) { return; } List<Part> list = new List<Part>(); foreach (GamePlayer item in val.CurrentPlayerQueue) { Character val2 = (((Object)(object)item != (Object)null) ? item.CharacterInstance : null); if ((Object)(object)val2 == (Object)null || val2.Waiting) { continue; } list.Clear(); ColliderDistance2D deepest = default(ColliderDistance2D); foreach (Part part3 in Parts) { if (Touching(val2, part3, ref deepest)) { list.Add(part3); } } if (list.Count == 0) { continue; } Vector2 val3 = Vector2.op_Implicit(((Component)val2).transform.position); if (list.Count == 1) { Part part = list[0]; if (part.omega != 0f) { val2.ApplyPhysicsModifier(new PhysicsModifier((ModType)1, part.omega, Vector2.op_Implicit(part.go.transform.position), part.go)); } if (++carried <= 3) { Plugin.Log.LogInfo((object)$"Gear {part.name} carries a player at {val3.x:0.0}, {val3.y:0.0}"); } if (((ColliderDistance2D)(ref deepest)).isValid && ((ColliderDistance2D)(ref deepest)).isOverlapped && ((ColliderDistance2D)(ref deepest)).distance < -0.3f) { Transform transform = ((Component)val2).transform; transform.position += Vector2.op_Implicit(((ColliderDistance2D)(ref deepest)).pointA - ((ColliderDistance2D)(ref deepest)).pointB); } continue; } Vector2 val4 = Vector2.zero; foreach (Part item2 in list) { Vector2 val5 = val3 - Vector2.op_Implicit(item2.go.transform.position); val4 += new Vector2(0f - val5.y, val5.x) * (item2.omega * ((float)Math.PI / 180f)); } if (!(((Vector2)(ref val4)).sqrMagnitude < 0.0001f)) { Transform transform2 = ((Component)val2).transform; transform2.position += Vector2.op_Implicit(((Vector2)(ref val4)).normalized * Mathf.Max(0.12f, ((Vector2)(ref val4)).magnitude * Time.fixedDeltaTime * 1.5f)); if (++squeezed <= 3) { Plugin.Log.LogInfo((object)$"Gears squeeze a player out at {val3.x:0.0}, {val3.y:0.0}"); } } } } private static bool Touching(Character ch, Part p, ref ColliderDistance2D deepest) { //IL_004e: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) bool result = false; Collider2D[] array = (Collider2D[])(object)new Collider2D[2] { ch.LowerBodyTrigger, ch.UpperBodyTrigger }; foreach (Collider2D val in array) { if ((Object)(object)val == (Object)null || !((Behaviour)val).enabled || !((Component)val).gameObject.activeInHierarchy) { continue; } ColliderDistance2D val2 = val.Distance((Collider2D)(object)p.shape); if (((ColliderDistance2D)(ref val2)).isValid) { if (((ColliderDistance2D)(ref val2)).distance <= p.carry) { result = true; } if (((ColliderDistance2D)(ref val2)).isOverlapped && (!((ColliderDistance2D)(ref deepest)).isValid || ((ColliderDistance2D)(ref val2)).distance < ((ColliderDistance2D)(ref deepest)).distance)) { deepest = val2; Vector2 pointA = ((ColliderDistance2D)(ref val2)).pointA; ((ColliderDistance2D)(ref deepest)).pointA = ((ColliderDistance2D)(ref val2)).pointB; ((ColliderDistance2D)(ref deepest)).pointB = pointA; } } } return result; } } public sealed class GearsFeature : ListFeature { private GearSet set; public override string Key => "gears"; public override void Build(object cfg, FeatureContext ctx) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) set = StageFx.Child(ctx.Fx, "Gears", Vector2.zero).AddComponent<GearSet>(); base.Build(cfg, ctx); } protected override void BuildItem(Dictionary<string, object> d, FeatureContext ctx) { //IL_005d: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) float[] array = d.FA("outline"); string text = d.S("art"); if (array == null || array.Length < 6) { throw new Exception("fx.json gear '" + text + "': needs an outline of at least 3 points"); } float[] array2 = d.FA("center"); Vector2 val = ((array2 != null && array2.Length == 2) ? ctx.Data.World(array2) : ctx.Data.World(0f, 0f)); GearSet.Part part = new GearSet.Part { name = (text ?? set.Parts.Count.ToString()), speed = d.F("speed"), carry = d.F("carry"), tick = d.FA("tick"), tickSound = d.S("tickSound"), sign = (d.B("clockwise", def: true) ? (-1f) : 1f) }; part.go = StageFx.Child(((Component)set).transform, "Gear_" + part.name, val); part.go.layer = 8; part.go.tag = "Solid"; part.body = part.go.AddComponent<Rigidbody2D>(); part.body.bodyType = (RigidbodyType2D)1; part.body.interpolation = (RigidbodyInterpolation2D)1; part.body.sleepMode = (RigidbodySleepMode2D)0; part.body.useFullKinematicContacts = true; part.shape = part.go.AddComponent<PolygonCollider2D>(); Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length / 2]; for (int i = 0; i < array3.Length; i++) { array3[i] = new Vector2(array[2 * i], array[2 * i + 1]); } part.shape.SetPath(0, array3); part.go.AddComponent<CollisionTag>().bitMask = (Tag)128; List<GameObject> list = StageFx.Art(text).ToList(); foreach (GameObject item in list) { item.transform.SetParent(part.go.transform, true); } float num = d.F("noBuild"); if (num > 0f) { GameObject obj = StageFx.Child(((Component)set).transform, "GearNoBuild_" + part.name, val); CircleCollider2D obj2 = obj.AddComponent<CircleCollider2D>(); obj2.radius = num; ((Collider2D)obj2).isTrigger = true; obj.AddComponent<CollisionTag>().bitMask = (Tag)4194304; } set.Parts.Add(part); string arg = ((part.tick != null && part.tick.Length == 2) ? $"ticking every {part.tick[0]}s" : "smoothly"); Plugin.Log.LogInfo((object)($"Gear {part.name} at {val.x}, {val.y}: {array3.Length} outline points, {part.speed} deg/s " + string.Format("{0} {1}, {2} art piece(s)", (part.sign < 0f) ? "clockwise" : "anticlockwise", arg, list.Count))); } } public class Spin : RoundTimer { public float speed; public float[] tick; protected override void Update() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) base.Update(); Tick(Time.deltaTime); ((Component)this).transform.localRotation = Quaternion.Euler(0f, 0f, speed * Escapement.At(RoundTime, tick, out var _)); } } public sealed class SpinFeature : ListFeature { public override string Key => "spin"; protected override void BuildItem(Dictionary<string, object> s, FeatureContext ctx) { //IL_0043: 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) string text = s.S("art"); float[] array = s.FA("pivot"); GameObject val = StageFx.Child(ctx.Fx, "Spin_" + text, (array != null && array.Length == 2) ? ctx.Data.World(array) : ctx.Data.World(0f, 0f)); foreach (GameObject item in StageFx.Art(text).ToList()) { item.transform.SetParent(val.transform, true); } Spin spin = val.AddComponent<Spin>(); spin.speed = s.F("speed"); spin.tick = s.FA("tick"); } } public class MusicState : MonoBehaviour { public string group; public string state; public string reset; private void Start() { Set(state); } private void OnDestroy() { Set(reset); } private void Set(string s) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(group) && !string.IsNullOrEmpty(s)) { AkSoundEngine.SetState(group, s); } } } public sealed class MusicStateFeature : ObjectFeature { public override string Key => "musicState"; protected override void Build(Dictionary<string, object> d, FeatureContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) MusicState musicState = StageFx.Child(ctx.Fx, "MusicState", Vector2.zero).AddComponent<MusicState>(); musicState.group = d.S("group"); musicState.state = d.S("state"); musicState.reset = d.S("reset"); Plugin.Log.LogInfo((object)("Music state " + musicState.group + " = " + musicState.state + " (back to " + musicState.reset + " after)")); } } public class Press : PhaseClock { public float cx; public float width; public float open; public float closed; public float top; public float period; public float first; public float warn; public float slam; public float hold; public float rise; public float windup; public float inset; public float lead; public float dustFps; public bool shake; public string warnSound; public string slamSound; public string impactSound; public string hitSound; public string riseSound; public string restSound; public Rigidbody2D ram; public BoxCollider2D hit; public Transform art; public SpriteRenderer[] lampOn = (SpriteRenderer[])(object)new SpriteRenderer[0]; public SpriteRenderer[] lampOff = (SpriteRenderer[])(object)new SpriteRenderer[0]; public SpriteRenderer[] steam = (SpriteRenderer[])(object)new SpriteRenderer[0]; public SpriteRenderer[][] dust = new SpriteRenderer[0][]; public SpriteRenderer debugRam; public SpriteRenderer debugHit; private const int Rest = 0; private const int Warn = 1; private const int Slam = 2; private const int Hold = 3; private const int Rise = 4; private const float SteamLife = 0.9f; private const float KillHold = 0.06f; private const float Steady = 0.15f; private float fixedT; private int state = -1; private Color[] lampOnColor; private Color[] lampOffColor; private Color[] steamColor; private Color[][] dustColor; private Vector3[] steamHome; private Vector3[] steamScale; private bool Cycling => base.Playing; protected override void Start() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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) base.Start(); lampOnColor = Opaque(lampOn); lampOffColor = Opaque(lampOff); steamColor = Opaque(steam); dustColor = new Color[dust.Length][]; for (int i = 0; i < dust.Length; i++) { dustColor[i] = Opaque(dust[i]); } steamHome = (Vector3[])(object)new Vector3[steam.Length]; steamScale = (Vector3[])(object)new Vector3[steam.Length]; for (int j = 0; j < steam.Length; j++) { steamHome[j] = ((Component)steam[j]).transform.position; steamScale[j] = ((Component)steam[j]).transform.localScale; } SpriteRenderer[] array = lampOn; foreach (SpriteRenderer obj in array) { obj.color = Clear(obj.color); } array = steam; foreach (SpriteRenderer obj2 in array) { obj2.color = Clear(obj2.color); } SpriteRenderer[][] array2 = dust; for (int k = 0; k < array2.Length; k++) { array = array2[k]; foreach (SpriteRenderer obj3 in array) { obj3.color = Clear(obj3.color); } } Plugin.Log.LogInfo((object)($"Press: {width:0.##} wide, {open - closed:0.##} stroke, slams every {period}s; art lamps " + $"{lampOn.Length}/{lampOff.Length}, dust {dust.Length} frames, steam {steam.Length}")); } private float Cycle(float t) { float num = t - (first - warn); if (!Cycling || !(num >= 0f)) { return -1f; } return Mathf.Repeat(num, period); } private int StateAt(float c) { if (!(c < 0f)) { if (!(c < warn)) { if (!(c < warn + slam)) { if (!(c < warn + slam + hold)) { if (!(c < warn + slam + hold + rise)) { return 0; } return 4; } return 3; } return 2; } return 1; } return 0; } private float Face(float c) { if (c < 0f) { return open; } if (c < warn) { return open + windup * Smooth(Mathf.Clamp01((c / warn - 0.5f) * 2f)); } if (c < warn + slam) { float num = (c - warn) / slam; float num2 = open + windup; return num2 - (num2 - closed) * num * num; } if (c < warn + slam + hold) { return closed; } if (c < warn + slam + hold + rise) { return closed + (open - closed) * Smooth((c - warn - slam - hold) / rise); } return open; } private static float Smooth(float t) { return t * t * (3f - 2f * t); } protected override void OnPhase(GamePhase from, GamePhase to) { //IL_0032: 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_0068: Unknown result type (might be due to invalid IL or missing references) fixedT = 0f; state = 0; if ((Object)(object)ram != (Object)null) { ram.position = new Vector2(cx, open); ((Component)ram).transform.position = new Vector3(cx, open, ((Component)ram).transform.position.z); } if ((Object)(object)hit != (Object)null) { ((Behaviour)hit).enabled = false; } } private void FixedUpdate() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ram == (Object)null || (Object)(object)hit == (Object)null) { return; } if (base.Paused) { ((Behaviour)hit).enabled = false; if ((Object)(object)debugHit != (Object)null) { ((Renderer)debugHit).enabled = false; } return; } fixedT += Time.fixedDeltaTime; float num = Cycle(fixedT); float num2 = Face(num); ram.MovePosition(new Vector2(cx, num2)); int num3 = StateAt(num); if (num3 != state) { Enter(num3, state); } bool flag = num3 switch { 3 => num - warn - slam < 0.06f, 2 => true, _ => false, }; if (flag) { float num4 = Mathf.Max(lead, 2.5f * Time.fixedDeltaTime); float num5 = Mathf.Max(closed - 0.05f, Face(num + num4) - 0.05f); float num6 = num2 + 0.4f; ((Component)hit).transform.position = new Vector3(cx, num6, 0f); ((Collider2D)hit).offset = new Vector2(0f, (0f - (num6 - num5)) * 0.5f); hit.size = new Vector2(Mathf.Max(0.1f, width - 2f * inset), Mathf.Max(0.05f, num6 - num5)); } ((Behaviour)hit).enabled = flag && base.Playing; if ((Object)(object)debugHit != (Object)null) { ((Renderer)debugHit).enabled = flag; ((Component)debugHit).transform.localPosition = Vector2.op_Implicit(((Collider2D)hit).offset); ((Component)debugHit).transform.localScale = new Vector3(hit.size.x, hit.size.y, 1f); debugHit.color = new Color(1f, 0.25f, 0.2f, base.Playing ? 0.85f : 0.35f); } } private void Enter(int s, int from) { state = s; if (!Cycling) { return; } switch (s) { case 1: FxSound.Post(warnSound, ((Component)this).gameObject); break; case 2: FxSound.Post(slamSound, ((Component)this).gameObject); break; case 3: { FxSound.Post(impactSound, ((Component)this).gameObject); FxSound.Post(hitSound, ((Component)this).gameObject); if (!shake || !base.Playing) { break; } LobbyManager instance = LobbyManager.instance; if (instance != null) { ZoomCamera currentZoomCamera = instance.GetCurrentZoomCamera(); if (currentZoomCamera != null) { currentZoomCamera.shakeCamera(); } } break; } case 4: FxSound.Post(riseSound, ((Component)this).gameObject); break; case 0: if (from == 4) { FxSound.Post(restSound, ((Component)this).gameObject); } break; } } protected override void Update() { base.Update(); float c = Cycle(PhaseTime); int s = StateAt(c); UpdateLamp(c, s); UpdateShiver(c, s); UpdateDust(c); UpdateSteam(c); } private void UpdateLamp(float c, int s) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) float num = 0f; switch (s) { case 1: num = ((c > warn - 0.15f || Mathf.Repeat(3f * c + 4.5f * c * c / warn, 1f) < 0.5f) ? 1f : 0f); break; case 2: case 3: num = 1f; break; case 4: num = Mathf.Clamp01(1f - 2f * (c - warn - slam - hold) / rise); break; } for (int i = 0; i < lampOn.Length; i++) { lampOn[i].color = WithAlpha(lampOnColor[i], num); } for (int j = 0; j < lampOff.Length; j++) { lampOff[j].color = WithAlpha(lampOffColor[j], 1f - num); } } private void UpdateShiver(float c, int s) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)art == (Object)null)) { float num = ((s == 1) ? (c / warn) : 0f); art.localPosition = new Vector3(0.03f * num * num * Mathf.Sin(c * 70f), 0f, 0f); } } private void UpdateDust(float c) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) float num = c - warn - slam; int num2 = ((c >= 0f && num >= 0f) ? Mathf.FloorToInt(num * dustFps) : (-1)); for (int i = 0; i < dust.Length; i++) { for (int j = 0; j < dust[i].Length; j++) { dust[i][j].color = ((i == num2) ? dustColor[i][j] : Clear(dustColor[i][j])); } } } private void UpdateSteam(float c) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < steam.Length; i++) { SpriteRenderer val = steam[i]; float num = c - warn - slam - 0.05f * (float)i; if (c < 0f || num < 0f || num > 0.9f) { val.color = Clear(steamColor[i]); continue; } float num2 = num / 0.9f; float num3 = Mathf.Sign(steamHome[i].x - cx); ((Component)val).transform.position = steamHome[i] + new Vector3(num3 * 0.8f * Mathf.Sqrt(num2), 1.2f * num2, 0f); ((Component)val).transform.localScale = steamScale[i] * (0.6f + 0.9f * Mathf.Sqrt(num2)); val.color = WithAlpha(steamColor[i], steamColor[i].a * Mathf.Clamp01(num / 0.08f) * (1f - num2 * num2)); } } protected override void OnDestroy() { base.OnDestroy(); if (!string.IsNullOrEmpty(warnSound + slamSound + impactSound + hitSound + riseSound + restSound)) { AkSoundEngine.StopAll(((Component)this).gameObject); } } private static Color[] Opaque(SpriteRenderer[] rs) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[rs.Length]; for (int i = 0; i < rs.Length; i++) { array[i] = new Color(rs[i].color.r, rs[i].color.g, rs[i].color.b, 1f); } return array; } private static Color WithAlpha(Color c, float a) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, a); } private static Color Clear(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, 0f); } } public sealed class PressFeature : ObjectFeature { public override string Key => "press"; protected override void Build(Dictionary<string, object> d, FeatureContext ctx) { //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_064c: Unknown result type (might be due to invalid IL or missing references) StageData data = ctx.Data; float[] array = d.FA("x"); if (array == null || array.Length != 2) { return; } Dictionary<string, object> d2 = d.O("art") ?? new Dictionary<string, object>(); float num = Mathf.Min(array[0], array[1]) + data.origin[0]; float num2 = Mathf.Max(array[0], array[1]) + data.origin[0]; float num3 = d.F("open") + data.origin[1]; float num4 = d.F("closed") + data.origin[1]; float num5 = d.F("top") + data.origin[1]; if (!(num4 < num3) || !(num3 < num5) || num2 - num < 0.5f) { Plugin.Log.LogWarning((object)string.Format("Press: needs closed < open < top and a ram wider than 0.5 (got {0}, {1}, {2})", d.F("closed"), d.F("open"), d.F("top"))); return; } float num6 = (num + num2) * 0.5f; float num7 = num2 - num; float num8 = num5 - num4; GameObject val = new GameObject("Press"); val.transform.SetParent(ctx.Root, false); val.transform.position = new Vector3(num6, num4, 0f); GameObject val2 = new GameObject("PressRam"); val2.layer = 8; val2.tag = "Solid"; val2.transform.SetParent(val.transform, false); val2.transform.position = new Vector3(num6, num3, 0f); Rigidbody2D val3 = val2.AddComponent<Rigidbody2D>(); val3.bodyType = (RigidbodyType2D)1; val3.interpolation = (RigidbodyInterpolation2D)1; val3.sleepMode = (RigidbodySleepMode2D)0; BoxCollider2D obj = val2.AddComponent<BoxCollider2D>(); obj.size = new Vector2(num7, num8); ((Collider2D)obj).offset = new Vector2(0f, num8 * 0.5f); val2.AddComponent<CollisionTag>().bitMask = (Tag)d.I("mask", 262272); GameObject val4 = new GameObject("PressHit"); val4.layer = 18; val4.tag = "Hazard"; val4.transform.SetParent(val.transform, false); val4.transform.position = new Vector3(num6, num3, 0f); BoxCollider2D val5 = val4.AddComponent<BoxCollider2D>(); ((Collider2D)val5).isTrigger = true; ((Behaviour)val5).enabled = false; val5.size = new Vector2(Mathf.Max(0.1f, num7 - 2f * d.F("inset")), 0.1f); val4.AddComponent<CollisionTag>().bitMask = (Tag)256; Transform transform = new GameObject("PressArt").transform; transform.SetParent(val2.transform, false); SpriteRenderer[] array2 = StageFx.Renderers(d2.S("ram")); SpriteRenderer[] array3 = array2; for (int i = 0; i < array3.Length; i++) { ((Component)array3[i]).transform.SetParent(transform, true); } Press press = val.AddComponent<Press>(); press.cx = num6; press.width = num7; press.open = num3; press.closed = num4; press.top = num5; press.period = Mathf.Max(0.5f, d.F("period")); press.warn = Mathf.Max(0.05f, d.F("warn")); press.first = Mathf.Max(press.warn, d.F("first")); press.slam = Mathf.Max(0.06f, d.F("slam")); press.hold = Mathf.Max(0.1f, d.F("hold")); press.rise = Mathf.Max(0.05f, d.F("rise")); press.windup = Mathf.Max(0f, d.F("windup")); press.inset = Mathf.Clamp(d.F("inset"), 0f, num7 * 0.4f); press.lead = Mathf.Max(0f, d.F("lead")); press.dustFps = Mathf.Max(1f, d.F("dustFps")); press.shake = d.B("shake"); press.warnSound = d.S("warnSound"); press.slamSound = d.S("slamSound"); press.impactSound = d.S("impactSound"); press.hitSound = d.S("hitSound"); press.riseSound = d.S("riseSound"); press.restSound = d.S("restSound"); press.ram = val3; press.hit = val5; press.art = transform; press.lampOn = StageFx.Renderers(d2.S("lampOn")); press.lampOff = StageFx.Renderers(d2.S("lampOff")); press.steam = StageFx.Renderers(d2.S("steam")); press.dust = StageBuilder.FrameGroups(d2.S("dust")); if (data.graybox || d.B("debug")) { press.debugRam = StageBuilder.DebugBox(val2.transform, new Vector2(0f, num8 * 0.5f), new Vector2(num7, num8), new Color(0.55f, 0.6f, 0.7f, data.graybox ? 1f : 0.45f)); press.debugHit = StageBuilder.DebugBox(val4.transform, Vector2.zero, Vector2.one, new Color(1f, 0.25f, 0.2f, 0.85f)); } if (array2.Length == 0 && !data.graybox) { Plugin.Log.LogWarning((object)("Press: no sprite file starts with '" + d2.S("ram") + "'")); } } } public class RisingWater : PhaseClock { public Transform water; public Transform[] art = (Transform[])(object)new Transform[0]; public Bubbles[] bubbles = new Bubbles[0]; public float delay; public float speed; public float accel; public float maxRise; public float drainSpeed; public float soundEvery; public string sound; private Vector3 waterBase; private Vector3 selfBase; private Vector3[] artBase; private float flood; private float nextSound; public float Rise { get; private set; } protected override void Start() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: 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) base.Start(); waterBase = water.position; selfBase = ((Component)this).transform.position; artBase = (Vector3[])(object)new Vector3[art.Length]; for (int i = 0; i < art.Length; i++) { artBase[i] = art[i].localPosition; } } protected override void OnPhase(GamePhase from, GamePhase to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)to == 2 || (int)to == 4) { flood = 0f; Rise = 0f; nextSound = delay; } } private static bool RunStarted(GamePhase phase) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)phase != 4) { return true; } VersusControl val = (VersusControl)(((Object)(object)LobbyManager.instance != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val == (Object)null)) { return val.runStarted; } return true; } protected override void Update() { //IL_001b: 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) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) base.Update(); if (base.Paused) { return; } if (base.Playing) { if (RunStarted(Phase)) { flood += Time.deltaTime; } float num = flood - delay; Rise = ((num <= 0f) ? 0f : Mathf.Min(maxRise, speed * num + 0.5f * accel * num * num)); if (num > 0f && Rise < maxRise && flood >= nextSound) { FxSound.Post(sound, ((Component)this).gameObject); nextSound = flood + soundEvery; } } else { Rise = Mathf.Max(0f, Rise - drainSpeed * Time.deltaTime); } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, Rise, 0f); if ((Object)(object)water != (Object)null) { water.position = waterBase + val; } ((Component)this).transform.position = selfBase + val; for (int i = 0; i < art.Length; i++) { if ((Object)(object)art[i] != (Object)null) { art[i].localPosition = artBase[i] + val; } } Bubbles[] array = this.bubbles; foreach (Bubbles bubbles in array) { if ((Object)(object)bubbles != (Object)null) { bubbles.offsetY = Rise; } } } } public sealed class RisingFeature : ObjectFeature { public override string Key => "rising"; protected override void Build(Dictionary<string, object> r, FeatureContext ctx) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00bf: Unknown result type (might be due to invalid IL or missing references) StageData data = ctx.Data; Transform val = StageFx.Collider(ctx.Colliders, r.S("collider")); if ((Object)(object)((Component)val).GetComponent<DrownComponent>() == (Object)null) { ((Component)val).gameObject.AddComponent<DrownComponent>(); } Rect val2 = StageFx.RectOf(data, ((Object)val).name); float surface = r.F("surface", ((Rect)(ref val2)).yMax - data.origin[1]); Rect val3 = data.WorldRect(data.camera); RisingWater risingWater = StageFx.Child(ctx.Fx, "RisingWater", new Vector2(((Rect)(ref val3)).center.x, surface + data.origin[1])).AddComponent<RisingWater>(); risingWater.water = val; risingWater.art = (from g in StageFx.Art(r.S("art")) select g.transform).ToArray(); risingWater.delay = r.F("delay"); risingWater.speed = r.F("speed"); risingWater.accel = r.F("accel"); risingWater.maxRise = r.F("maxRise"); risingWater.drainSpeed = Mathf.Max(0.1f, r.F("drainSpeed")); risingWater.sound = r.S("sound"); risingWater.soundEvery = Mathf.Max(0.5f, r.F("soundEvery")); if (r.B("moveBubbles")) { risingWater.bubbles = ctx.Vessels.Where((Bubbles v) => (Object)(object)v != (Object)null && Mathf.Abs(v.top - (surface + data.origin[1])) < 1f).ToArray(); } } } public sealed class ShapesFeature : ListFeature { public override string Key => "shapes"; protected override void BuildItem(Dictionary<string, object> s, FeatureContext ctx) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) float[] array = s.FA("outline"); string text = s.S("name", "shape"); if (array == null || array.Length < 6) { throw new Exception("fx.json shape '" + text + "': needs an outline of at least 3 points"); } GameObject val = new GameObject("Shape_" + text) { layer = 8, tag = s.S("tag", "Solid") }; val.transform.SetParent(((Object)(object)ctx.Colliders != (Object)null) ? ctx.Colliders : ctx.Root, false); val.transform.position = Vector3.zero; PolygonCollider2D val2 = val.AddComponent<PolygonCollider2D>(); Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = ctx.Data.World(array[2 * i], array[2 * i + 1]); } val2.SetPath(0, array2); val.AddComponent<CollisionTag>().bitMask = (Tag)s.I("mask", 128); Plugin.Log.LogInfo((object)string.Format("Shape {0}: {1} outline points, tag {2}, mask {3}", text, array2.Length, val.tag, s.I("mask", 128))); } } public class Pond : MonoBehaviour { public float surface; public float x0; public float x1; public Sprite[] frames = (Sprite[])(object)new Sprite[0]; public float fps; public float scale; public Color tint; public string sound; public string layer; public int order; private readonly List<SplashAnim> pool = new List<SplashAnim>(); private readonly Dictionary<Character, float> lastFeet = new Dictionary<Character, float>(); private Character[] characters = (Character[])(object)new Character[0]; private float nextScan; private void Update() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (frames.Length == 0) { return; } if (Time.unscaledTime >= nextScan) { characters = Object.FindObjectsOfType<Character>(); nextScan = Time.unscaledTime + 0.5f; } Character[] array = characters; foreach (Character val in array) { if (!((Object)(object)val == (Object)null)) { Vector3 val2 = (((Object)(object)val.Feet != (Object)null) ? ((Component)val.Feet).transform.position : ((Component)val).transform.position); if (lastFeet.TryGetValue(val, out var value) && value > surface && val2.y <= surface && val2.x >= x0 && val2.x <= x1) { Play(val2.x); } lastFeet[val] = val2.y; } } } private void Play(float x) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) SplashAnim splashAnim = pool.Find((SplashAnim k) => !k.Playing); if ((Object)(object)splashAnim == (Object)null) { GameObject val = new GameObject("splash"); val.transform.SetParent(((Component)this).transform, false); splashAnim = val.AddComponent<SplashAnim>(); pool.Add(splashAnim); } ((Component)splashAnim).transform.position = new Vector3(x, surface, 0f); ((Component)splashAnim).transform.localScale = new Vector3(scale * ((Random.value < 0.5f) ? (-1f) : 1f), scale, 1f); splashAnim.Play(frames, fps, layer, order, tint); FxSound.Post(sound, ((Component)splashAnim).gameObject); } } public class SplashAnim : MonoBehaviour { private SpriteRenderer sr; private Sprite[] frames; private float fps; private float t; public bool Playing { get; private set; } public void Play(Sprite[] f, float rate, string layer, int order, Color tint) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sr == (Object)null) { sr = ((Component)this).gameObject.AddComponent<SpriteRenderer>(); ((Component)this).gameObject.AddComponent<AkGameObj>(); } frames = f; fps = rate; t = 0f; ((Renderer)sr).sortingLayerName = layer; ((Renderer)sr).sortingOrder = order; sr.color = tint; sr.sprite = frames[0]; ((Renderer)sr).enabled = true; Playing = true; } private void Update() { if (Playing) { t += Time.deltaTime; int num = (int)(t * fps); if (num >= frames.Length) { ((Renderer)sr).enabled = false; Playing = false; } else { sr.sprite = frames[num]; } } } } public sealed class SplashFeature : ObjectFeature { public override string Key => "splash"; protected override void Build(Dictionary<string, object> d, FeatureContext ctx) { //IL_0072: 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_007f: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) StageData data = ctx.Data; Transform val = StageFx.Collider(ctx.Colliders, d.S("collider")); if (d.B("drown") && (Object)(object)((Component)val).GetComponent<DrownComponent>() == (Object)null) { ((Component)val).gameObject.AddComponent<DrownComponent>().isLava = false; } float[] array = d.FA("pivot"); Vector2 pivot = ((array != null && array.Length == 2) ? new Vector2(array[0], array[1]) : new Vector2(0.5f, 0f)); float ppu = d.F("ppu"); Sprite[] array2 = (from f in d.SA("frames") select StageBuilder.LoadSprite(f, pivot, ppu) into f where (Object)(object)f != (Object)null select f).ToArray(); Pond pond = StageFx.Child(ctx.Fx, "Splash_" + ((Object)val).name, Vector2.zero).AddComponent<Pond>(); pond.surface = d.F("surface") + data.origin[1]; pond.x0 = d.F("x0") + data.origin[0]; pond.x1 = d.F("x1") + data.origin[0]; pond.frames = array2; pond.fps = Mathf.Max(1f, d.F("fps")); pond.scale = d.F("scale"); float[] array3 = d.FA("color"); pond.tint = ((array3 != null && array3.Length >= 3) ? StageBuilde