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 Repo Starfield Menu v1.0.0
EmpressRepoStarfieldMenu.dll
Decompiled 20 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("EmpressRepoStarfieldMenu")] [assembly: AssemblyTitle("EmpressRepoStarfieldMenu")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EmpressRepoStarfieldMenu { [BepInPlugin("empress.repo.starfieldmenu", "Empress REPO Starfield Menu", "1.0.0")] public sealed class EmpressRepoStarfieldMenuPlugin : BaseUnityPlugin { internal const string PluginGuid = "empress.repo.starfieldmenu"; internal const string PluginName = "Empress REPO Starfield Menu"; internal const string PluginVersion = "1.0.0"; internal ConfigEntry<bool> Enabled; internal ConfigEntry<int> MusicVolume; internal ConfigEntry<int> VisualObjectCount; internal ConfigEntry<float> VisualIntensity; private Harmony? _harmony; private EmpressRepoStarfieldMenuRuntime? _runtime; internal static EmpressRepoStarfieldMenuPlugin? Instance { get; private set; } internal static ManualLogSource? EmpressLog { get; private set; } internal string PluginDirectory => Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty; internal string MusicPath => Path.Combine(PluginDirectory, "menumusic.mp3"); private void Awake() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown Instance = this; EmpressLog = ((BaseUnityPlugin)this).Logger; ((Object)this).hideFlags = (HideFlags)(((Object)this).hideFlags | 0x3D); GameObject gameObject = ((Component)this).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x3D); Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Replaces the REPO main menu background with the Empress starfield visualizer."); MusicVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Audio", "Music Volume", 80, new ConfigDescription("Volume for menumusic.mp3.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); VisualObjectCount = ((BaseUnityPlugin)this).Config.Bind<int>("Visuals", "REPO Object Count", 84, new ConfigDescription("How many REPO item and valuable clones fly through the menu.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(24, 140), Array.Empty<object>())); VisualIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Visualizer Intensity", 1.15f, new ConfigDescription("How hard the objects flash, spin, and punch to the music.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 3f), Array.Empty<object>())); _harmony = new Harmony("empress.repo.starfieldmenu"); _harmony.PatchAll(); EnsureRuntime(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress REPO Starfield Menu 1.0.0 loaded."); } internal EmpressRepoStarfieldMenuRuntime EnsureRuntime() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if ((Object)(object)_runtime != (Object)null) { return _runtime; } GameObject val = new GameObject("EmpressRepoStarfieldMenu.Runtime") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)val); _runtime = val.AddComponent<EmpressRepoStarfieldMenuRuntime>(); return _runtime; } } [HarmonyPatch(typeof(MainMenuOpen), "Start")] internal static class EmpressRepoStarfieldMainMenuOpenStartPatch { private static void Postfix() { EmpressRepoStarfieldMenuPlugin.Instance?.EnsureRuntime().RequestRefresh(); } } [HarmonyPatch(typeof(MenuPageMain), "Start")] internal static class EmpressRepoStarfieldMenuPageMainStartPatch { private static void Postfix() { EmpressRepoStarfieldMenuPlugin.Instance?.EnsureRuntime().RequestRefresh(); } } [HarmonyPatch(typeof(TruckMenuAnimated), "Start")] internal static class EmpressRepoStarfieldTruckMenuAnimatedStartPatch { private static void Postfix() { EmpressRepoStarfieldMenuPlugin.Instance?.EnsureRuntime().RequestRefresh(); } } [HarmonyPatch(typeof(CameraNoPlayerTarget), "Update")] internal static class EmpressRepoStarfieldCameraNoPlayerTargetUpdatePatch { private static void Postfix(CameraNoPlayerTarget __instance) { EmpressRepoStarfieldMenuPlugin.Instance?.EnsureRuntime().ApplyMenuCameraRig(__instance, null, null); } } [HarmonyPatch(typeof(CameraPosition), "Update")] internal static class EmpressRepoStarfieldCameraPositionUpdatePatch { private static void Postfix(CameraPosition __instance) { EmpressRepoStarfieldMenuPlugin.Instance?.EnsureRuntime().ApplyMenuCameraRig(null, __instance, null); } } [HarmonyPatch(typeof(CameraAim), "Update")] internal static class EmpressRepoStarfieldCameraAimUpdatePatch { private static void Postfix(CameraAim __instance) { EmpressRepoStarfieldMenuPlugin.Instance?.EnsureRuntime().ApplyMenuCameraRig(null, null, __instance); } } [HarmonyPatch(typeof(LevelMusic), "Update")] internal static class EmpressRepoStarfieldLevelMusicUpdatePatch { private static bool Prefix(LevelMusic __instance) { return !EmpressRepoStarfieldMenuRuntime.ShouldSuppressLevelMusic(__instance); } } [HarmonyPatch(typeof(ConstantMusic), "Update")] internal static class EmpressRepoStarfieldConstantMusicUpdatePatch { private static bool Prefix(ConstantMusic __instance) { return !EmpressRepoStarfieldMenuRuntime.ShouldSuppressConstantMusic(__instance); } } internal enum EmpressFormationMode { Starfield, Sphere, Helix, EqualizerWall, SpiralGate, ShowcaseOrbit } internal sealed class EmpressRepoStarfieldMenuRuntime : MonoBehaviour { private static readonly FieldRef<LevelMusic, AudioSource?> LevelMusicAudioSourceRef = AccessTools.FieldRefAccess<LevelMusic, AudioSource>("audioSource"); private static readonly FieldRef<LevelMusic, bool> LevelMusicActiveRef = AccessTools.FieldRefAccess<LevelMusic, bool>("active"); private static readonly FieldRef<LevelMusic, bool> LevelMusicActivePlayedRef = AccessTools.FieldRefAccess<LevelMusic, bool>("activePlayed"); private static readonly FieldRef<LevelMusic, bool> LevelMusicInterruptRef = AccessTools.FieldRefAccess<LevelMusic, bool>("interrupt"); private static readonly FieldRef<LevelMusic, float> LevelMusicInterruptVolumeRef = AccessTools.FieldRefAccess<LevelMusic, float>("interruptVolume"); private static readonly FieldRef<LevelMusic, float> LevelMusicInterruptVolumeLerpRef = AccessTools.FieldRefAccess<LevelMusic, float>("interruptVolumeLerp"); private static readonly FieldRef<LevelMusic, float> LevelMusicCooldownTimeRef = AccessTools.FieldRefAccess<LevelMusic, float>("cooldownTime"); private static readonly FieldRef<LevelMusic, float> LevelMusicCooldownTimeMinRef = AccessTools.FieldRefAccess<LevelMusic, float>("cooldownTimeMin"); private static readonly FieldRef<ConstantMusic, AudioSource?> ConstantMusicAudioSourceRef = AccessTools.FieldRefAccess<ConstantMusic, AudioSource>("audioSource"); private static readonly FieldRef<ConstantMusic, bool> ConstantMusicSetupRef = AccessTools.FieldRefAccess<ConstantMusic, bool>("setup"); private static readonly FieldRef<StatsManager, Dictionary<string, Item>?> StatsManagerItemDictionaryRef = AccessTools.FieldRefAccess<StatsManager, Dictionary<string, Item>>("itemDictionary"); private static readonly FieldRef<Item, PrefabRef?> ItemPrefabRef = AccessTools.FieldRefAccess<Item, PrefabRef>("prefab"); private static readonly FieldRef<RunManager, List<Level>?> RunManagerLevelsRef = AccessTools.FieldRefAccess<RunManager, List<Level>>("levels"); private static readonly FieldRef<Level, List<LevelValuables>?> LevelValuablePresetsRef = AccessTools.FieldRefAccess<Level, List<LevelValuables>>("ValuablePresets"); private static readonly FieldRef<LevelValuables, List<PrefabRef>?> LevelValuablesTinyRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("tiny"); private static readonly FieldRef<LevelValuables, List<PrefabRef>?> LevelValuablesSmallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("small"); private static readonly FieldRef<LevelValuables, List<PrefabRef>?> LevelValuablesMediumRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("medium"); private static readonly FieldRef<LevelValuables, List<PrefabRef>?> LevelValuablesBigRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("big"); private static readonly FieldRef<LevelValuables, List<PrefabRef>?> LevelValuablesWideRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("wide"); private static readonly FieldRef<LevelValuables, List<PrefabRef>?> LevelValuablesTallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("tall"); private static readonly FieldRef<LevelValuables, List<PrefabRef>?> LevelValuablesVeryTallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("veryTall"); private static readonly FieldRef<EnemyDirector, List<EnemySetup>?> EnemyDirectorDifficulty1Ref = AccessTools.FieldRefAccess<EnemyDirector, List<EnemySetup>>("enemiesDifficulty1"); private static readonly FieldRef<EnemyDirector, List<EnemySetup>?> EnemyDirectorDifficulty2Ref = AccessTools.FieldRefAccess<EnemyDirector, List<EnemySetup>>("enemiesDifficulty2"); private static readonly FieldRef<EnemyDirector, List<EnemySetup>?> EnemyDirectorDifficulty3Ref = AccessTools.FieldRefAccess<EnemyDirector, List<EnemySetup>>("enemiesDifficulty3"); private static readonly FieldRef<EnemySetup, List<PrefabRef>?> EnemySetupSpawnObjectsRef = AccessTools.FieldRefAccess<EnemySetup, List<PrefabRef>>("spawnObjects"); private readonly List<EmpressVisualizerObject> _visualObjects = new List<EmpressVisualizerObject>(); private readonly List<Renderer> _suppressedRenderers = new List<Renderer>(); private readonly List<Behaviour> _suppressedBehaviours = new List<Behaviour>(); private readonly List<ParticleSystem> _suppressedParticles = new List<ParticleSystem>(); private readonly Dictionary<AudioSource, EmpressAudioSourceState> _suppressedAudio = new Dictionary<AudioSource, EmpressAudioSourceState>(); private readonly Dictionary<Camera, EmpressCameraState> _cameraStates = new Dictionary<Camera, EmpressCameraState>(); private readonly float[] _spectrum = new float[512]; private readonly Random _pickRandom = new Random(771777); private GameObject? _sceneRoot; private Transform? _objectRoot; private Transform? _cameraAnchor; private AudioSource? _musicSource; private AudioClip? _musicClip; private Coroutine? _musicLoadCoroutine; private Light? _bassLight; private Light? _trebleLight; private Material? _starMaterial; private bool _menuActive; private bool _refreshRequested = true; private bool _sceneBuilt; private bool _sceneBuildFailed; private bool _musicLoadFailed; private bool _repoObjectsPopulated; private bool _waitingForPrefabsLogged; private float _nextPrefabRetryTime; private EmpressFormationMode _formationMode; private EmpressFormationMode _previousFormationMode; private float _formationChangeTime; private float _formationTransitionSeconds = 7.5f; private float _nextFormationChangeTime; private int _formationObjectCount = 1; private float _bass; private float _mid; private float _treble; private float _fallbackPhase; internal bool FormationActive => false; private void Awake() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) ((Object)this).hideFlags = (HideFlags)(((Object)this).hideFlags | 0x3D); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; _musicSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _musicSource.playOnAwake = false; _musicSource.loop = true; _musicSource.spatialBlend = 0f; _musicSource.priority = 16; } internal void RequestRefresh() { _refreshRequested = true; } private void Update() { bool flag = MenuContextActive(); if (flag != _menuActive) { _menuActive = flag; _refreshRequested = true; } if (_refreshRequested) { RefreshMenuPresentation(); _refreshRequested = false; } if (_menuActive && _sceneBuilt) { SuppressVanillaMenuPresentation(suppress: true); ApplyMenuCameraRig(null, null, null); UpdateMusic(); UpdateSpectrum(); RetryPopulateRepoObjects(); UpdateVisualizerObjects(); } } private void LateUpdate() { if (_menuActive && _sceneBuilt) { ApplyMenuCameraRig(null, null, null); } } private bool MenuContextActive() { EmpressRepoStarfieldMenuPlugin? instance = EmpressRepoStarfieldMenuPlugin.Instance; if (instance == null || !instance.Enabled.Value) { return false; } if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent == (Object)null || (Object)(object)RunManager.instance.levelMainMenu == (Object)null) { return false; } return RunManager.instance.levelCurrent == RunManager.instance.levelMainMenu; } private void RefreshMenuPresentation() { if (!_menuActive) { if ((Object)(object)_sceneRoot != (Object)null) { _sceneRoot.SetActive(false); } SuppressVanillaMenuPresentation(suppress: false); if ((Object)(object)_musicSource != (Object)null) { _musicSource.Stop(); } } else if (_sceneBuildFailed) { SuppressVanillaMenuPresentation(suppress: false); } else { EnsureSceneBuilt(); if ((Object)(object)_sceneRoot != (Object)null) { _sceneRoot.SetActive(true); } } } private void EnsureSceneBuilt() { if (_sceneBuilt || _sceneBuildFailed) { return; } try { BuildScene(); _sceneBuilt = true; ManualLogSource? empressLog = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog != null) { empressLog.LogInfo((object)$"Built REPO starfield menu with {_visualObjects.Count} visual objects."); } } catch (Exception arg) { _sceneBuildFailed = true; ManualLogSource? empressLog2 = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog2 != null) { empressLog2.LogError((object)$"Failed to build REPO starfield menu: {arg}"); } } } private void BuildScene() { //IL_0006: 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_0018: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00ce: 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_0108: 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_014b: Unknown result type (might be due to invalid IL or missing references) _sceneRoot = new GameObject("EmpressRepoStarfieldMenu.Scene") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)_sceneRoot); _cameraAnchor = new GameObject("Camera Anchor").transform; _cameraAnchor.SetParent(_sceneRoot.transform, false); _cameraAnchor.position = new Vector3(0f, 1.45f, -17.5f); _cameraAnchor.rotation = Quaternion.Euler(5.5f, 0f, 0f); _objectRoot = new GameObject("REPO Starfield Objects").transform; _objectRoot.SetParent(_sceneRoot.transform, false); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.035f, 0.045f, 0.075f); RenderSettings.fog = false; _bassLight = CreateLight("Bass Flash", new Vector3(-3.5f, 1.2f, -4.5f), new Color(0.15f, 0.95f, 1f), 3.5f, 14f); _trebleLight = CreateLight("Treble Flash", new Vector3(3.5f, 2.8f, 4f), new Color(1f, 0.12f, 0.78f), 2.2f, 18f); CreateBackdrop(); CreateStarDots(120); _repoObjectsPopulated = CreateVisualObjects(); _nextPrefabRetryTime = Time.unscaledTime + 1f; _formationChangeTime = Time.unscaledTime; _nextFormationChangeTime = Time.unscaledTime + 18f; } private Light CreateLight(string objectName, Vector3 position, Color color, float intensity, float range) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(objectName) { hideFlags = (HideFlags)61 }; val.transform.SetParent(_sceneRoot.transform, false); val.transform.localPosition = position; Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = color; obj.intensity = intensity; obj.range = range; return obj; } private void CreateBackdrop() { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_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) Material val = new Material(Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default")) { hideFlags = (HideFlags)61, color = new Color(0.006f, 0.008f, 0.014f, 1f) }; if (val.HasProperty("_Cull")) { val.SetInt("_Cull", 0); } GameObject val2 = new GameObject("Empress Dark Stage") { hideFlags = (HideFlags)61 }; val2.transform.SetParent(_cameraAnchor, false); val2.transform.localPosition = new Vector3(0f, 0f, 78f); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = new Vector3(1000f, 600f, 1f); val2.AddComponent<MeshFilter>().sharedMesh = CreateQuadMesh(); MeshRenderer obj = val2.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = val; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; ((Renderer)obj).lightProbeUsage = (LightProbeUsage)0; ((Renderer)obj).reflectionProbeUsage = (ReflectionProbeUsage)0; } private void CreateStarDots(int count) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0045: 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_0063: 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_007d: 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) _starMaterial = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color")) { hideFlags = (HideFlags)61 }; _starMaterial.color = new Color(0.6f, 0.9f, 1f, 0.8f); Mesh sharedMesh = CreateQuadMesh(); for (int i = 0; i < count; i++) { GameObject val = new GameObject("Star Dot") { hideFlags = (HideFlags)61 }; val.transform.SetParent(_objectRoot, false); val.AddComponent<MeshFilter>().sharedMesh = sharedMesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = _starMaterial; EmpressVisualizerObject empressVisualizerObject = val.AddComponent<EmpressVisualizerObject>(); empressVisualizerObject.InitializeAsStar(this, Random.Range(0.025f, 0.08f)); _visualObjects.Add(empressVisualizerObject); } } private static Mesh CreateQuadMesh() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_004c: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e6: 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) Mesh val = new Mesh { name = "Empress Star Quad", hideFlags = (HideFlags)61 }; val.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(0.5f, 0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f) }; val.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; val.triangles = new int[6] { 0, 1, 2, 0, 2, 3 }; val.RecalculateBounds(); return val; } private bool CreateVisualObjects() { List<GameObject> list = CollectRepoVisualPrefabs(); List<GameObject> list2 = CollectEnemyVisualPrefabs(); if (list.Count == 0 && list2.Count == 0) { if (!_waitingForPrefabsLogged) { _waitingForPrefabsLogged = true; ManualLogSource? empressLog = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog != null) { empressLog.LogInfo((object)"Waiting for REPO item, valuable, and enemy prefabs before filling the visualizer."); } } return false; } int num = Mathf.Clamp(EmpressRepoStarfieldMenuPlugin.Instance?.VisualObjectCount.Value ?? 84, 24, 140); int visualIndex = 0; int num2 = CreateVisualizerClones(list, num, "Visualizer", isEnemy: false, ref visualIndex); int targetCount = ((list2.Count != 0) ? Mathf.Clamp(num / 3, 12, 42) : 0); int num3 = CreateVisualizerClones(list2, targetCount, "Enemy Visualizer", isEnemy: true, ref visualIndex); num2 += num3; _formationObjectCount = Mathf.Max(1, visualIndex); if (num2 > 0) { ManualLogSource? empressLog2 = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog2 != null) { empressLog2.LogInfo((object)$"Added {num2} REPO visual prefabs to the menu visualizer, including {num3} enemy clone(s)."); } } return num2 > 0; } private int CreateVisualizerClones(List<GameObject> prefabs, int targetCount, string namePrefix, bool isEnemy, ref int visualIndex) { if (prefabs.Count == 0 || targetCount <= 0) { return 0; } int num = 0; for (int i = 0; i < targetCount; i++) { GameObject val = prefabs[_pickRandom.Next(prefabs.Count)]; if (!((Object)(object)val == (Object)null)) { bool activeSelf = val.activeSelf; GameObject val2; try { val.SetActive(false); val2 = Object.Instantiate<GameObject>(val, _objectRoot); } finally { val.SetActive(activeSelf); } ((Object)val2).name = namePrefix + " " + CleanPrefabName(((Object)val).name); ((Object)val2).hideFlags = (HideFlags)61; StripGameplayComponents(val2); val2.SetActive(true); if (!HasRenderableGeometry(val2)) { Object.Destroy((Object)(object)val2); continue; } FitCloneScale(val2, isEnemy); EmpressVisualizerObject empressVisualizerObject = val2.AddComponent<EmpressVisualizerObject>(); empressVisualizerObject.InitializeAsRepoObject(this, visualIndex, isEnemy); _visualObjects.Add(empressVisualizerObject); visualIndex++; num++; } } return num; } private List<GameObject> CollectRepoVisualPrefabs() { Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase); try { if ((Object)(object)StatsManager.instance != (Object)null) { Dictionary<string, Item> dictionary2 = StatsManagerItemDictionaryRef.Invoke(StatsManager.instance); if (dictionary2 != null) { foreach (Item item in dictionary2.Values.Where((Item item) => (Object)(object)item != (Object)null)) { PrefabRef prefabRef = ItemPrefabRef.Invoke(item); AddPrefab(dictionary, prefabRef); } } } } catch (Exception ex) { ManualLogSource? empressLog = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog != null) { empressLog.LogWarning((object)("Could not collect REPO item prefabs yet: " + ex.Message)); } } try { if ((Object)(object)RunManager.instance != (Object)null) { List<Level> list = RunManagerLevelsRef.Invoke(RunManager.instance); if (list != null) { foreach (Level item2 in list.Where((Level level) => (Object)(object)level != (Object)null)) { List<LevelValuables> list2 = LevelValuablePresetsRef.Invoke(item2); if (list2 == null) { continue; } foreach (LevelValuables item3 in list2.Where((LevelValuables preset) => (Object)(object)preset != (Object)null)) { AddPrefabList(dictionary, LevelValuablesTinyRef.Invoke(item3)); AddPrefabList(dictionary, LevelValuablesSmallRef.Invoke(item3)); AddPrefabList(dictionary, LevelValuablesMediumRef.Invoke(item3)); AddPrefabList(dictionary, LevelValuablesBigRef.Invoke(item3)); AddPrefabList(dictionary, LevelValuablesWideRef.Invoke(item3)); AddPrefabList(dictionary, LevelValuablesTallRef.Invoke(item3)); AddPrefabList(dictionary, LevelValuablesVeryTallRef.Invoke(item3)); } } } } } catch (Exception ex2) { ManualLogSource? empressLog2 = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog2 != null) { empressLog2.LogWarning((object)("Could not collect REPO valuable prefabs yet: " + ex2.Message)); } } return dictionary.Values.ToList(); } private List<GameObject> CollectEnemyVisualPrefabs() { Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase); try { if ((Object)(object)EnemyDirector.instance != (Object)null) { AddEnemySetupList(dictionary, EnemyDirectorDifficulty1Ref.Invoke(EnemyDirector.instance)); AddEnemySetupList(dictionary, EnemyDirectorDifficulty2Ref.Invoke(EnemyDirector.instance)); AddEnemySetupList(dictionary, EnemyDirectorDifficulty3Ref.Invoke(EnemyDirector.instance)); } foreach (EnemySetup item in from enemySetup in Resources.FindObjectsOfTypeAll<EnemySetup>() where (Object)(object)enemySetup != (Object)null select enemySetup) { AddEnemySetup(dictionary, item); } } catch (Exception ex) { ManualLogSource? empressLog = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog != null) { empressLog.LogWarning((object)("Could not collect REPO enemy prefabs yet: " + ex.Message)); } } return dictionary.Values.ToList(); } private static void AddEnemySetupList(Dictionary<string, GameObject> prefabs, List<EnemySetup>? enemySetups) { if (enemySetups == null) { return; } foreach (EnemySetup item in enemySetups.Where((EnemySetup enemySetup) => (Object)(object)enemySetup != (Object)null)) { AddEnemySetup(prefabs, item); } } private static void AddEnemySetup(Dictionary<string, GameObject> prefabs, EnemySetup enemySetup) { List<PrefabRef> list = EnemySetupSpawnObjectsRef.Invoke(enemySetup); if (list == null) { return; } foreach (PrefabRef item in list.Where((PrefabRef prefabRef) => prefabRef != null)) { AddPrefab(prefabs, item); } } private static void AddPrefabList(Dictionary<string, GameObject> prefabs, List<PrefabRef>? refs) { if (refs == null) { return; } foreach (PrefabRef item in refs.Where((PrefabRef prefabRef) => prefabRef != null)) { AddPrefab(prefabs, item); } } private static void AddPrefab(Dictionary<string, GameObject> prefabs, PrefabRef? prefabRef) { if (prefabRef != null && prefabRef.IsValid()) { GameObject prefab = prefabRef.Prefab; if (!((Object)(object)prefab == (Object)null)) { string key = ((!string.IsNullOrWhiteSpace(prefabRef.ResourcePath)) ? prefabRef.ResourcePath : ((Object)prefab).name); prefabs[key] = prefab; } } } private void RetryPopulateRepoObjects() { if (!_repoObjectsPopulated && !(Time.unscaledTime < _nextPrefabRetryTime)) { _repoObjectsPopulated = CreateVisualObjects(); _nextPrefabRetryTime = Time.unscaledTime + 1f; } } private static string CleanPrefabName(string name) { return name.Replace("(Clone)", string.Empty).Replace("Item ", string.Empty).Replace("Valuable ", string.Empty) .Trim(); } private static bool HasRenderableGeometry(GameObject root) { return root.GetComponentsInChildren<Renderer>(true).Any((Renderer renderer) => (Object)(object)renderer != (Object)null && (renderer is MeshRenderer || renderer is SkinnedMeshRenderer)); } private static void StripGameplayComponents(GameObject root) { Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { try { ((Component)val).gameObject.tag = "Untagged"; } catch { } } } Component[] componentsInChildren2 = root.GetComponentsInChildren<Component>(true); for (int num = componentsInChildren2.Length - 1; num >= 0; num--) { Component val2 = componentsInChildren2[num]; if (val2 is MonoBehaviour) { Object.DestroyImmediate((Object)(object)val2); } } componentsInChildren2 = root.GetComponentsInChildren<Component>(true); for (int num2 = componentsInChildren2.Length - 1; num2 >= 0; num2--) { Component val3 = componentsInChildren2[num2]; if (!((Object)(object)val3 == (Object)null) && !IsAllowedVisualComponent(val3)) { Object.DestroyImmediate((Object)(object)val3); } } } private static bool IsAllowedVisualComponent(Component component) { if (!(component is Transform) && !(component is MeshFilter) && !(component is MeshRenderer) && !(component is SkinnedMeshRenderer) && !(component is Animator)) { return component is Animation; } return true; } private static void FitCloneScale(GameObject clone, bool isEnemy) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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) Renderer[] componentsInChildren = clone.GetComponentsInChildren<Renderer>(true); if (componentsInChildren.Length != 0) { Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } float num = Mathf.Max(((Bounds)(ref bounds)).size.x, Mathf.Max(((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z)); if (!(num <= 0.001f)) { float num2 = Mathf.Clamp((isEnemy ? Random.Range(2.2f, 3.65f) : Random.Range(0.65f, 1.75f)) / num, 0.05f, isEnemy ? 4.5f : 2.5f); clone.transform.localScale = Vector3.one * num2; } } } private void UpdateMusic() { if ((Object)(object)_musicSource == (Object)null) { return; } _musicSource.volume = Mathf.Clamp01((float)(EmpressRepoStarfieldMenuPlugin.Instance?.MusicVolume.Value ?? 80) / 100f); if ((Object)(object)_musicClip == (Object)null) { if (_musicLoadCoroutine == null && !_musicLoadFailed) { _musicLoadCoroutine = ((MonoBehaviour)this).StartCoroutine(LoadMusicCoroutine()); } return; } if (_musicSource.clip != _musicClip) { _musicSource.clip = _musicClip; } if (!_musicSource.isPlaying) { _musicSource.Play(); } } private IEnumerator LoadMusicCoroutine() { string text = EmpressRepoStarfieldMenuPlugin.Instance?.MusicPath ?? string.Empty; if (string.IsNullOrWhiteSpace(text) || !File.Exists(text)) { _musicLoadFailed = true; ManualLogSource? empressLog = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog != null) { empressLog.LogWarning((object)"menumusic.mp3 was not found beside the DLL."); } _musicLoadCoroutine = null; yield break; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(text).AbsoluteUri, (AudioType)13); try { yield return request.SendWebRequest(); if ((int)request.result == 1) { _musicClip = DownloadHandlerAudioClip.GetContent(request); if ((Object)(object)_musicClip != (Object)null) { ((Object)_musicClip).name = "EmpressRepoStarfieldMenuMusic"; } } else { _musicLoadFailed = true; ManualLogSource? empressLog2 = EmpressRepoStarfieldMenuPlugin.EmpressLog; if (empressLog2 != null) { empressLog2.LogWarning((object)("menumusic.mp3 failed to load: " + request.error)); } } _musicLoadCoroutine = null; } finally { ((IDisposable)request)?.Dispose(); } } private void UpdateSpectrum() { if ((Object)(object)_musicSource != (Object)null && _musicSource.isPlaying) { _musicSource.GetSpectrumData(_spectrum, 0, (FFTWindow)5); float num = AverageSpectrum(1, 14) * 95f; float num2 = AverageSpectrum(15, 80) * 160f; float num3 = AverageSpectrum(90, 320) * 380f; _bass = Mathf.Lerp(_bass, Mathf.Clamp01(num), Time.unscaledDeltaTime * 12f); _mid = Mathf.Lerp(_mid, Mathf.Clamp01(num2), Time.unscaledDeltaTime * 10f); _treble = Mathf.Lerp(_treble, Mathf.Clamp01(num3), Time.unscaledDeltaTime * 16f); } else { _fallbackPhase += Time.unscaledDeltaTime; _bass = Mathf.Lerp(_bass, 0.45f + Mathf.Sin(_fallbackPhase * 3.1f) * 0.25f, Time.unscaledDeltaTime * 4f); _mid = Mathf.Lerp(_mid, 0.35f + Mathf.Sin(_fallbackPhase * 4.7f) * 0.2f, Time.unscaledDeltaTime * 4f); _treble = Mathf.Lerp(_treble, 0.3f + Mathf.Sin(_fallbackPhase * 9.5f) * 0.18f, Time.unscaledDeltaTime * 4f); } float num4 = EmpressRepoStarfieldMenuPlugin.Instance?.VisualIntensity.Value ?? 1.15f; if ((Object)(object)_bassLight != (Object)null) { _bassLight.intensity = 1.25f + _bass * 8f * num4; } if ((Object)(object)_trebleLight != (Object)null) { _trebleLight.intensity = 0.8f + _treble * 7f * num4; } } private float AverageSpectrum(int start, int end) { float num = 0f; int num2 = 0; end = Mathf.Min(end, _spectrum.Length - 1); for (int i = start; i <= end; i++) { num += _spectrum[i]; num2++; } if (num2 != 0) { return num / (float)num2; } return 0f; } private void UpdateVisualizerObjects() { float intensity = EmpressRepoStarfieldMenuPlugin.Instance?.VisualIntensity.Value ?? 1.15f; for (int num = _visualObjects.Count - 1; num >= 0; num--) { if ((Object)(object)_visualObjects[num] == (Object)null) { _visualObjects.RemoveAt(num); } else { _visualObjects[num].VisualizerTick(_bass, _mid, _treble, intensity); } } } private void UpdateFormationMode() { if (_nextFormationChangeTime <= 0f) { _formationChangeTime = Time.unscaledTime; _nextFormationChangeTime = Time.unscaledTime + 18f; } else if (!(Time.unscaledTime < _nextFormationChangeTime)) { _previousFormationMode = _formationMode; _formationMode = NextFormationMode(_formationMode); _formationChangeTime = Time.unscaledTime; _formationTransitionSeconds = Random.Range(6.5f, 9f); _nextFormationChangeTime = Time.unscaledTime + Random.Range(22f, 34f); } } private static EmpressFormationMode NextFormationMode(EmpressFormationMode current) { return current switch { EmpressFormationMode.Starfield => EmpressFormationMode.Helix, EmpressFormationMode.Helix => EmpressFormationMode.EqualizerWall, EmpressFormationMode.EqualizerWall => EmpressFormationMode.SpiralGate, EmpressFormationMode.SpiralGate => EmpressFormationMode.ShowcaseOrbit, EmpressFormationMode.ShowcaseOrbit => EmpressFormationMode.Sphere, _ => EmpressFormationMode.Starfield, }; } internal void ResetVisualizerTransform(EmpressVisualizerObject visualObject) { //IL_007d: 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) float num = (visualObject.IsStar ? Random.Range(5f, 16f) : Random.Range(2f, 10.5f)); float num2 = Random.Range(0f, MathF.PI * 2f); float num3 = Random.Range(12f, 56f); Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor(Mathf.Cos(num2) * num, Mathf.Sin(num2) * num * 0.62f + Random.Range(-1.4f, 1.8f), num3); ((Component)visualObject).transform.localPosition = localPosition; ((Component)visualObject).transform.localRotation = Random.rotation; visualObject.DepthSpeed = Random.Range(3.5f, 9.5f); visualObject.OrbitAngle = num2; visualObject.OrbitRadius = num; visualObject.OrbitSpeed = Random.Range(-0.35f, 0.35f); } internal Vector3 GetFormationTarget(EmpressVisualizerObject visualObject, float bass, float mid, float treble) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) Vector3 formationTargetForMode = GetFormationTargetForMode(_formationMode, visualObject, bass, mid, treble); if (_previousFormationMode == _formationMode) { return formationTargetForMode; } float num = Mathf.Clamp01((Time.unscaledTime - _formationChangeTime) / Mathf.Max(0.1f, _formationTransitionSeconds)); num = num * num * (3f - 2f * num); return Vector3.Lerp(GetFormationTargetForMode(_previousFormationMode, visualObject, bass, mid, treble), formationTargetForMode, num); } private Vector3 GetFormationTargetForMode(EmpressFormationMode mode, EmpressVisualizerObject visualObject, float bass, float mid, float treble) { //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: 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) float num = visualObject.VisualIndex; float num2 = Mathf.Max(1, _formationObjectCount); float num3 = (num + 0.5f) / num2; float unscaledTime = Time.unscaledTime; float num4 = (visualObject.IsEnemy ? 0.75f : 0f); switch (mode) { case EmpressFormationMode.Starfield: { float num19 = num % 36f; float num20 = Mathf.Floor(num / 36f); float num21 = num19 / 36f * MathF.PI * 2f + unscaledTime * (0.11f + treble * 0.18f) + num20 * 0.41f; float num22 = 2.2f + num20 % 5f * 0.72f + bass * 1.1f + (visualObject.IsEnemy ? 1.3f : 0f); float num23 = 12f + Mathf.Repeat(num * 1.71f - unscaledTime * (1.7f + bass * 2.2f), 26f); return new Vector3(Mathf.Cos(num21) * num22 * 1.35f, Mathf.Sin(num21) * num22 * 0.58f + Mathf.Sin(unscaledTime * 0.7f + num) * 0.35f + num4, num23); } case EmpressFormationMode.Sphere: { float num27 = 1f - 2f * num3; float num28 = Mathf.Sqrt(Mathf.Max(0f, 1f - num27 * num27)); float num29 = num * 2.399963f + unscaledTime * (0.16f + treble * 0.45f); float num30 = 7.2f + bass * 1.2f + (visualObject.IsEnemy ? 1.7f : 0f); return new Vector3(Mathf.Cos(num29) * num28 * num30, num27 * 4.4f + num4 + Mathf.Sin(unscaledTime * 1.1f + num) * mid * 0.8f, 21f + Mathf.Sin(num29 + unscaledTime * 0.22f) * 5.2f); } case EmpressFormationMode.Helix: { float num10 = num * 0.42f + unscaledTime * (0.42f + treble * 0.85f); float num11 = 3.2f + num % 6f * 0.28f + bass * 1.7f + (visualObject.IsEnemy ? 1.4f : 0f); float num12 = 10f + Mathf.Repeat(num * 0.93f + unscaledTime * (0.55f + bass), 25f); return new Vector3(Mathf.Cos(num10) * num11 * 1.45f, Mathf.Sin(num10) * num11 * 0.72f + num4, num12); } case EmpressFormationMode.EqualizerWall: { int num13 = 14; float num14 = visualObject.VisualIndex % num13; float num15 = Mathf.Floor((float)(visualObject.VisualIndex / num13)) % 8f; float num16 = num14 / ((float)num13 - 1f); float num17 = Mathf.Lerp(bass, treble, num16); float num18 = Mathf.Sin(unscaledTime * (1.1f + num16 * 1.2f) + num15 * 0.8f) * (0.25f + num17 * 1.6f); return new Vector3((num14 - ((float)num13 - 1f) * 0.5f) * 1.12f, (num15 - 3.5f) * 0.78f + num18 + num4, 18.5f + Mathf.Sin(unscaledTime * 0.45f + num14) * 2.2f); } case EmpressFormationMode.SpiralGate: { float num24 = num * 0.31f + unscaledTime * (0.55f + bass * 0.9f); float num25 = 2.1f + num % 40f * 0.17f + treble * 1.55f + (visualObject.IsEnemy ? 1.6f : 0f); float num26 = 19f + Mathf.Sin(num * 0.18f + unscaledTime * 0.72f) * 5.8f; return new Vector3(Mathf.Cos(num24) * num25 * 1.18f, Mathf.Sin(num24) * num25 * 0.82f + num4, num26); } case EmpressFormationMode.ShowcaseOrbit: { float num5 = num % 3f; float num6 = num3 * MathF.PI * 2f + unscaledTime * (0.18f + num5 * 0.04f); float num7 = 4.4f + num5 * 1.45f + bass * 1.2f + (visualObject.IsEnemy ? 1.8f : 0f); float num8 = 17f + num5 * 4f + Mathf.Sin(num6 * 2f + unscaledTime * 0.3f) * 1.4f; float num9 = Mathf.Sin(num6 * 1.5f + num5) * 2.2f + num4; return new Vector3(Mathf.Cos(num6) * num7 * 1.42f, num9, num8); } default: return ((Component)visualObject).transform.localPosition; } } internal static bool ShouldSuppressLevelMusic(LevelMusic levelMusic) { if (!RuntimeMenuContextActive()) { return false; } AudioSource val = LevelMusicAudioSourceRef.Invoke(levelMusic); if ((Object)(object)val != (Object)null) { val.Stop(); val.mute = true; } LevelMusicActiveRef.Invoke(levelMusic) = false; LevelMusicActivePlayedRef.Invoke(levelMusic) = false; LevelMusicInterruptRef.Invoke(levelMusic) = false; LevelMusicInterruptVolumeRef.Invoke(levelMusic) = 0f; LevelMusicInterruptVolumeLerpRef.Invoke(levelMusic) = 0f; LevelMusicCooldownTimeRef.Invoke(levelMusic) = LevelMusicCooldownTimeMinRef.Invoke(levelMusic); return true; } internal static bool ShouldSuppressConstantMusic(ConstantMusic constantMusic) { if (!RuntimeMenuContextActive()) { return false; } AudioSource val = ConstantMusicAudioSourceRef.Invoke(constantMusic); if ((Object)(object)val != (Object)null) { val.Stop(); val.mute = true; } ConstantMusicSetupRef.Invoke(constantMusic) = false; return true; } private static bool RuntimeMenuContextActive() { EmpressRepoStarfieldMenuPlugin? instance = EmpressRepoStarfieldMenuPlugin.Instance; if (instance == null || !instance.Enabled.Value) { return false; } if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent == (Object)null || (Object)(object)RunManager.instance.levelMainMenu == (Object)null) { return false; } return RunManager.instance.levelCurrent == RunManager.instance.levelMainMenu; } internal void ApplyMenuCameraRig(CameraNoPlayerTarget? noPlayerTarget, CameraPosition? cameraPosition, CameraAim? cameraAim) { //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_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_003e: 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_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_0076: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (_menuActive && !((Object)(object)_cameraAnchor == (Object)null)) { Vector3 position = _cameraAnchor.position; Quaternion rotation = _cameraAnchor.rotation; if ((Object)(object)noPlayerTarget != (Object)null) { ((Component)noPlayerTarget).transform.SetPositionAndRotation(position, rotation); ApplyCamera(((Component)noPlayerTarget).GetComponent<Camera>()); } if ((Object)(object)cameraPosition != (Object)null) { ((Component)cameraPosition).transform.SetPositionAndRotation(position, rotation); } if ((Object)(object)cameraAim != (Object)null) { ((Component)cameraAim).transform.rotation = rotation; } if ((Object)(object)CameraNoPlayerTarget.instance != (Object)null) { ((Component)CameraNoPlayerTarget.instance).transform.SetPositionAndRotation(position, rotation); ApplyCamera(((Component)CameraNoPlayerTarget.instance).GetComponent<Camera>()); } if ((Object)(object)Camera.main != (Object)null) { ((Component)Camera.main).transform.SetPositionAndRotation(position, rotation); ApplyCamera(Camera.main); } } } private void ApplyCamera(Camera? camera) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)camera == (Object)null)) { if (!_cameraStates.ContainsKey(camera)) { _cameraStates[camera] = new EmpressCameraState(camera); } ((Behaviour)camera).enabled = true; camera.fieldOfView = 72f + _bass * 4f; camera.nearClipPlane = 0.03f; camera.farClipPlane = 90f; camera.clearFlags = (CameraClearFlags)2; camera.backgroundColor = Color.black; } } private void SuppressVanillaMenuPresentation(bool suppress) { if (!suppress) { foreach (Behaviour item in _suppressedBehaviours.Where((Behaviour item) => (Object)(object)item != (Object)null)) { item.enabled = true; } foreach (Renderer item2 in _suppressedRenderers.Where((Renderer item) => (Object)(object)item != (Object)null)) { item2.enabled = true; } foreach (ParticleSystem item3 in _suppressedParticles.Where((ParticleSystem item) => (Object)(object)item != (Object)null)) { item3.Play(true); } KeyValuePair<AudioSource, EmpressAudioSourceState>[] array = _suppressedAudio.Where<KeyValuePair<AudioSource, EmpressAudioSourceState>>((KeyValuePair<AudioSource, EmpressAudioSourceState> item) => (Object)(object)item.Key != (Object)null).ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair<AudioSource, EmpressAudioSourceState> keyValuePair = array[i]; keyValuePair.Value.Restore(keyValuePair.Key); } KeyValuePair<Camera, EmpressCameraState>[] array2 = _cameraStates.Where<KeyValuePair<Camera, EmpressCameraState>>((KeyValuePair<Camera, EmpressCameraState> item) => (Object)(object)item.Key != (Object)null).ToArray(); for (int i = 0; i < array2.Length; i++) { KeyValuePair<Camera, EmpressCameraState> keyValuePair2 = array2[i]; keyValuePair2.Value.Restore(keyValuePair2.Key); } _suppressedBehaviours.Clear(); _suppressedRenderers.Clear(); _suppressedParticles.Clear(); _suppressedAudio.Clear(); _cameraStates.Clear(); return; } TruckMenuAnimated[] array3 = Object.FindObjectsOfType<TruckMenuAnimated>(true); foreach (TruckMenuAnimated val in array3) { if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled) { _suppressedBehaviours.Add((Behaviour)(object)val); ((Behaviour)val).enabled = false; } } Renderer[] array4 = Object.FindObjectsOfType<Renderer>(true); foreach (Renderer val2 in array4) { if (!((Object)(object)val2 == (Object)null) && val2.enabled && ShouldSuppressMenuVisual(((Component)val2).transform)) { _suppressedRenderers.Add(val2); val2.enabled = false; } } ParticleSystem[] array5 = Object.FindObjectsOfType<ParticleSystem>(true); foreach (ParticleSystem val3 in array5) { if (!((Object)(object)val3 == (Object)null) && val3.isPlaying && ShouldSuppressMenuVisual(((Component)val3).transform)) { _suppressedParticles.Add(val3); val3.Stop(true, (ParticleSystemStopBehavior)0); } } AudioSource[] array6 = Object.FindObjectsOfType<AudioSource>(true); foreach (AudioSource val4 in array6) { if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4 == (Object)(object)_musicSource) && ShouldSuppressMenuAudio(val4)) { if (!_suppressedAudio.ContainsKey(val4)) { _suppressedAudio[val4] = new EmpressAudioSourceState(val4); } val4.Pause(); val4.mute = true; } } } private bool ShouldSuppressMenuVisual(Transform candidate) { if ((Object)(object)candidate == (Object)null) { return false; } if ((Object)(object)_sceneRoot != (Object)null && candidate.IsChildOf(_sceneRoot.transform)) { return false; } if ((Object)(object)((Component)candidate).GetComponentInParent<Canvas>(true) != (Object)null || (Object)(object)((Component)candidate).GetComponentInParent<MenuPage>(true) != (Object)null || (Object)(object)((Component)candidate).GetComponentInParent<MenuButton>(true) != (Object)null) { return false; } return true; } private bool ShouldSuppressMenuAudio(AudioSource source) { if ((Object)(object)_sceneRoot != (Object)null && ((Component)source).transform.IsChildOf(_sceneRoot.transform)) { return false; } if ((Object)(object)((Component)source).GetComponentInParent<MenuPage>(true) != (Object)null || (Object)(object)((Component)source).GetComponentInParent<MenuButton>(true) != (Object)null) { return false; } if (!source.loop) { return LooksLikeBackgroundAudio(source); } return true; } private static bool LooksLikeBackgroundAudio(AudioSource source) { string text = TransformPath(((Component)source).transform).ToLowerInvariant(); if (!text.Contains("music") && !text.Contains("ambience") && !text.Contains("ambient") && !text.Contains("truck") && !text.Contains("mainmenu")) { return text.Contains("main menu"); } return true; } private static string TransformPath(Transform transformNode) { List<string> list = new List<string>(); while ((Object)(object)transformNode != (Object)null) { list.Add(((Object)transformNode).name); transformNode = transformNode.parent; } list.Reverse(); return string.Join("/", list); } } internal sealed class EmpressVisualizerObject : MonoBehaviour { private readonly List<EmpressMaterialPulseState> _materialStates = new List<EmpressMaterialPulseState>(); private Vector3 _baseScale; private Color _baseColor; private float _spinMultiplier; private float _pulseOffset; private EmpressRepoStarfieldMenuRuntime? _runtime; private int _visualIndex; private bool _isEnemy; private bool _isStar; internal bool IsStar => _isStar; internal bool IsEnemy => _isEnemy; internal int VisualIndex => _visualIndex; internal float DepthSpeed { get; set; } internal float OrbitAngle { get; set; } internal float OrbitRadius { get; set; } internal float OrbitSpeed { get; set; } internal void InitializeAsRepoObject(EmpressRepoStarfieldMenuRuntime runtime, int index, bool isEnemy) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) _runtime = runtime; _visualIndex = index; _isEnemy = isEnemy; _isStar = false; _baseScale = ((Component)this).transform.localScale; _spinMultiplier = Random.Range(isEnemy ? 0.35f : 0.55f, isEnemy ? 1.35f : 2.25f); _pulseOffset = (float)index * 0.37f; CaptureMaterials(); _baseColor = AverageMaterialColor(); runtime.ResetVisualizerTransform(this); } internal void InitializeAsStar(EmpressRepoStarfieldMenuRuntime runtime, float size) { //IL_001d: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) _runtime = runtime; _visualIndex = -1; _isEnemy = false; _isStar = true; _baseScale = Vector3.one * size; _spinMultiplier = Random.Range(0.5f, 1.25f); _pulseOffset = Random.Range(0f, 20f); CaptureMaterials(); _baseColor = new Color(0.55f, 0.9f, 1f, 1f); runtime.ResetVisualizerTransform(this); } internal void VisualizerTick(float bass, float mid, float treble, float intensity) { //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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0097: 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_009c: 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_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) float unscaledDeltaTime = Time.unscaledDeltaTime; OrbitAngle += OrbitSpeed * unscaledDeltaTime * (1f + treble * 2.5f); Vector3 val = ((Component)this).transform.localPosition; if (!_isStar && (Object)(object)_runtime != (Object)null && _runtime.FormationActive) { Vector3 formationTarget = _runtime.GetFormationTarget(this, bass, mid, treble); float num = 1f - Mathf.Exp((0f - unscaledDeltaTime) * (0.78f + bass * 1.45f + treble * 0.85f)); val = Vector3.Lerp(val, formationTarget, num); val.x += Mathf.Sin(Time.unscaledTime * (1.15f + _spinMultiplier * 0.4f) + _pulseOffset) * unscaledDeltaTime * treble * 0.38f * intensity; val.y += Mathf.Cos(Time.unscaledTime * (0.9f + _spinMultiplier * 0.35f) + _pulseOffset) * unscaledDeltaTime * mid * 0.32f * intensity; } else { val.z -= DepthSpeed * unscaledDeltaTime * (1f + bass * 3.75f * intensity); val.x += Mathf.Sin(Time.unscaledTime * (0.9f + _spinMultiplier) + _pulseOffset) * unscaledDeltaTime * treble * 2.2f * intensity; val.y += Mathf.Cos(Time.unscaledTime * (0.75f + _spinMultiplier) + _pulseOffset) * unscaledDeltaTime * mid * 1.5f * intensity; if (val.z < -14f) { (_runtime ?? EmpressRepoStarfieldMenuPlugin.Instance?.EnsureRuntime())?.ResetVisualizerTransform(this); val = ((Component)this).transform.localPosition; } } ((Component)this).transform.localPosition = val; float num2 = (_isStar ? (1f + (treble * 4f + bass * 1.2f) * intensity) : (1f + (bass * (_isEnemy ? 0.32f : 0.55f) + treble * (_isEnemy ? 0.14f : 0.22f)) * intensity)); float num3 = 1f + Mathf.Sin(Time.unscaledTime * (5f + _spinMultiplier * 2f) + _pulseOffset) * 0.08f * (1f + treble); ((Component)this).transform.localScale = _baseScale * num2 * num3; float num4 = (25f + treble * (_isEnemy ? 170f : 420f) + bass * (_isEnemy ? 75f : 120f)) * _spinMultiplier * unscaledDeltaTime * intensity; ((Component)this).transform.Rotate(31f * unscaledDeltaTime + num4, 57f * unscaledDeltaTime + num4 * 0.6f, 23f * unscaledDeltaTime + num4 * 0.35f, (Space)1); UpdateMaterials(bass, mid, treble, intensity); } private void UpdateMaterials(float bass, float mid, float treble, float intensity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Color val = Color.Lerp(_baseColor, new Color(1f, 0.86f, 0.18f), Mathf.Clamp01(bass * 1.15f)); val = Color.Lerp(val, new Color(0.35f, 0.95f, 1f), Mathf.Clamp01(treble * 0.9f)); float emissionStrength = (_isStar ? 0.5f : 0.08f) + (bass * 0.9f + treble * 1.1f + mid * 0.3f) * intensity; float colorBlend = (_isStar ? 0.9f : Mathf.Clamp01(0.035f + bass * 0.065f + treble * 0.045f)); float emissionBlend = (_isStar ? 0.9f : 0.38f); foreach (EmpressMaterialPulseState materialState in _materialStates) { materialState.Apply(val, emissionStrength, colorBlend, emissionBlend); } } private void CaptureMaterials() { _materialStates.Clear(); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if (!((Object)(object)val2 == (Object)null)) { _materialStates.Add(new EmpressMaterialPulseState(val2)); } } } } private Color AverageMaterialColor() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_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_005e: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (_materialStates.Count == 0) { return Color.HSVToRGB(Random.Range(0.47f, 0.94f), 0.45f, 0.95f); } Color val = Color.black; int num = 0; foreach (EmpressMaterialPulseState materialState in _materialStates) { if (materialState.HasColor) { val += materialState.BaseColor; num++; } } if (num != 0) { return val / (float)num; } return Color.HSVToRGB(Random.Range(0.47f, 0.94f), 0.45f, 0.95f); } } internal readonly struct EmpressMaterialPulseState { internal readonly Material Material; internal readonly Color BaseColor; internal readonly Color BaseEmission; internal readonly bool HasColor; internal readonly bool HasEmission; internal EmpressMaterialPulseState(Material material) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Material = material; HasColor = material.HasProperty("_Color"); BaseColor = (HasColor ? material.color : Color.white); HasEmission = material.HasProperty("_EmissionColor"); BaseEmission = (HasEmission ? material.GetColor("_EmissionColor") : Color.black); if (HasEmission) { material.EnableKeyword("_EMISSION"); } } internal void Apply(Color flash, float emissionStrength, float colorBlend, float emissionBlend) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) if (!((Object)(object)Material == (Object)null)) { if (HasColor) { Material.color = Color.Lerp(BaseColor, flash, colorBlend); } if (HasEmission) { Material.SetColor("_EmissionColor", Color.Lerp(BaseEmission, flash * emissionStrength, emissionBlend)); } } } } internal readonly struct EmpressAudioSourceState { private readonly bool _mute; private readonly bool _wasPlaying; internal EmpressAudioSourceState(AudioSource source) { _mute = source.mute; _wasPlaying = source.isPlaying; } internal void Restore(AudioSource source) { if (!((Object)(object)source == (Object)null)) { source.mute = _mute; if (_wasPlaying && !source.isPlaying) { source.UnPause(); } } } } internal readonly struct EmpressCameraState { private readonly bool _enabled; private readonly float _fieldOfView; private readonly float _nearClipPlane; private readonly float _farClipPlane; private readonly CameraClearFlags _clearFlags; private readonly Color _backgroundColor; internal EmpressCameraState(Camera camera) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0043: Unknown result type (might be due to invalid IL or missing references) _enabled = ((Behaviour)camera).enabled; _fieldOfView = camera.fieldOfView; _nearClipPlane = camera.nearClipPlane; _farClipPlane = camera.farClipPlane; _clearFlags = camera.clearFlags; _backgroundColor = camera.backgroundColor; } internal void Restore(Camera camera) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)camera == (Object)null)) { ((Behaviour)camera).enabled = _enabled; camera.fieldOfView = _fieldOfView; camera.nearClipPlane = _nearClipPlane; camera.farClipPlane = _farClipPlane; camera.clearFlags = _clearFlags; camera.backgroundColor = _backgroundColor; } } } }