Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MoonControl v1.0.0
MoonControl.dll
Decompiled 14 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using MenuLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [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 MoonControl { internal static class MoonBonus { private static readonly ConditionalWeakTable<ValuableObject, object> baseValues = new ConditionalWeakTable<ValuableObject, object>(); internal static float Apply(ValuableObject valuable) { int applied = MoonState.Applied; if ((Object)(object)valuable == (Object)null || applied <= 0) { return 0f; } try { float num = 1f + Plugin.ValueBonusPercent.Value / 100f * (float)applied; float num2 = Refs.DollarValueCurrent.Invoke(valuable); float num3 = Round(num2 * num); Record(valuable, num2); Refs.DollarValueOriginal.Invoke(valuable) = Round(Refs.DollarValueOriginal.Invoke(valuable) * num); Refs.DollarValueCurrent.Invoke(valuable) = num3; return num3 - num2; } catch (Exception ex) { Plugin.Log.LogError((object)("Applying the moon's value bonus to a valuable failed: " + ex)); return 0f; } } private static float Round(float value) { return Mathf.Round(value / 100f) * 100f; } internal static void Record(ValuableObject valuable, float baseValue) { baseValues.Remove(valuable); baseValues.Add(valuable, baseValue); } internal static bool TryGetBase(ValuableObject valuable, out float baseValue) { if ((Object)(object)valuable != (Object)null && baseValues.TryGetValue(valuable, out var value)) { baseValue = (float)value; return true; } baseValue = 0f; return false; } } internal static class MoonButton { private sealed class Spin : MonoBehaviour { private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Rotate(Vector3.up, 12f * Time.deltaTime, (Space)1); } } private const string PrefabName = "MoonControl Button"; private const float MoonDiameter = 0.3f; private const float PedestalHeight = 0.6f; private const float PedestalRadius = 0.14f; private const int MoonTextureSize = 256; private static readonly Color GlowColour = new Color(0.84f, 0.88f, 1f); private static readonly Color Steel = new Color(0.3f, 0.34f, 0.41f); private static readonly Color SteelLight = new Color(0.47f, 0.51f, 0.58f); private static readonly Color GoldTrim = new Color(0.86f, 0.66f, 0.26f); private static readonly Color GoldDark = new Color(0.48f, 0.35f, 0.12f); private static readonly Color GrooveShadow = new Color(0.07f, 0.08f, 0.1f); private static readonly Color Grime = new Color(0.16f, 0.13f, 0.1f); private static PrefabRef buttonRef; private static GameObject currentInstance; private static Material moonMaterial; private static readonly string[] surfaceShaders = new string[3] { "Standard", "Legacy Shaders/Diffuse", "Mobile/Diffuse" }; internal static bool Ready => buttonRef != null; internal static bool Placed => (Object)(object)currentInstance != (Object)null; internal static void Register() { if (buttonRef != null) { return; } try { GameObject val = Build(); buttonRef = NetworkPrefabs.RegisterNetworkPrefab("MoonControl/MoonControl Button", val) ?? throw new InvalidOperationException("REPOLib did not accept the prefab"); Plugin.Log.LogInfo((object)"The moon button is registered."); } catch (Exception ex) { Plugin.Log.LogError((object)("The moon button was not added: " + ex)); } } private static GameObject Build() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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) //IL_0202: 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) GameObject val = new GameObject("MoonControl prefabs"); val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); GameObject val2 = new GameObject("MoonControl Button"); val2.transform.SetParent(val.transform, false); val2.tag = "Phys Grab Object"; val2.layer = LayerMask.NameToLayer("StaticGrabObject"); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj).name = "Pedestal"; obj.transform.SetParent(val2.transform, false); obj.transform.localPosition = new Vector3(0f, 0.3f, 0f); obj.transform.localScale = new Vector3(0.28f, 0.3f, 0.28f); Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.GetComponent<Renderer>().sharedMaterial = BuildMaterial("Moon Pedestal", BuildPedestalTexture(), 0.55f, 0.5f); GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val3).name = "Moon"; val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = new Vector3(0f, 0.75f, 0f); val3.transform.localScale = Vector3.one * 0.3f; Object.Destroy((Object)(object)val3.GetComponent<Collider>()); Texture2D val4 = BuildMoonTexture(); moonMaterial = BuildMaterial("Moon", val4); moonMaterial.EnableKeyword("_EMISSION"); moonMaterial.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)0; moonMaterial.SetTexture("_EmissionMap", (Texture)(object)val4); val3.GetComponent<Renderer>().sharedMaterial = moonMaterial; val3.AddComponent<Spin>(); GameObject val5 = new GameObject("Glow"); val5.transform.SetParent(val3.transform, false); Light obj2 = val5.AddComponent<Light>(); obj2.type = (LightType)2; obj2.color = GlowColour; obj2.shadows = (LightShadows)0; obj2.range = 4.5f; BoxCollider obj3 = val2.AddComponent<BoxCollider>(); obj3.center = new Vector3(0f, 0.45000002f, 0f); obj3.size = new Vector3(0.33600003f, 0.90000004f, 0.33600003f); val2.AddComponent<PhotonView>(); StaticGrabObject obj4 = val2.AddComponent<StaticGrabObject>(); obj4.colliderTransform = val2.transform; obj4.hoverText = "Grab to open moon control"; val2.AddComponent<MoonButtonWatcher>(); return val2; } internal static void SpawnFixed(bool announce = true) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //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) if (!Ready) { return; } DespawnCurrent(); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Plugin.ButtonPositionX.Value, Plugin.ButtonPositionY.Value, Plugin.ButtonPositionZ.Value); Quaternion val2 = Quaternion.Euler(0f, Plugin.ButtonYawDegrees.Value, 0f); GameObject val3 = (currentInstance = NetworkPrefabs.SpawnNetworkPrefab(buttonRef, val, val2, (byte)0, (object[])null)); if (!((Object)(object)val3 == (Object)null)) { float num = Mathf.Max(0.05f, Plugin.ButtonScale.Value); val3.transform.localScale = Vector3.one * num; ApplyGlow(val3); string[] obj = new string[5] { "Moon button placed at ", null, null, null, null }; Vector3 position = val3.transform.position; obj[1] = ((Vector3)(ref position)).ToString("F2"); obj[2] = " (scale "; obj[3] = num.ToString("0.##"); obj[4] = "x)."; string text = string.Concat(obj); if (announce) { Plugin.Log.LogInfo((object)text); } else { Plugin.Log.LogDebug((object)text); } } } private static void ApplyGlow(GameObject instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, Plugin.ButtonGlow.Value); if ((Object)(object)moonMaterial != (Object)null) { moonMaterial.SetColor("_EmissionColor", GlowColour * (1.5f * num)); } Light componentInChildren = instance.GetComponentInChildren<Light>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.intensity = 2.2f * num; ((Behaviour)componentInChildren).enabled = num > 0f; } } internal static void DespawnCurrent() { if ((Object)(object)currentInstance == (Object)null) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView component = currentInstance.GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null && component.IsMine) { PhotonNetwork.Destroy(currentInstance); } } else { Object.Destroy((Object)(object)currentInstance); } currentInstance = null; } private static Texture2D BuildMoonTexture() { //IL_0143: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) Random random = new Random(9001); float[] array = new float[7]; float[] array2 = new float[7]; float[] array3 = new float[7]; for (int i = 0; i < 7; i++) { array[i] = (float)random.NextDouble(); array2[i] = Mathf.Acos(1f - 2f * (float)random.NextDouble()) / MathF.PI; array3[i] = 0.1f + (float)random.NextDouble() * 0.13f; } float[] array4 = new float[55]; float[] array5 = new float[55]; float[] array6 = new float[55]; for (int j = 0; j < 55; j++) { array4[j] = (float)random.NextDouble(); array5[j] = Mathf.Acos(1f - 2f * (float)random.NextDouble()) / MathF.PI; double num = random.NextDouble(); array6[j] = ((num < 0.05) ? (0.035f + (float)random.NextDouble() * 0.03f) : ((num < 0.3) ? (0.013f + (float)random.NextDouble() * 0.014f) : (0.004f + (float)random.NextDouble() * 0.008f))); } Vector2 val = new Vector2(-0.7f, 0.7f); Vector2 normalized = ((Vector2)(ref val)).normalized; Color[] array7 = (Color[])(object)new Color[65536]; for (int k = 0; k < 256; k++) { float num2 = ((float)k + 0.5f) / 256f; float num3 = Mathf.Max(Mathf.Cos((num2 - 0.5f) * MathF.PI), 0.12f); for (int l = 0; l < 256; l++) { float num4 = ((float)l + 0.5f) / 256f; float num5 = 0f; for (int m = 0; m < 7; m++) { float num6 = num2 - array2[m]; if (!(num6 > array3[m] * 1.6f) && !(num6 < (0f - array3[m]) * 1.6f)) { float num7 = num4 - array[m]; float num8 = (num7 - Mathf.Round(num7)) * num3; float num9 = 0.72f + 0.5f * Mathf.PerlinNoise((float)l * 0.05f + (float)m * 7f, (float)k * 0.05f + (float)m * 13f); float num10 = Mathf.Sqrt(num8 * num8 + num6 * num6) / (array3[m] * num9); num5 = Mathf.Max(num5, Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((1f - num10) / 0.32f))); } } float num11 = Mathf.Lerp(0.8f, 0.44f, num5); num11 += (Mathf.PerlinNoise((float)l * 0.2f + 60f, (float)k * 0.2f + 130f) - 0.5f) * 0.07f; float num12 = 0f; float num13 = 0f; float num14 = 0f; for (int n = 0; n < 55; n++) { float num15 = num2 - array5[n]; if (num15 > array6[n] * 2.6f || num15 < (0f - array6[n]) * 2.6f) { continue; } float num16 = num4 - array4[n]; float num17 = (num16 - Mathf.Round(num16)) * num3; float num18 = Mathf.Sqrt(num17 * num17 + num15 * num15) / array6[n]; if (!(num18 > 2.6f)) { float num19 = ((num18 > 0.001f) ? ((num17 * normalized.x + num15 * normalized.y) / (num18 * array6[n])) : 0f); if (num18 < 1f) { float num20 = Mathf.Sqrt(1f - num18 * num18); num13 = Mathf.Max(num13, num20 * 0.2f); num12 += (0f - num19) * num20 * 0.22f; } else if (num18 < 1.28f) { float num21 = 1f - Mathf.Abs(num18 - 1.12f) / 0.16f; num12 += Mathf.Clamp01(num21) * num19 * 0.3f; } else if (array6[n] > 0.05f) { float num22 = Mathf.PerlinNoise(Mathf.Atan2(num15, num17) * 3.2f + (float)n * 10f, 0.5f); num14 = Mathf.Max(num14, Mathf.Clamp01(num22 - 0.45f) * Mathf.Clamp01(1f - (num18 - 1.28f) / 1.3f) * 0.5f); } } } num11 = Mathf.Clamp01(num11 * (1f - num13) + num12 * 0.4f + num14 * 0.1f); array7[k * 256 + l] = new Color(num11 * (1.03f - num5 * 0.05f), num11, num11 * (0.95f + num5 * 0.07f)); } } return Keep<Texture2D>(MakeTexture("Moon", array7)); } private static Texture2D BuildPedestalTexture() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b3: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d5: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_011e: 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) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: 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_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[65536]; for (int i = 0; i < 256; i++) { float num = ((float)i + 0.5f) / 256f; for (int j = 0; j < 256; j++) { float num2 = ((float)j + 0.5f) / 256f; float num3 = 0.9f + 0.18f * Mathf.PerlinNoise((float)j * 0.37f, (float)i * 0.04f); Color val = Color.Lerp(Steel, SteelLight, Mathf.Clamp01(Mathf.PerlinNoise((float)j * 0.25f + 40f, (float)i * 0.05f + 12f) * 0.6f)) * num3; val *= 0.66f + 0.46f * num; float num4 = Band(num, 0.6f, 0.72f, 0.012f); if (num4 > 0f) { Color val2 = Color.Lerp(GoldDark, GoldTrim, Mathf.Clamp01(0.45f + 0.7f * Mathf.PerlinNoise((float)j * 0.8f + 5f, (float)i * 0.05f + 3f))); val = Color.Lerp(val, val2, num4); } val = Color.Lerp(val, GoldDark, Band(num, 0.145f, 0.165f, 0.008f) * 0.85f); float num5 = Mathf.Max(Band(num, 0.578f, 0.592f, 0.006f), Mathf.Max(Band(num, 0.728f, 0.742f, 0.006f), Band(num, 0.888f, 0.9f, 0.006f))); val = Color.Lerp(val, GrooveShadow, num5 * 0.9f); val = Color.Lerp(val, SteelLight * 1.15f, Band(num, 0.905f, 1f, 0.01f) * 0.8f); float num6 = 0f; float num7 = 0f; for (int k = 0; k < 8; k++) { float num8 = Mathf.Abs(num2 - (float)k / 8f); num8 = Mathf.Min(num8, 1f - num8); num6 = Mathf.Max(num6, Mathf.Clamp01(1f - num8 / 0.006f)); float num9 = Mathf.Abs(num2 - ((float)k + 0.5f) / 8f); num9 = Mathf.Min(num9, 1f - num9) * 1.5f; float num10 = num - 0.66f; num7 = Mathf.Max(num7, Mathf.Clamp01(1f - Mathf.Sqrt(num9 * num9 + num10 * num10) / 0.026f)); } val = Color.Lerp(val, GrooveShadow, num6 * 0.55f * (1f - num4)); if (num7 > 0f) { float num11 = ((num7 > 0.55f) ? 1.35f : 0.55f); val = Color.Lerp(val, GoldTrim * num11, Mathf.Clamp01(num7 * 1.6f)); } val *= 0.9f + 0.16f * Mathf.PerlinNoise((float)j * 0.05f + 70f, (float)i * 0.05f + 30f); float num12 = Mathf.Clamp01(1f - num / 0.3f) * (0.35f + 0.5f * Mathf.PerlinNoise((float)j * 0.12f + 11f, (float)i * 0.12f + 91f)); val = Color.Lerp(val, Grime, num12 * 0.5f); val.a = 1f; array[i * 256 + j] = val; } } return Keep<Texture2D>(MakeTexture("Moon Pedestal", array)); } private static float Band(float v, float lo, float hi, float feather) { if (v < lo) { return Mathf.Clamp01(1f - (lo - v) / feather); } if (v > hi) { return Mathf.Clamp01(1f - (v - hi) / feather); } return 1f; } private static Texture2D MakeTexture(string name, Color[] pixels) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown int num = Mathf.RoundToInt(Mathf.Sqrt((float)pixels.Length)); Texture2D val = new Texture2D(num, num, (TextureFormat)4, false) { name = name, wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; val.SetPixels(pixels); val.Apply(false, false); return val; } private static Material BuildMaterial(string name, Texture2D texture, float metallic = 0f, float glossiness = 0.1f) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Material val = null; string[] array = surfaceShaders; for (int i = 0; i < array.Length; i++) { Shader val2 = Shader.Find(array[i]); if ((Object)(object)val2 != (Object)null && val2.isSupported) { val = new Material(val2); break; } } if ((Object)(object)val == (Object)null) { val = new Material(Shader.Find("Sprites/Default")); } ((Object)val).name = name; val.mainTexture = (Texture)(object)texture; if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", glossiness); } return Keep<Material>(val); } private static T Keep<T>(T asset) where T : Object { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)asset != (Object)null) { ((Object)asset).hideFlags = (HideFlags)(((Object)asset).hideFlags | 0x20); } return asset; } } internal sealed class MoonButtonWatcher : MonoBehaviour { private StaticGrabObject grab; private bool wasGrabbing; private void Awake() { grab = ((Component)this).GetComponent<StaticGrabObject>(); } private void Update() { if (!Plugin.Enabled.Value || (Object)(object)grab == (Object)null) { return; } PhysGrabber instance = PhysGrabber.instance; bool flag = (Object)(object)instance != (Object)null && (Object)(object)Refs.GrabbedStaticGrabObject.Invoke(instance) == (Object)(object)grab; if (flag && !wasGrabbing) { try { MoonMenu.Open(); } catch (Exception ex) { Plugin.Log.LogError((object)("Opening the moon menu failed: " + ex)); } } wasGrabbing = flag; } } internal sealed class MoonButtonSpawner : MonoBehaviour { private const float SettleSeconds = 1f; private const float RetrySeconds = 1f; private float sinceReady; private float sinceSpawn; private bool placedThisVisit; private void Awake() { Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void Update() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 if (!Plugin.Enabled.Value || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (!SemiFunc.RunIsLobby() || !((Object)(object)GameDirector.instance != (Object)null) || (int)GameDirector.instance.currentState != 2) { sinceReady = 0f; sinceSpawn = 0f; placedThisVisit = false; return; } sinceReady += Time.deltaTime; sinceSpawn += Time.deltaTime; if (sinceReady < 1f || sinceSpawn < 1f) { return; } bool num = !MoonButton.Placed; float value = Plugin.LiveTuneSeconds.Value; bool flag = value > 0f && sinceSpawn >= value; if (!num && !flag) { return; } sinceSpawn = 0f; try { MoonButton.SpawnFixed(!placedThisVisit); placedThisVisit = true; } catch (Exception ex) { Plugin.Log.LogError((object)("Could not place the moon button: " + ex)); } } } internal static class MoonMenu { private sealed class Watcher : MonoBehaviour { private void Update() { Tick(); } private void OnDestroy() { OnPageDestroyed(); } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action <>9__35_3; public static ScrollViewBuilderDelegate <>9__35_0; internal RectTransform <BuildRows>b__35_0(Transform scroll) { return ((REPOElement)(randomButton = CreateRow(scroll, RandomRowText(MoonState.RandomMode), delegate { Net.RequestRandom(); }))).rectTransform; } internal void <BuildRows>b__35_3() { Net.RequestRandom(); } } private const string Gold = "#FFD24A"; private const string Grey = "#808080"; private const string White = "#FFFFFF"; private const int RandomSentinel = -1; private const float PanelGap = 10f; private static REPOPopupPage page; private static TextMeshProUGUI textStyle; private static readonly Dictionary<int, REPOButton> rows = new Dictionary<int, REPOButton>(); private static REPOButton randomButton; private static float rowWidth; private static int shownFor = -1; private static int highlighted = -1; private static bool highlightedRandom; private static RawImage previewIcon; private static readonly List<RawImage> multiIcons = new List<RawImage>(); private static REPOLabel previewTitle; private static REPOLabel previewAttributes; private static REPOLabel description; private static float iconAreaLeft; private static float iconAreaTop; private static float iconAreaWidth; private static float iconAreaHeight; private static int selectedLevel = -1; private static RectTransform closeRect; private static Image closeImage; private static TextMeshProUGUI closeText; private static Camera closeCamera; private static bool closeHovering; private static readonly Color CloseIdle = new Color(0.12f, 0.12f, 0.12f, 0.9f); private static readonly Color CloseHover = new Color(0.32f, 0.32f, 0.32f, 0.95f); internal static bool IsOpen => (Object)(object)page != (Object)null; internal static bool CanOpen() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 if (!SemiFunc.RunIsLobby()) { return false; } if ((Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2) { return false; } MenuManager instance = MenuManager.instance; if ((Object)(object)instance == (Object)null || (Object)(object)Refs.CurrentMenuPage.Invoke(instance) != (Object)null) { return false; } return SemiFunc.NoTextInputsActive(); } internal static void Open() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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) if (IsOpen || !CanOpen()) { return; } try { rows.Clear(); randomButton = null; shownFor = -1; highlighted = -1; highlightedRandom = false; selectedLevel = (MoonState.RandomMode ? (-1) : MoonState.Applied); page = MenuAPI.CreateREPOPopupPage("MOON CONTROL", (PresetSide)0, false, true, 6f); ((Component)page).gameObject.AddComponent<Watcher>(); ((Transform)page.rectTransform).localScale = Vector3.one * Plugin.MenuScale.Value; rowWidth = Mathf.Max(100f, page.maskRectTransform.sizeDelta.x - 14f); REPOLabel obj = MenuAPI.CreateREPOLabel("", (Transform)(object)page.rectTransform, default(Vector2)); ((Component)obj).gameObject.SetActive(false); textStyle = obj.labelTMP; page.OpenPage(false); Refresh(); BuildSidePanel(); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not open the moon menu: " + ex)); if ((Object)(object)page != (Object)null) { Object.Destroy((Object)(object)((Component)page).gameObject); } OnPageDestroyed(); } } private static void Refresh() { if ((Object)(object)page == (Object)null) { return; } int num = MoonState.Unlocked(RunManager.instance); if (num != shownFor) { BuildRows(num); shownFor = num; } int applied = MoonState.Applied; bool randomMode = MoonState.RandomMode; if (applied != highlighted || randomMode != highlightedRandom) { highlighted = applied; highlightedRandom = randomMode; foreach (KeyValuePair<int, REPOButton> row in rows) { ((TMP_Text)row.Value.labelTMP).text = RowText(row.Key, !randomMode && row.Key == applied); } if ((Object)(object)randomButton != (Object)null) { ((TMP_Text)randomButton.labelTMP).text = RandomRowText(randomMode); } } bool flag = false; foreach (KeyValuePair<int, REPOButton> row2 in rows) { REPOButton value = row2.Value; if ((Object)(object)value != (Object)null && (Object)(object)value.menuButton != (Object)null && ((Component)value).gameObject.activeInHierarchy && Refs.ButtonHovering.Invoke(value.menuButton)) { Select(row2.Key); flag = true; break; } } if (!flag && (Object)(object)randomButton != (Object)null && (Object)(object)randomButton.menuButton != (Object)null && ((Component)randomButton).gameObject.activeInHierarchy && Refs.ButtonHovering.Invoke(randomButton.menuButton)) { Select(-1); } } private static void BuildRows(int unlocked) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown foreach (REPOButton value in rows.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } rows.Clear(); if ((Object)(object)randomButton != (Object)null) { Object.Destroy((Object)(object)((Component)randomButton).gameObject); randomButton = null; } bool flag = SemiFunc.IsMasterClientOrSingleplayer(); for (int i = 0; i <= unlocked; i++) { int captured = i; float num = ((i == 0) ? 18f : 0f); page.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scroll) { REPOButton val2 = CreateRow(scroll, RowText(captured, !MoonState.RandomMode && captured == MoonState.Applied), delegate { Net.Request(captured); }); rows[captured] = val2; return ((REPOElement)val2).rectTransform; }, num, 0f); } if (flag && unlocked >= 1) { REPOPopupPage obj = page; object obj2 = <>c.<>9__35_0; if (obj2 == null) { ScrollViewBuilderDelegate val = (Transform scroll) => ((REPOElement)(randomButton = CreateRow(scroll, RandomRowText(MoonState.RandomMode), delegate { Net.RequestRandom(); }))).rectTransform; <>c.<>9__35_0 = val; obj2 = (object)val; } obj.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f); } if (unlocked < 1) { AddNote2("No moon is unlocked yet in this run - it takes 5 levels for the first one. Only \"none\" is available."); } if (!flag) { AddNote2("You are not the host, so this list is read-only for you - it still follows what the host picks."); } } private static REPOButton CreateRow(Transform scroll, string text, Action onClick) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) REPOButton obj = MenuAPI.CreateREPOButton(text, onClick, scroll, default(Vector2)); TextMeshProUGUI labelTMP = obj.labelTMP; float fontSize = ((TMP_Text)labelTMP).fontSize; ((TMP_Text)labelTMP).enableWordWrapping = false; ((TMP_Text)labelTMP).overflowMode = (TextOverflowModes)1; ((TMP_Text)labelTMP).enableAutoSizing = true; ((TMP_Text)labelTMP).fontSizeMax = fontSize; ((TMP_Text)labelTMP).fontSizeMin = Mathf.Max(10f, fontSize * 0.55f); float num = ((fontSize > 0f) ? (fontSize * 1.3f) : 24f); obj.overrideButtonSize = new Vector2(rowWidth, num); return obj; } private static string RowText(int level, bool applied) { string text = ((level <= 0) ? "None (the game's own baseline)" : ("Moon " + level + NameSuffix(level))); string text2 = (applied ? "#FFD24A" : "#FFFFFF"); string text3 = (applied ? "◉ " : "○ "); return "<color=" + text2 + ">" + text3 + text + "</color>"; } private static string RandomRowText(bool applied) { string text = (applied ? "#FFD24A" : "#FFFFFF"); string text2 = (applied ? "◉ " : "○ "); return "<color=" + text + ">" + text2 + "Random (among unlocked moons)</color>"; } private static string NameSuffix(int level) { RunManager instance = RunManager.instance; string text = (((Object)(object)instance == (Object)null) ? "" : instance.MoonGetName(level)); if (!string.IsNullOrEmpty(text)) { return " - " + text; } return ""; } private static float BonusPercent(int level) { return Plugin.ValueBonusPercent.Value * (float)level; } private static void Select(int level) { if (level != selectedLevel) { selectedLevel = level; RefreshPreview(); } } private static void RefreshPreview() { if ((Object)(object)previewTitle == (Object)null) { return; } RunManager instance = RunManager.instance; if (selectedLevel == -1) { ((TMP_Text)previewTitle.labelTMP).text = "Random"; int num = MoonState.Unlocked(instance); ShowMultiIcons(num); ((TMP_Text)previewAttributes.labelTMP).text = ((num < 1) ? "No moon is unlocked yet, so there is nothing to roll among until level 5." : "A random moon among the ones you have unlocked is applied as a surprise the moment the next level starts, and rolled again for the one after that - you find out which one only by playing it."); return; } if (selectedLevel <= 0 || (Object)(object)instance == (Object)null) { ((TMP_Text)previewTitle.labelTMP).text = "None"; ShowSingleIcon(null); ((TMP_Text)previewAttributes.labelTMP).text = "The game's own baseline - no moon effects, and no bonus to what valuables are worth."; return; } string text = instance.MoonGetName(selectedLevel); ((TMP_Text)previewTitle.labelTMP).text = "<color=#FFD24A>Moon " + selectedLevel + (string.IsNullOrEmpty(text) ? "" : (" - " + text)) + "</color>"; ShowSingleIcon(instance.MoonGetIcon(selectedLevel)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<color=#FFD24A>+").Append(BonusPercent(selectedLevel).ToString("0.#")).Append("% to what every valuable is worth</color>"); List<MoonAttribute> list = instance.MoonGetAttributes(selectedLevel); if (list != null) { foreach (MoonAttribute item in list) { if (item != null) { string value = (((Object)(object)item.LocalizedText != (Object)null) ? item.LocalizedText.GetLocalizedString() : item.text); if (!string.IsNullOrEmpty(value)) { stringBuilder.Append("\n").Append(value); } } } } ((TMP_Text)previewAttributes.labelTMP).text = stringBuilder.ToString(); } private static void ShowSingleIcon(Texture texture) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) ClearMultiIcons(); if (!((Object)(object)previewIcon == (Object)null)) { float num = Mathf.Min(iconAreaWidth * 0.4f, iconAreaHeight); RectTransform rectTransform = ((Graphic)previewIcon).rectTransform; rectTransform.sizeDelta = new Vector2(num, num); ((Transform)rectTransform).localPosition = new Vector3(iconAreaLeft + (iconAreaWidth - num) * 0.5f, iconAreaTop, 0f); previewIcon.texture = texture; ((Behaviour)previewIcon).enabled = (Object)(object)texture != (Object)null; } } private static void ShowMultiIcons(int unlocked) { //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) //IL_00b0: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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) ClearMultiIcons(); if ((Object)(object)previewIcon != (Object)null) { ((Behaviour)previewIcon).enabled = false; } if (unlocked >= 1) { RunManager instance = RunManager.instance; float num = 4f; float num2 = Mathf.Min(iconAreaHeight, (iconAreaWidth - num * (float)(unlocked - 1)) / (float)unlocked); float num3 = num2 * (float)unlocked + num * (float)(unlocked - 1); float num4 = iconAreaLeft + (iconAreaWidth - num3) * 0.5f; for (int i = 1; i <= unlocked; i++) { GameObject val = new GameObject("RandomPreviewIcon" + i, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)page.rectTransform, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0.5f, 0.5f); val2.anchorMax = new Vector2(0.5f, 0.5f); val2.pivot = new Vector2(0f, 1f); val2.sizeDelta = new Vector2(num2, num2); ((Transform)val2).localPosition = new Vector3(num4 + (float)(i - 1) * (num2 + num), iconAreaTop, 0f); RawImage val3 = val.AddComponent<RawImage>(); ((Graphic)val3).raycastTarget = false; Texture val4 = (val3.texture = (((Object)(object)instance != (Object)null) ? instance.MoonGetIcon(i) : null)); ((Behaviour)val3).enabled = (Object)(object)val4 != (Object)null; multiIcons.Add(val3); } } } private static void ClearMultiIcons() { foreach (RawImage multiIcon in multiIcons) { if ((Object)(object)multiIcon != (Object)null) { Object.Destroy((Object)(object)((Component)multiIcon).gameObject); } } multiIcons.Clear(); } private static void BuildSidePanel() { //IL_00bb: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_010b: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) try { Transform rectTransform = (Transform)(object)page.rectTransform; Vector3[] array = (Vector3[])(object)new Vector3[4]; if ((Object)(object)page.scrollView != (Object)null) { page.scrollView.UpdateElements(); } Transform obj = ((Transform)page.rectTransform).Find("Panel"); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); float num2; float num; float y; float y2; if ((Object)(object)val != (Object)null) { val.GetWorldCorners(array); Vector3 val2 = rectTransform.InverseTransformPoint(array[0]); Vector3 val3 = rectTransform.InverseTransformPoint(array[2]); y = val3.y; y2 = val2.y; num = val3.x - val2.x; num2 = val3.x + 10f; } else { page.maskRectTransform.GetWorldCorners(array); Vector3 val4 = rectTransform.InverseTransformPoint(array[0]); Vector3 val5 = rectTransform.InverseTransformPoint(array[2]); y = val5.y; y2 = val4.y; num = (val5.y - val4.y) * 0.73f; num2 = val5.x + 10f; } RectTransform item = AddBackground(rectTransform, new Vector2(num2, y), num, y - y2); float num3 = Mathf.Max(10f, (y - y2) * 0.04f); num2 += num3; num -= num3 * 2f; y -= num3; y2 += num3; float num4 = y - y2; float num5 = num4 * 0.09f; previewTitle = AddTextBlock(rectTransform, new Vector2(num2, y), num, num5, 20f, 12f, singleLine: true); ((TMP_Text)previewTitle.labelTMP).alignment = (TextAlignmentOptions)4098; float num6 = num4 * 0.02f; iconAreaTop = y - num5 - num6; iconAreaHeight = num4 * 0.16f; iconAreaLeft = num2; iconAreaWidth = num; GameObject val6 = new GameObject("PreviewIcon", new Type[1] { typeof(RectTransform) }); val6.transform.SetParent(rectTransform, false); RectTransform val7 = (RectTransform)val6.transform; val7.anchorMin = new Vector2(0.5f, 0.5f); val7.anchorMax = new Vector2(0.5f, 0.5f); val7.pivot = new Vector2(0f, 1f); previewIcon = val6.AddComponent<RawImage>(); ((Graphic)previewIcon).raycastTarget = false; float num7 = 26f + num6; float num8 = Mathf.Max(num4 * 0.16f, 40f); float num9 = y2 + num7 + num8; description = AddTextBlock(rectTransform, new Vector2(num2, num9), num, num8, 12f, 8f, singleLine: false); ((TMP_Text)description.labelTMP).text = "Each moon level applied adds " + Plugin.ValueBonusPercent.Value.ToString("0.#") + "% to what every valuable is worth. Only the host's choice counts."; float num10 = iconAreaTop - iconAreaHeight - num6; float num11 = num9 + num6; float height = Mathf.Max(num10 - num11, num4 * 0.1f); previewAttributes = AddTextBlock(rectTransform, new Vector2(num2, num10), num, height, 15f, 8f, singleLine: false); RectTransform item2 = AddCloseButton(rectTransform, new Vector2(num2 + num - 90f, y2), 90f, 26f); RefreshPreview(); CenterOnScreen(new List<RectTransform> { val, page.maskRectTransform, page.scrollBarRectTransform, item, item2, ((REPOElement)previewTitle).rectTransform, ((REPOElement)previewAttributes).rectTransform, ((REPOElement)description).rectTransform }); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not build the moon menu's preview panel: " + ex)); } } private static REPOLabel AddTextBlock(Transform host, Vector2 topLeft, float width, float height, float fontSize, float minFontSize, bool singleLine) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_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) REPOLabel obj = MenuAPI.CreateREPOLabel("", host, default(Vector2)); SetTopLeftRect(((REPOElement)obj).rectTransform, width, height); TextMeshProUGUI labelTMP = obj.labelTMP; ((TMP_Text)labelTMP).fontSize = fontSize; ((TMP_Text)labelTMP).overflowMode = (TextOverflowModes)0; ((TMP_Text)labelTMP).enableAutoSizing = true; ((TMP_Text)labelTMP).fontSizeMin = minFontSize; ((TMP_Text)labelTMP).fontSizeMax = fontSize; ((TMP_Text)labelTMP).richText = true; if (singleLine) { ((TMP_Text)labelTMP).enableWordWrapping = false; ((TMP_Text)labelTMP).alignment = (TextAlignmentOptions)4097; } else { ((TMP_Text)labelTMP).enableWordWrapping = true; ((TMP_Text)labelTMP).alignment = (TextAlignmentOptions)257; ((Graphic)labelTMP).color = new Color(0.85f, 0.85f, 0.85f); } SetTopLeftRect(((TMP_Text)labelTMP).rectTransform, width, height); ((Transform)((TMP_Text)labelTMP).rectTransform).localPosition = Vector3.zero; ((Transform)((REPOElement)obj).rectTransform).localPosition = new Vector3(topLeft.x, topLeft.y, 0f); return obj; } private static void SetTopLeftRect(RectTransform rect, float width, float height) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); rect.pivot = new Vector2(0f, 1f); rect.sizeDelta = new Vector2(width, height); } private static RectTransform AddBackground(Transform host, Vector2 topLeft, float width, float height) { //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PreviewBackground", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(host, false); RectTransform val2 = (RectTransform)val.transform; SetTopLeftRect(val2, width, height); ((Transform)val2).localPosition = new Vector3(topLeft.x, topLeft.y, 0f); Image obj = val.AddComponent<Image>(); ((Graphic)obj).color = new Color(0f, 0f, 0f, 0.55f); ((Graphic)obj).raycastTarget = false; return val2; } private static RectTransform AddCloseButton(Transform host, Vector2 bottomLeft, float width, float height) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0142: Expected O, but got Unknown GameObject val = new GameObject("Close", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(host, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0.5f, 0.5f); val2.anchorMax = new Vector2(0.5f, 0.5f); val2.pivot = Vector2.zero; val2.sizeDelta = new Vector2(width, height); ((Transform)val2).localPosition = new Vector3(bottomLeft.x, bottomLeft.y, 0f); closeImage = val.AddComponent<Image>(); ((Graphic)closeImage).color = CloseIdle; ((Graphic)closeImage).raycastTarget = false; closeText = CreateText((Transform)val2, textStyle, "Text", 14f, (TextAlignmentOptions)4098); Stretch(((TMP_Text)closeText).rectTransform); ((TMP_Text)closeText).text = "Close"; Canvas componentInParent = ((Component)page).GetComponentInParent<Canvas>(); closeCamera = ((!((Object)(object)componentInParent != (Object)null) || (int)componentInParent.renderMode == 0) ? null : (((Object)(object)componentInParent.worldCamera != (Object)null) ? componentInParent.worldCamera : OverlayCamera())); closeRect = val2; closeHovering = false; return val2; } private static Camera OverlayCamera() { try { return ((Object)(object)CameraOverlay.instance != (Object)null) ? ((Component)CameraOverlay.instance).GetComponent<Camera>() : null; } catch (Exception) { return null; } } private static void TickCloseButton() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0090: 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) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)closeRect == (Object)null) { return; } bool flag; try { flag = RectTransformUtility.RectangleContainsScreenPoint(closeRect, Vector2.op_Implicit(Input.mousePosition), closeCamera) || ((Object)(object)page.menuPage != (Object)null && SemiFunc.UIMouseHover(page.menuPage, closeRect, "-1", 0f, 0f, (MenuScrollBox)null, (ScrollRect)null)); } catch (Exception) { return; } if (flag != closeHovering) { closeHovering = flag; if ((Object)(object)closeImage != (Object)null) { ((Graphic)closeImage).color = (flag ? CloseHover : CloseIdle); } if ((Object)(object)closeText != (Object)null) { ((Graphic)closeText).color = (flag ? HexColor("#FFD24A") : Color.white); } } if (flag && Input.GetMouseButtonDown(0)) { page.ClosePage(true); } } private static void AddNote2(string text) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown page.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scroll) { //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_007e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown GameObject val = new GameObject("Note2", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(scroll, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0.5f, 0.5f); val2.anchorMax = new Vector2(0.5f, 0.5f); val2.pivot = Vector2.zero; val2.sizeDelta = new Vector2(rowWidth, 40f); ((Transform)val2).localPosition = Vector3.zero; TextMeshProUGUI obj = CreateText((Transform)val2, textStyle, "Text", 14f, (TextAlignmentOptions)257); Stretch(((TMP_Text)obj).rectTransform); ((Graphic)obj).color = HexColor("#808080"); ((TMP_Text)obj).enableWordWrapping = true; ((TMP_Text)obj).text = text; return val2; }, 0f, 8f); } private static void CenterOnScreen(List<RectTransform> parts) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) try { Canvas componentInParent = ((Component)page).GetComponentInParent<Canvas>(); RectTransform val = (RectTransform)(((Object)(object)componentInParent != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null) { return; } Rect rect = val.rect; Vector3 val2 = ((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); Vector3[] array = (Vector3[])(object)new Vector3[4]; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(float.MaxValue, float.MaxValue); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(float.MinValue, float.MinValue); foreach (RectTransform part in parts) { if (!((Object)(object)part == (Object)null)) { part.GetWorldCorners(array); Vector3[] array2 = array; foreach (Vector3 val5 in array2) { val3 = Vector2.Min(val3, Vector2.op_Implicit(val5)); val4 = Vector2.Max(val4, Vector2.op_Implicit(val5)); } } } if (!(val3.x > val4.x)) { Transform transform = ((Component)page).transform; Vector3 val6 = Vector3.zero; MenuPage menuPage = page.menuPage; if ((Object)(object)transform.parent != (Object)null && (Object)(object)Refs.PageRect.Invoke(menuPage) != (Object)null) { Vector2 val7 = Refs.PageOriginalPosition.Invoke(menuPage); Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(val7.x, val7.y, transform.localPosition.z); val6 = transform.parent.TransformVector(transform.localPosition - val8); } Vector3 val9 = new Vector3((val3.x + val4.x) * 0.5f, (val3.y + val4.y) * 0.5f, val2.z) - val6; Vector3 val10 = val2 - val9; val10.z = 0f; rect = val.rect; Vector3 val11 = Vector3.Scale(Vector2.op_Implicit(((Rect)(ref rect)).size), ((Transform)val).lossyScale); if (Mathf.Abs(val10.x) > val11.x * 0.5f || Mathf.Abs(val10.y) > val11.y * 0.5f) { Plugin.Log.LogWarning((object)("Skipped centering the moon menu: the measured shift " + ((Vector3)(ref val10)).ToString("0.0") + " is implausible.")); return; } RectTransform rectTransform = page.rectTransform; ((Transform)rectTransform).position = ((Transform)rectTransform).position + val10; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not center the moon menu: " + ex.Message)); } } private static Color HexColor(string hex) { //IL_0010: 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) Color result = default(Color); if (!ColorUtility.TryParseHtmlString(hex, ref result)) { return Color.grey; } return result; } private static TextMeshProUGUI CreateText(Transform parent, TextMeshProUGUI style, string objectName, float fontSize, TextAlignmentOptions alignment) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(objectName, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = ((TMP_Text)style).font; ((TMP_Text)obj).fontSharedMaterial = ((TMP_Text)style).fontSharedMaterial; ((TMP_Text)obj).fontSize = fontSize; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).enableWordWrapping = false; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).alignment = alignment; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).richText = true; ((Graphic)obj).raycastTarget = false; return obj; } private static void Stretch(RectTransform rect) { //IL_0001: 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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; } private static void Tick() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 if (IsOpen) { if ((Object)(object)GameDirector.instance != (Object)null) { GameDirector.instance.SetDisableEscMenu(0.3f); } if (!SemiFunc.RunIsLobby() || (Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2) { page.ClosePage(true); return; } Refresh(); TickCloseButton(); } } private static void OnPageDestroyed() { page = null; textStyle = null; randomButton = null; previewIcon = null; previewTitle = null; previewAttributes = null; description = null; closeRect = null; closeImage = null; closeText = null; closeCamera = null; closeHovering = false; multiIcons.Clear(); selectedLevel = -1; rows.Clear(); shownFor = -1; highlighted = -1; highlightedRandom = false; } } internal static class MoonState { private const string DictionaryName = "vibezMoonControl"; private const string AppliedKey = "applied"; private const string RandomModeKey = "random"; internal static int Applied { get { Dictionary<string, int> dictionary = Store(); if (dictionary == null || !dictionary.TryGetValue("applied", out var value)) { return 0; } return value; } } internal static bool RandomMode { get { Dictionary<string, int> dictionary = Store(); if (dictionary != null && dictionary.TryGetValue("random", out var value)) { return value != 0; } return false; } } internal static int Unlocked(RunManager run) { if ((Object)(object)run == (Object)null) { return 0; } return (run.levelsCompleted + 1) / 5; } internal static void SetApplied(int level) { int num = Mathf.Max(0, level); Dictionary<string, int> dictionary = Store(); if (dictionary != null) { dictionary["applied"] = num; } RunManager instance = RunManager.instance; if (!((Object)(object)instance == (Object)null) && Refs.MoonLevel.Invoke(instance) != num) { Refs.MoonLevel.Invoke(instance) = num; Refs.MoonLevelChanged.Invoke(instance) = true; } } internal static void SetRandomMode(bool value) { Dictionary<string, int> dictionary = Store(); if (dictionary != null) { dictionary["random"] = (value ? 1 : 0); } } internal static void RollRandom() { int num = Unlocked(RunManager.instance); SetApplied((num >= 1) ? Random.Range(1, num + 1) : 0); } private static Dictionary<string, int> Store() { if ((Object)(object)StatsManager.instance == (Object)null) { return null; } SortedDictionary<string, Dictionary<string, int>> sortedDictionary = Refs.StatDictionaries.Invoke(StatsManager.instance); if (!sortedDictionary.TryGetValue("vibezMoonControl", out var value)) { value = (sortedDictionary["vibezMoonControl"] = new Dictionary<string, int>()); } return value; } } internal static class Net { private const byte EvApplied = 192; private static bool initialized; internal static void Init() { if (!initialized) { initialized = true; PhotonNetwork.NetworkingClient.EventReceived += OnEvent; } } internal static void Request(int level) { if (SemiFunc.IsMasterClientOrSingleplayer()) { int num = MoonState.Unlocked(RunManager.instance); Broadcast((level >= 0) ? ((level > num) ? num : level) : 0, randomMode: false); } } internal static void RequestRandom() { if (SemiFunc.IsMasterClientOrSingleplayer()) { Broadcast(MoonState.Applied, randomMode: true); } } private static void Broadcast(int level, bool randomMode) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0033: Expected O, but got Unknown if (SemiFunc.IsMultiplayer()) { PhotonNetwork.RaiseEvent((byte)192, (object)new int[2] { level, randomMode ? 1 : 0 }, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } else { MoonState.SetApplied(level); MoonState.SetRandomMode(randomMode); } } private static void OnEvent(EventData data) { try { if (data.Code == 192) { int[] array = (int[])data.CustomData; MoonState.SetApplied(array[0]); MoonState.SetRandomMode(array.Length > 1 && array[1] != 0); } } catch (Exception ex) { Plugin.Log.LogError((object)("Handling a moon-control network event failed: " + ex)); } } } [HarmonyPatch(typeof(RunManager), "Awake")] internal static class RunManagerAwakePatch { private static void Postfix() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) try { Net.Init(); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not register the network handler: " + ex)); } try { MoonButton.Register(); if ((Object)(object)Object.FindObjectOfType<MoonButtonSpawner>() == (Object)null) { new GameObject("MoonControl watcher").AddComponent<MoonButtonSpawner>(); } } catch (Exception ex2) { Plugin.Log.LogError((object)("Could not add the moon button: " + ex2)); } } } [HarmonyPatch(typeof(RunManager), "UpdateMoonLevel")] internal static class UpdateMoonLevelPatch { private static bool Prefix() { if (!Plugin.Enabled.Value) { return true; } try { if (MoonState.RandomMode && SemiFunc.RunIsLevel()) { MoonState.RollRandom(); } else { MoonState.SetApplied(MoonState.Applied); } } catch (Exception ex) { Plugin.Log.LogError((object)("Keeping the moon level failed (letting the game's own calculation run instead): " + ex)); return true; } return false; } } [HarmonyPatch(typeof(LevelUI), "Update")] internal static class LevelUIUpdatePatch { private static void Postfix(LevelUI __instance) { if (!Plugin.Enabled.Value || (Object)(object)__instance == (Object)null || (Object)(object)__instance.objectMoon == (Object)null) { return; } try { RunManager instance = RunManager.instance; int applied = MoonState.Applied; bool flag = (Object)(object)instance != (Object)null && applied > 0 && applied <= instance.moons.Count; __instance.objectMoon.SetActive(flag); if (flag) { ((TMP_Text)__instance.textMoon).text = instance.MoonGetName(applied); __instance.iconMoon.texture = instance.MoonGetIcon(applied); } } catch (Exception ex) { Plugin.Log.LogError((object)("Could not correct the level panel's moon indicator: " + ex)); } } } [HarmonyPatch(typeof(ValuableObject), "DollarValueSetLogic")] internal static class DollarValueSetLogicPatch { private static void Prefix(ValuableObject __instance, out bool __state) { __state = Refs.DollarValueSet.Invoke(__instance); } private static void Postfix(ValuableObject __instance, bool __state) { if (!(!Plugin.Enabled.Value || __state) && !SpawnValuableBonusPatch.Defer(__instance)) { MoonBonus.Apply(__instance); } } } [HarmonyPatch(typeof(ValuableDirector), "SpawnValuable")] internal static class SpawnValuableBonusPatch { private static bool spawning; private static ValuableObject pending; internal static bool Defer(ValuableObject valuable) { if (!spawning) { return false; } pending = valuable; return true; } private static void Prefix() { spawning = true; pending = null; } private static void Finalizer() { spawning = false; ValuableObject val = pending; pending = null; if ((Object)(object)val != (Object)null) { MoonBonus.Apply(val); } } } [HarmonyPatch(typeof(WorldSpaceUIValue), "Show", new Type[] { typeof(PhysGrabObject), typeof(int), typeof(bool), typeof(Vector3) })] internal static class WorldSpaceUIValuePatch { private static void Postfix(WorldSpaceUIValue __instance, PhysGrabObject _grabObject, bool _cost) { if (!Plugin.Enabled.Value || _cost || (Object)(object)_grabObject == (Object)null) { return; } try { ValuableObject component = ((Component)_grabObject).GetComponent<ValuableObject>(); if ((Object)(object)component == (Object)null || !MoonBonus.TryGetBase(component, out var baseValue)) { return; } int num = Mathf.RoundToInt(Refs.DollarValueCurrent.Invoke(component) - baseValue); if (num > 0) { TextMeshProUGUI val = Refs.WorldSpaceUIText.Invoke(__instance); if (!((Object)(object)val == (Object)null)) { ((TMP_Text)val).text = "$" + SemiFunc.DollarGetString((int)baseValue) + " <color=red>+" + SemiFunc.DollarGetString(num) + "</color>"; } } } catch (Exception ex) { Plugin.Log.LogError((object)("Could not show the moon bonus on a held valuable's price: " + ex)); } } } [BepInPlugin("vibez.MoonControl", "MoonControl", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "vibez.MoonControl"; public const string Name = "MoonControl"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> ValueBonusPercent; internal static ConfigEntry<float> ButtonPositionX; internal static ConfigEntry<float> ButtonPositionY; internal static ConfigEntry<float> ButtonPositionZ; internal static ConfigEntry<float> ButtonYawDegrees; internal static ConfigEntry<float> ButtonScale; internal static ConfigEntry<float> ButtonGlow; internal static ConfigEntry<float> LiveTuneSeconds; internal static ConfigEntry<float> MenuScale; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Turns the whole mod on or off. While on, the moon never advances by itself: it stays at \"none\" until you grab the moon button in the truck, and a new run starts back at \"none\" again. Turn this off to get the game's own moon behaviour back (it advances on its own, permanently, every 5 levels)."); ValueBonusPercent = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ValueBonusPercent", 10f, new ConfigDescription("How much applying a moon adds to what every valuable is worth, in percent per level applied, added together (10 means moon 2 is +20%, moon 3 is +30%, and so on). Only the host's setting is used.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); ButtonPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ButtonPositionX", -13.3964f, "The moon button's fixed world X position in the truck. Use DevTools' coordinate probe (if installed) to find a good spot: aim at the floor where you want the button and read its \"World XYZ\" off the on-screen readout."); ButtonPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ButtonPositionY", 0.6852542f, "The moon button's fixed world Y position (height) in the truck."); ButtonPositionZ = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ButtonPositionZ", -1.899255f, "The moon button's fixed world Z position in the truck."); ButtonYawDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ButtonYawDegrees", 0f, "Which way the moon button faces, in degrees around the vertical axis. Only cosmetic - grabbing does not care which way it is turned."); ButtonScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ButtonScale", 1.8f, new ConfigDescription("How big the moon button is, as a multiplier of its normal size (1 = normal, 5 = five times bigger). Handy while hunting for it: turn this way up so it is impossible to miss, confirm you can see it somewhere, then dial the position in and bring the size back down. Grabbing still works at any size (the hitbox scales with it) - the host is the one who sets this. A changed value only applies the next time the button is placed - either by leaving the truck and coming back, or automatically if LiveTuneSeconds is on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>())); ButtonGlow = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ButtonGlow", 1f, new ConfigDescription("How strongly the moon glows, as a multiplier (1 = normal, 0 = no glow at all - just a lit model). It gives off a pale white: the moon itself lights up, and it casts that light onto the pedestal and the floor around it. Local only, and applied the next time the button is placed (leave the truck and come back, or use LiveTuneSeconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); LiveTuneSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LiveTuneSeconds", 0f, new ConfigDescription("Debug convenience: while above 0, the moon button re-places itself on this interval (in seconds) for as long as you stay in the truck, picking up any ButtonPositionX/Y/Z/ButtonYawDegrees/ButtonScale change made through REPOConfig without having to leave and come back. 0 = off, placed once per visit as usual. Leave this at 0 outside of a tuning session - re-placing pulls the button out from under anyone holding it or about to grab it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>())); MenuScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MenuScale", 0.9f, new ConfigDescription("How big the moon menu popup is, as a multiplier of its normal size (1 = the size MenuLib gives it, smaller than 1 shrinks it). Takes effect the next time you open the menu.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 1.5f), Array.Empty<object>())); try { Harmony val = new Harmony("vibez.MoonControl"); Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { val.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Log.LogError((object)("Patch " + type.Name + " failed: " + ex)); } } } } catch (Exception ex2) { Log.LogError((object)("The game changed in a way this version of MoonControl does not understand; it will not work: " + ex2)); return; } string text; try { text = " (dll built " + File.GetLastWriteTime(typeof(Plugin).Assembly.Location).ToString("yyyy-MM-dd HH:mm:ss") + ")"; } catch (Exception) { text = ""; } Log.LogInfo((object)("MoonControl 1.0.0 loaded." + text)); } } internal static class Refs { internal static readonly FieldRef<RunManager, int> MoonLevel = AccessTools.FieldRefAccess<RunManager, int>("moonLevel"); internal static readonly FieldRef<RunManager, bool> MoonLevelChanged = AccessTools.FieldRefAccess<RunManager, bool>("moonLevelChanged"); internal static readonly FieldRef<StatsManager, SortedDictionary<string, Dictionary<string, int>>> StatDictionaries = AccessTools.FieldRefAccess<StatsManager, SortedDictionary<string, Dictionary<string, int>>>("dictionaryOfDictionaries"); internal static readonly FieldRef<MenuPage, Vector2> PageOriginalPosition = AccessTools.FieldRefAccess<MenuPage, Vector2>("originalPosition"); internal static readonly FieldRef<MenuPage, RectTransform> PageRect = AccessTools.FieldRefAccess<MenuPage, RectTransform>("rectTransform"); internal static readonly FieldRef<MenuManager, MenuPage> CurrentMenuPage = AccessTools.FieldRefAccess<MenuManager, MenuPage>("currentMenuPage"); internal static readonly FieldRef<ValuableObject, float> DollarValueOriginal = AccessTools.FieldRefAccess<ValuableObject, float>("dollarValueOriginal"); internal static readonly FieldRef<ValuableObject, float> DollarValueCurrent = AccessTools.FieldRefAccess<ValuableObject, float>("dollarValueCurrent"); internal static readonly FieldRef<ValuableObject, bool> DollarValueSet = AccessTools.FieldRefAccess<ValuableObject, bool>("dollarValueSet"); internal static readonly FieldRef<WorldSpaceUIValue, TextMeshProUGUI> WorldSpaceUIText = AccessTools.FieldRefAccess<WorldSpaceUIValue, TextMeshProUGUI>("text"); internal static readonly FieldRef<MenuButton, bool> ButtonHovering = AccessTools.FieldRefAccess<MenuButton, bool>("hovering"); internal static readonly FieldRef<PlayerAvatar, bool> PlayerDisabled = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled"); internal static readonly FieldRef<PhysGrabber, StaticGrabObject> GrabbedStaticGrabObject = AccessTools.FieldRefAccess<PhysGrabber, StaticGrabObject>("grabbedStaticGrabObject"); } }