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 Pharlooms Glory v0.1.4
plugins/PharloomsGlory.dll
Decompiled 5 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GlobalEnums; using HarmonyLib; using Microsoft.CodeAnalysis; using PharloomsGlory.Components; using PharloomsGlory.Managers; using PharloomsGlory.Modifiers; using Silksong.AssetHelper.ManagedAssets; using TMProOld; using TeamCherry.Localization; using TeamCherry.NestedFadeGroup; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Networking; using UnityEngine.SceneManagement; 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: AssemblyCompany("PharloomsGlory")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.4.0")] [assembly: AssemblyInformationalVersion("0.1.4+45cc3fa1b791b3e7a254dedfe951a9d8f25e1d9c")] [assembly: AssemblyProduct("PharloomsGlory")] [assembly: AssemblyTitle("PharloomsGlory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace PharloomsGlory { public class Constants { public const string PLUGIN_GUID = "com.norrieboy.pharloomsglory"; public const string PLUGIN_NAME = "Pharloom's Glory"; public const string PLUGIN_VERSION = "0.1.4"; private const string DLL_NAME = "PharloomsGlory.dll"; private static string basePluginPath = string.Empty; public static readonly string TEXTURES_PATH = Path.Combine(BASE_PLUGIN_PATH, "Textures"); public static readonly string SPRITE_OFFSETS_FILE_NAME = "spriteOffsets.txt"; public static readonly string TK2D_TEXTURES_DIRECTORY = "TK2D"; public static readonly string AREA_ART_TEXTURES_DIRECTORY = "AREA_ART"; public static readonly string HUD_TEXTURES_DIRECTORY = "HUD"; public static readonly Color BLASTED_STEPS_MAP_COLOR = new Color(0.408f, 0.855f, 0.988f, 1f); public static readonly string SCENE_MODIFICATIONS_PATH = Path.Combine(BASE_PLUGIN_PATH, "Scenes"); public static readonly string OBJECT_PATHS_FILE_PATH = Path.Combine(SCENE_MODIFICATIONS_PATH, "objectPaths.txt"); public static readonly string OBJECT_RENAMES_FILE_PATH = Path.Combine(SCENE_MODIFICATIONS_PATH, "objectRenames.txt"); public static readonly string RIVER_CLONES_DATA_FILE_PATH = Path.Combine(SCENE_MODIFICATIONS_PATH, "riverClones.txt"); public static readonly string TEXT_MODIFICATIONS_PATH = Path.Combine(BASE_PLUGIN_PATH, "Text"); public static readonly string AUDIO_PATH = Path.Combine(BASE_PLUGIN_PATH, "Audio"); public const string BLASTED_STEPS_MAIN_MUSIC_FILE_NAME = "H116 Coral Steps-42 MAIN ALT"; public const string BLASTED_STEPS_SUB_MUSIC_FILE_NAME = "H116 Coral Steps-42 SUB"; public const string SANDS_OF_KARAK_MAIN_MUSIC_FILE_NAME = "Coral Ruins Main"; public const string SANDS_OF_KARAK_SUB_MUSIC_FILE_NAME = "Coral Ruins Sub"; public static string BASE_PLUGIN_PATH { get { if (!string.IsNullOrEmpty(basePluginPath)) { return basePluginPath; } string[] directories = Directory.GetDirectories(Paths.PluginPath); foreach (string path in directories) { if (Directory.GetFiles(path).Any((string file) => Path.GetFileName(file) == "PharloomsGlory.dll")) { basePluginPath = Path.Combine(Paths.PluginPath, Path.GetFileName(path)); break; } } return basePluginPath; } } } [BepInPlugin("com.norrieboy.pharloomsglory", "Pharloom's Glory", "0.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static Plugin instance; private void Awake() { instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Pharloom's Glory 0.1.4] has loaded"); SpriteRendererModifier.Init(); TK2DSpriteModifier.Init(); AudioModifier.Init(); SceneModifier.Init(); PatcherManager.Init(); AssetManager.Init(); ConfigurationManager.Init(); SpriteRendererModifier.instance.LoadTextures(); AudioModifier.instance.LoadAudioClips(); AssetManager.instance.RequestAssets(); ConfigurationManager.instance.Bind(((BaseUnityPlugin)this).Config); AudioModifier.instance.LoadOverridesFromConfig(); SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode _mode) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!PatcherManager.instance.patched) { PatcherManager.instance.Patch(); } if (!AssetManager.instance.IsLoaded) { AssetManager.instance.LoadAllAssets(); } SceneModifier.instance.Modify(scene); } public static void LogInfo(string msg) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)msg); } public static void LogError(string msg) { ((BaseUnityPlugin)instance).Logger.LogError((object)msg); } } public class Util { private static readonly List<GameObject> gameObjects = new List<GameObject>(); private static readonly Dictionary<string, GameObject> gameObjectsDictionary = new Dictionary<string, GameObject>(); private static string currentSceneName = string.Empty; private static string currentDictionarySceneName = string.Empty; private static readonly string[] VALID_TEXTURE_SHEETS = new string[31] { "Core_Glows", "Coral_BG", "Area_Art", "CoralBG", "CoralCornerBlack", "CoralCornerBlue", "CoralRiverBlack", "CoralRiverBlue", "CW_sand_rest", "CW_sand_down", "CW_sand_fg", "Acid_top", "Coral Tower", "Sand", "Bellshrine", "Stone", "Coral", "HBone", "Core", "Inventory", "Hornet_Map", "clam_village", "summons_pin", "Sign", "Pinstress_Hut", "Room_Pinstress_Interior", "Bell", "Grey", "Jail", "Song", "umb_blue_doormat" }; public static string GetValidTextureName(string name) { return name.Replace("|", "-"); } public static string GetSpriteName(Sprite sprite) { //IL_001e: 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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_007c: 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) if (sprite != null) { Texture2D texture = sprite.texture; if (((texture != null) ? ((Object)texture).name : null) != null && sprite != null) { _ = sprite.textureRect; if (0 == 0) { Rect textureRect = sprite.textureRect; string text = ((int)((Rect)(ref textureRect)).x).ToString(); textureRect = sprite.textureRect; string text2 = ((int)((Rect)(ref textureRect)).y).ToString(); textureRect = sprite.textureRect; string text3 = ((int)((Rect)(ref textureRect)).width).ToString(); textureRect = sprite.textureRect; string text4 = ((int)((Rect)(ref textureRect)).height).ToString(); return GetValidTextureName(((Object)sprite.texture).name) + "-sprite-x" + text + "y" + text2 + "w" + text3 + "h" + text4; } } } return string.Empty; } public static List<GameObject> GetAllGameObjects(Scene scene, bool forceReload = false) { if (!((Scene)(ref scene)).IsValid()) { Plugin.LogError("Failed to get scene game objects because the scene was invalid"); gameObjects.Clear(); return gameObjects; } if (!forceReload && ((Scene)(ref scene)).name == currentSceneName) { return gameObjects; } gameObjects.Clear(); currentSceneName = ((Scene)(ref scene)).name; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); for (int i = 0; i < rootGameObjects.Length; i++) { Transform[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Transform>(); foreach (Transform val in componentsInChildren) { if ((Object)(object)((val != null) ? ((Component)val).gameObject : null) != (Object)null) { Extensions.AddIfNotPresent<GameObject>(gameObjects, ((Component)val).gameObject); } } } return gameObjects; } public static string GetGameObjectUniqueName(GameObject go) { string text = ((int)Extensions.GetPositionX(go.transform)).ToString(); string text2 = ((int)Extensions.GetPositionY(go.transform)).ToString(); return ((Object)go).name + "-x" + text + "y" + text2; } public static Dictionary<string, GameObject> GetAllGameObjectsAsDictionary(Scene scene, bool forceReload = false) { if (!((Scene)(ref scene)).IsValid()) { Plugin.LogError("Failed to get scene game objects as dictionary because the scene is invalid"); gameObjectsDictionary.Clear(); return gameObjectsDictionary; } if (!forceReload && ((Scene)(ref scene)).name == currentDictionarySceneName) { return gameObjectsDictionary; } gameObjectsDictionary.Clear(); currentDictionarySceneName = ((Scene)(ref scene)).name; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); for (int i = 0; i < rootGameObjects.Length; i++) { Transform[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Transform>(); foreach (Transform val in componentsInChildren) { if ((Object)(object)((val != null) ? ((Component)val).gameObject : null) != (Object)null) { string gameObjectUniqueName = GetGameObjectUniqueName(((Component)val).gameObject); if (!gameObjectsDictionary.ContainsKey(gameObjectUniqueName)) { gameObjectsDictionary.Add(gameObjectUniqueName, ((Component)val).gameObject); } } } } return gameObjectsDictionary; } public static void Clear() { currentSceneName = string.Empty; gameObjects.Clear(); currentDictionarySceneName = string.Empty; gameObjectsDictionary.Clear(); } public static string GetSpriteNameWithTextureNameOnly(string spriteName) { int num = spriteName.IndexOf("sprite"); if (num == -1) { return spriteName; } string text = spriteName.Substring(0, num); string text2 = string.Empty; for (int i = 0; i < VALID_TEXTURE_SHEETS.Length; i++) { if (text.Contains(VALID_TEXTURE_SHEETS[i])) { text2 = VALID_TEXTURE_SHEETS[i]; break; } } if (string.IsNullOrEmpty(text2)) { return spriteName; } string text3 = text2; int num2 = num; return text3 + "-" + spriteName.Substring(num2, spriteName.Length - num2); } public static string GetSpriteNameWithTextureNameOnly(Sprite sprite) { return GetSpriteNameWithTextureNameOnly(GetSpriteName(sprite)); } } } namespace PharloomsGlory.Modifiers { public class AudioModifier { internal static AudioModifier instance; private readonly Dictionary<string, AudioClip> updatedClips = new Dictionary<string, AudioClip>(); private readonly Dictionary<string, string> overriddenFileNames = new Dictionary<string, string>(); public static void Init() { if (instance == null) { instance = new AudioModifier(); } } public void LoadAudioClips() { updatedClips.Clear(); if (!Directory.Exists(Constants.AUDIO_PATH)) { Plugin.LogError("Failed to find updated audio directory"); return; } string[] files = Directory.GetFiles(Constants.AUDIO_PATH); foreach (string text in files) { try { string url = "file:///" + Uri.EscapeUriString(text.Replace("\\\\?\\", "").Replace("\\", "/")); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (!GetAudioClip(url, fileNameWithoutExtension, out AudioClip clip)) { Plugin.LogError("Failed to load audio clip " + text); } else { updatedClips.Add(fileNameWithoutExtension, clip); } } catch (Exception ex) { Plugin.LogError("Exception while loading audio clip: " + ex.Message); } } Plugin.LogInfo("Loaded audio clips"); } private bool GetAudioClip(string url, string clipName, out AudioClip clip) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 clip = null; UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(url, (AudioType)0); UnityWebRequestAsyncOperation val = audioClip.SendWebRequest(); while (!((AsyncOperation)val).isDone) { } if ((int)audioClip.result != 1) { return false; } clip = DownloadHandlerAudioClip.GetContent(audioClip); ((Object)clip).name = clipName; return true; } public bool GetAudioClip(string clipName, out AudioClip clip) { return updatedClips.TryGetValue(overriddenFileNames.GetValueOrDefault(clipName, clipName), out clip); } public void LoadOverridesFromConfig() { string value = ConfigurationManager.instance.BlastedStepsMusic switch { ConfigurationManager.AreaMusicTrack.VANILLA => string.Empty, ConfigurationManager.AreaMusicTrack.CORAL_STEPS => "H116 Coral Steps-42 MAIN ALT", ConfigurationManager.AreaMusicTrack.RED_CORAL_GORGE => "Coral Ruins Main", _ => string.Empty, }; overriddenFileNames.Add("H116 Coral Steps-42 MAIN ALT", value); string value2 = ConfigurationManager.instance.BlastedStepsMusic switch { ConfigurationManager.AreaMusicTrack.VANILLA => string.Empty, ConfigurationManager.AreaMusicTrack.CORAL_STEPS => "H116 Coral Steps-42 SUB", ConfigurationManager.AreaMusicTrack.RED_CORAL_GORGE => "Coral Ruins Sub", _ => string.Empty, }; overriddenFileNames.Add("H116 Coral Steps-42 SUB", value2); string value3 = ConfigurationManager.instance.SandsOfKarakMusic switch { ConfigurationManager.AreaMusicTrack.VANILLA => string.Empty, ConfigurationManager.AreaMusicTrack.CORAL_STEPS => "H116 Coral Steps-42 MAIN ALT", ConfigurationManager.AreaMusicTrack.RED_CORAL_GORGE => "Coral Ruins Main", _ => string.Empty, }; overriddenFileNames.Add("Coral Ruins Main", value3); string value4 = ConfigurationManager.instance.SandsOfKarakMusic switch { ConfigurationManager.AreaMusicTrack.VANILLA => string.Empty, ConfigurationManager.AreaMusicTrack.CORAL_STEPS => "H116 Coral Steps-42 SUB", ConfigurationManager.AreaMusicTrack.RED_CORAL_GORGE => "Coral Ruins Sub", _ => string.Empty, }; overriddenFileNames.Add("Coral Ruins Sub", value4); } } public class SceneModificationsParser { private Vector3 parsedRotation; private Vector2 parsedScale; private SceneModifier.FishParticleData parsedFishParticleData; private float parsedSurfaceWaterRegion; private Color parsedColor; private float parsedOffsetY; public SceneModificationsParser() { parsedSurfaceWaterRegion = 0f; parsedOffsetY = 0f; } public bool ParseVector2(string data, out Vector2 result) { //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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) result = Vector2.zero; Tuple<bool, int, int> tuple = VerifyParentheses(data); if (!tuple.Item1) { return false; } int item = tuple.Item2; string[] array = data.Substring(item, tuple.Item3 - item).Replace("(", "").Replace(")", "") .Split(","); if (array.Length != 2) { return false; } array[0] = array[0]; array[1] = array[1]; if (float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { result = new Vector2(result2, result3); return true; } return false; } public bool ParseVector3(string data, out Vector3 result) { //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_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) result = Vector3.zero; Tuple<bool, int, int> tuple = VerifyParentheses(data); if (!tuple.Item1) { return false; } int item = tuple.Item2; string[] array = data.Substring(item, tuple.Item3 - item).Replace("(", "").Replace(")", "") .Split(","); if (array.Length != 3) { return false; } array[0] = array[0]; array[2] = array[2]; if (float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4)) { result = new Vector3(result2, result3, result4); return true; } return false; } public bool ParseColor(string data, out Color result) { //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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) result = Color.white; Tuple<bool, int, int> tuple = VerifyParentheses(data); if (!tuple.Item1) { return false; } int item = tuple.Item2; string[] array = data.Substring(item, tuple.Item3 - item).Replace("(", "").Replace(")", "") .Split(","); if (array.Length != 4) { return false; } array[0] = array[0]; array[3] = array[3]; if (float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4) && float.TryParse(array[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result5)) { result = new Color(result2, result3, result4, result5); return true; } return false; } public bool ParseSpriteAlterPoint(string data, out Vector2 position, out float radius) { //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) position = Vector2.zero; radius = 0f; string[] array = data.Split("@"); if (array.Length != 2) { return false; } if (ParseVector2(array[0], out position)) { return float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out radius); } return false; } public bool ParseArgument(string argument, string fullData) { int num = fullData.IndexOf(argument); if (num == -1) { return false; } int num2 = num; Tuple<bool, int, int> tuple = VerifyParentheses(fullData.Substring(num2, fullData.Length - num2)); if (!tuple.Item1) { return false; } num2 = num + tuple.Item2; string data = fullData.Substring(num2, num + tuple.Item3 - num2); switch (argument) { case "rotation": return ParseRotation(data); case "scale": return ParseScale(data); case "fish": return ParseFishParticleData(data); case "surfaceWaterRegion": return ParseSurfaceWaterRegion(data); case "color": return ParseColor(data); case "offsetY": return ParseOffsetY(data); default: Plugin.LogError("Invalid scene modification argument " + argument); return false; } } private Tuple<bool, int, int> VerifyParentheses(string data) { int num = data.IndexOf("("); if (num == -1) { return new Tuple<bool, int, int>(item1: false, -1, -1); } int num2 = num; int num3 = 0; while (num2 < data.Length + 1) { if (data[num2] == '(') { num3++; } else if (data[num2] == ')') { num3--; } num2++; if (num3 == 0) { break; } } if (num3 != 0) { return new Tuple<bool, int, int>(item1: false, -1, -1); } return new Tuple<bool, int, int>(item1: true, num, num2); } private bool ParseRotation(string data) { return ParseVector3(data, out parsedRotation); } private bool ParseScale(string data) { if (ParseVector2(data, out parsedScale)) { return true; } if (float.TryParse(data.Replace("(", "").Replace(")", ""), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { parsedScale.x = result; parsedScale.y = result; return true; } return false; } private bool ParseColor(string data) { return ParseColor(data, out parsedColor); } private bool ParseFishParticleData(string data) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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) parsedFishParticleData = default(SceneModifier.FishParticleData); string[] array = data.Substring(1, data.Length - 1 - 1).Split(";"); if (array.Length != 4) { return false; } if (ParseVector2(array[0], out var result) && ParseVector2(array[1], out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && (array[3] == "bg" || array[3] == "fg")) { SceneModifier.FishParticleData fishParticleData = default(SceneModifier.FishParticleData); fishParticleData.minCurveMin = result.x; fishParticleData.minCurveMax = result.y; fishParticleData.maxCurveMax = result2.x; fishParticleData.maxCurveMin = result2.y; fishParticleData.limit = result3; string text = array[3]; SceneModifier.FishParticleType type = ((!(text == "bg")) ? ((text == "fg") ? SceneModifier.FishParticleType.FG : SceneModifier.FishParticleType.BG) : SceneModifier.FishParticleType.BG); fishParticleData.type = type; parsedFishParticleData = fishParticleData; return true; } return false; } private bool ParseSurfaceWaterRegion(string data) { return float.TryParse(data.Replace("(", "").Replace(")", ""), NumberStyles.Float, CultureInfo.InvariantCulture, out parsedSurfaceWaterRegion); } private bool ParseOffsetY(string data) { return float.TryParse(data.Replace("(", "").Replace(")", ""), NumberStyles.Float, CultureInfo.InvariantCulture, out parsedOffsetY); } public Vector3 GetParsedRotation() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return parsedRotation; } public Vector2 GetParsedScale() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return parsedScale; } public SceneModifier.FishParticleData GetParsedFishParticleData() { return parsedFishParticleData; } public float GetParsedSurfaceWaterRegion() { return parsedSurfaceWaterRegion; } public Color GetParsedColor() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return parsedColor; } public float GetParsedOffsetY() { return parsedOffsetY; } } public class SceneModifier { private struct DeactivatePointWithSpriteData { public Vector2 position; public float radius; public string spriteName; public float? depth; } public struct DeactivateWakeEffectData { public string range; public string effect; } private struct DeactivateDelayedObjectData { public string name; public float delay; } public enum FishParticleType { BG, FG } public struct FishParticleData { public float minCurveMin; public float minCurveMax; public float maxCurveMin; public float maxCurveMax; public float limit; public FishParticleType type; } public struct CloneObjectData { public string name; public Vector3 position; public Vector3? rotation; public FishParticleData? fishParticleData; public float? surfaceWaterRegion; public Vector2? scale; } public struct AddObjectData { public string spriteName; public Vector3 position; public Vector3? rotation; public Vector2? scale; public Color? color; } private enum WaterfallLength { THIN, NORMAL, WIDE, HUGE } private enum WaterfallType { BG, FG } private struct WaterfallObjectData { public WaterfallLength length; public WaterfallType type; public bool noEffects; public Vector3 position; public Vector3? rotation; public Vector2? scale; public float? offsetY; public Color? color; } private struct WaterfallEffectsObjectData { public WaterfallLength length; public WaterfallType type; public Vector3 position; public Vector3? rotation; public Vector2? scale; } private enum RiverOrientation { SLOPE, HORIZONTAL, VERTICAL, CORNER } private enum RiverType { BG, FG } private struct RiverObjectData { public RiverOrientation orientation; public RiverType type; public Vector3 position; public Vector3? rotation; public Vector2? scale; } private struct MoveObjectData { public string name; public Vector2 offset; } public struct SpriteModifyObjectData { public string name; public MapZone? mapZone; } public struct SpriteAlterPointData { public Vector2 position; public float radius; public MapZone? mapZone; } private struct WaterfallModifiers { public string baseObjectPath; public float baseScale; public float steamScale; public float splashScale; } [CompilerGenerated] private sealed class <DeactivateDelayedRoutine>d__73 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public Scene scene; public string name; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DeactivateDelayedRoutine>d__73(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: { <>1__state = -1; if (!Util.GetAllGameObjectsAsDictionary(scene, forceReload: true).TryGetValue(name, out GameObject value)) { return false; } value.SetActive(false); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static SceneModifier instance; public bool active; private readonly string[] CORAL_SCENES = new string[32] { "Coral_34", "Coral_11b", "Coral_11", "Coral_03", "Bellway_08", "Coral_35", "Coral_43", "Coral_33", "Coral_42", "Coral_36", "Coral_32", "Coral_Judge_Arena", "Coral_12", "Coral_37", "Coral_19", "Coral_19b", "Coral_02", "Room_Pinstress", "Coral_35b", "Coral_23", "Coral_40", "Coral_24", "Coral_26", "Coral_38", "Bellshrine_Coral", "Coral_25", "Coral_44", "Coral_27", "Coral_28", "Coral_Tower_01", "Coral_41", "Coral_39" }; private readonly List<GameObject> currentlyAddedGameObjects = new List<GameObject>(); private readonly List<string> parsedDeactivatedObjects = new List<string>(); private readonly List<DeactivatePointWithSpriteData> parsedDeactivatedPointsWithSprite = new List<DeactivatePointWithSpriteData>(); private readonly List<DeactivateWakeEffectData> parsedDeactivatedWakeEffects = new List<DeactivateWakeEffectData>(); private readonly List<string> parsedDeactivatedAudioObjects = new List<string>(); private readonly List<DeactivateDelayedObjectData> parsedDeactivateDelayedObjects = new List<DeactivateDelayedObjectData>(); private readonly List<CloneObjectData> parsedClonedObjects = new List<CloneObjectData>(); private readonly List<AddObjectData> parsedAddedObjects = new List<AddObjectData>(); private readonly List<WaterfallObjectData> parsedWaterfallObjects = new List<WaterfallObjectData>(); private readonly List<WaterfallEffectsObjectData> parsedWaterfallEffectObjects = new List<WaterfallEffectsObjectData>(); private readonly List<RiverObjectData> parsedRiverObjects = new List<RiverObjectData>(); private readonly List<MoveObjectData> parsedMoveObjects = new List<MoveObjectData>(); private bool modifyAllSprites; private readonly List<string> parsedSpriteIgnoreObjects = new List<string>(); private readonly List<SpriteModifyObjectData> parsedSpriteModifyObjects = new List<SpriteModifyObjectData>(); private readonly List<SpriteAlterPointData> parsedSpriteModifyPoints = new List<SpriteAlterPointData>(); private readonly List<SpriteAlterPointData> parsedSpriteIgnorePoints = new List<SpriteAlterPointData>(); private readonly List<SpriteModifyObjectData> parsedSpriteModifyObjectsWithMapZone = new List<SpriteModifyObjectData>(); private readonly List<SpriteAlterPointData> parsedSpriteModifyPointsWithMapZone = new List<SpriteAlterPointData>(); private MapZone? overrideMapZone; private Color? parsedHeroLightColor; private Color? parsedAmbientLightColor; private float? parsedAmbientLightIntensity; private float? parsedSaturation; private MapZone? parsedParticleType; private EnvironmentTypes? parsedEnvironmentType; private readonly Dictionary<string, Color> parsedTransitions = new Dictionary<string, Color>(); public static void Init() { if (instance == null) { instance = new SceneModifier(); } } public void SetActive(bool value) { if (active != value) { if (active && !value) { PatcherManager.instance.ResetColorValues(); Util.Clear(); } active = value; Plugin.LogInfo($"Set active SceneModifier to {value}"); } } public void Modify(Scene scene) { //IL_01a1: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) if (!CORAL_SCENES.Contains(((Scene)(ref scene)).name)) { SetActive(value: false); return; } if (!active) { SetActive(value: true); } if (!AssetManager.instance.IsLoaded) { return; } parsedDeactivatedObjects.Clear(); parsedDeactivatedPointsWithSprite.Clear(); parsedDeactivatedWakeEffects.Clear(); parsedDeactivatedAudioObjects.Clear(); parsedDeactivateDelayedObjects.Clear(); parsedClonedObjects.Clear(); parsedAddedObjects.Clear(); parsedWaterfallObjects.Clear(); parsedWaterfallEffectObjects.Clear(); parsedRiverObjects.Clear(); parsedMoveObjects.Clear(); modifyAllSprites = true; parsedSpriteIgnoreObjects.Clear(); parsedSpriteModifyObjects.Clear(); parsedSpriteModifyPoints.Clear(); parsedSpriteIgnorePoints.Clear(); parsedSpriteModifyObjectsWithMapZone.Clear(); parsedSpriteModifyPointsWithMapZone.Clear(); overrideMapZone = null; parsedHeroLightColor = null; parsedAmbientLightColor = null; parsedAmbientLightIntensity = null; parsedSaturation = null; parsedParticleType = null; parsedEnvironmentType = null; parsedTransitions.Clear(); if (!Directory.Exists(Constants.SCENE_MODIFICATIONS_PATH)) { Plugin.LogError("Failed to find scene modifications directory"); return; } string path = Path.Combine(Constants.SCENE_MODIFICATIONS_PATH, ((Scene)(ref scene)).name + ".txt"); if (File.Exists(path)) { ParseSceneModifications(File.ReadAllLines(path)); } DeactivateGameObjects(scene); PatcherManager.instance.SetColorValues(parsedHeroLightColor, parsedAmbientLightColor, parsedAmbientLightIntensity, parsedSaturation); PatcherManager.instance.SetWakeEffects(parsedDeactivatedWakeEffects); AddGameObjects(); MoveObjects(scene); ModifySpriteRenderers(scene); ModifySpriteCollections(); ModifySceneManager(); ModifyTransitions(scene); Plugin.LogInfo("Modified " + ((Scene)(ref scene)).name); } private void ParseSceneModifications(string[] lines) { foreach (string text in lines) { if (string.IsNullOrEmpty(text) || text.StartsWith("#")) { continue; } int num = text.IndexOf(":"); if (num == -1) { Plugin.LogError("Invalid scene modification syntax @ line " + text); continue; } string text2 = text.Substring(0, num); string text3 = text; int num2 = num + 1; string text4 = text3.Substring(num2, text3.Length - num2); switch (text2) { case "deactivate": parsedDeactivatedObjects.Add(text4); break; case "deactivatePointWithSprite": if (!ParseDeactivatePointWithSprite(text4)) { Plugin.LogError("Failed to parse deactivatePointWithSprite scene modification @ line " + text); } break; case "deactivateWakeEffect": if (!ParseDeactivateWakeEffect(text4)) { Plugin.LogError("Failed to parse deactivateWakeEffect scene modification @ line " + text); } break; case "deactivateAudio": parsedDeactivatedAudioObjects.Add(text4); break; case "deactivateDelayed": if (!ParseDeactivateDelayed(text4)) { Plugin.LogError("Failed to parse deactivateDelayed scene modification @ line " + text); } break; case "clone": if (!ParseClone(text4)) { Plugin.LogError("Failed to parse clone scene modification @ line " + text); } break; case "add": if (!ParseAdd(text4)) { Plugin.LogError("Failed to parse add scene modification @ line " + text); } break; case "waterfall": if (!ParseWaterfall(text4)) { Plugin.LogError("Failed to parse waterfall scene modification @ line " + text); } break; case "waterfallEffects": if (!ParseWaterfallEffects(text4)) { Plugin.LogError("Failed to parse waterfallEffects scene modification @ line " + text); } break; case "river": if (!ParseRiver(text4)) { Plugin.LogError("Failed to parse river scene modification @ line " + text); } break; case "move": if (!ParseMove(text4)) { Plugin.LogError("Failed to parse move scene modification @ line " + text); } break; case "spriteIgnoreObject": parsedSpriteIgnoreObjects.Add(text4); break; case "spriteModifyObject": modifyAllSprites = false; parsedSpriteModifyObjects.Add(new SpriteModifyObjectData { name = text4, mapZone = null }); break; case "spriteModifyPoint": modifyAllSprites = false; if (!ParseSpriteModifyPoint(text4)) { Plugin.LogError("Failed to parse spriteModifyPoint scene modification @ line " + text); } break; case "spriteIgnorePoint": if (!ParseSpriteIgnorePoint(text4)) { Plugin.LogError("Failed to parse spriteIgnorePoint scene modification @ line " + text); } break; case "spriteModifyObjectWithMapZone": modifyAllSprites = false; if (!ParseSpriteModifyObjectWithMapZone(text4)) { Plugin.LogError("Failed to parse spriteModifyObjectWithMapZone scene modification @ line " + text); } break; case "spriteModifyPointWithMapZone": modifyAllSprites = false; if (!ParseSpriteModifyPointWithMapZone(text4)) { Plugin.LogError("Failed to parse spriteModifyPointWithMapZone scene modification @ line " + text); } break; case "overrideMapZone": if (!ParseOverrideMapZone(text4)) { Plugin.LogError("Failed to parse overrideMapZone scene modification @ line " + text); } break; case "modifyAllSprites": if (!bool.TryParse(text4, out modifyAllSprites)) { Plugin.LogError("Failed to parse modifyAllSprites scene modification @ line " + text); modifyAllSprites = true; } break; case "heroLightColor": if (!ParseHeroLightColor(text4)) { Plugin.LogError("Failed to parse color for HeroLightColor @ line " + text); } break; case "ambientLightColor": if (!ParseAmbientLightColor(text4)) { Plugin.LogError("Failed to parse color for AmbientLightColor @ line " + text); } break; case "ambientLightIntensity": { if (float.TryParse(text4, NumberStyles.Float, CultureInfo.InvariantCulture, out var result4)) { parsedAmbientLightIntensity = result4; } else { Plugin.LogError("Failed to parse float value for AmbientLightIntensity @ line " + text); } break; } case "saturation": { if (float.TryParse(text4, NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { parsedSaturation = result3; } else { Plugin.LogError("Failed to parse float value for Saturation @ line " + text); } break; } case "particles": { if (int.TryParse(text4, out var result2)) { parsedParticleType = (MapZone)result2; } else { Plugin.LogError("Failed to parse int value for ParticleType @ line " + text); } break; } case "environment": { if (int.TryParse(text4, out var result)) { parsedEnvironmentType = (EnvironmentTypes)result; } else { Plugin.LogError("Failed to parse int value for EnvironmentType @ line " + text); } break; } case "transition": if (!ParseTransition(text4)) { Plugin.LogError("Failed to parse transition scene modification @ line " + text); } break; default: Plugin.LogError("Invalid scene modification " + text2 + " @ line " + text); break; } } } private bool ParseDeactivatePointWithSprite(string data) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0075: 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_00b3: Unknown result type (might be due to invalid IL or missing references) string[] array = data.Split("@"); if (array.Length != 2) { return false; } string spriteName = array[1]; string[] array2 = array[0].Split(";"); if (array2.Length != 2) { return false; } SceneModificationsParser sceneModificationsParser = new SceneModificationsParser(); Vector3 result; bool flag = sceneModificationsParser.ParseVector3(array2[0], out result); if ((!sceneModificationsParser.ParseVector2(array2[0], out var result2) && !flag) || !float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { return false; } DeactivatePointWithSpriteData deactivatePointWithSpriteData = default(DeactivatePointWithSpriteData); deactivatePointWithSpriteData.position = (Vector2)(flag ? new Vector2(result.x, result.y) : result2); deactivatePointWithSpriteData.radius = result3; deactivatePointWithSpriteData.spriteName = spriteName; deactivatePointWithSpriteData.depth = (flag ? new float?(result.z) : null); DeactivatePointWithSpriteData item = deactivatePointWithSpriteData; parsedDeactivatedPointsWithSprite.Add(item); return true; } private bool ParseDeactivateWakeEffect(string data) { string[] array = data.Split("@"); if (array.Length != 2) { return false; } string range = array[0]; string effect = array[1]; DeactivateWakeEffectData deactivateWakeEffectData = default(DeactivateWakeEffectData); deactivateWakeEffectData.range = range; deactivateWakeEffectData.effect = effect; DeactivateWakeEffectData item = deactivateWakeEffectData; parsedDeactivatedWakeEffects.Add(item); return true; } private bool ParseDeactivateDelayed(string data) { string[] array = data.Split("@"); if (array.Length != 2) { return false; } string name = array[0]; if (!float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return false; } DeactivateDelayedObjectData deactivateDelayedObjectData = default(DeactivateDelayedObjectData); deactivateDelayedObjectData.name = name; deactivateDelayedObjectData.delay = result; DeactivateDelayedObjectData item = deactivateDelayedObjectData; parsedDeactivateDelayedObjects.Add(item); return true; } private bool ParseClone(string data) { //IL_0080: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) string[] array = data.Split("@"); if (array.Length != 2) { return false; } string name = array[0]; SceneModificationsParser sceneModificationsParser = new SceneModificationsParser(); if (!sceneModificationsParser.ParseVector3(array[1], out var result)) { return false; } bool flag = sceneModificationsParser.ParseArgument("rotation", array[1]); bool flag2 = sceneModificationsParser.ParseArgument("fish", array[1]); bool flag3 = sceneModificationsParser.ParseArgument("surfaceWaterRegion", array[1]); bool flag4 = sceneModificationsParser.ParseArgument("scale", array[1]); CloneObjectData cloneObjectData = default(CloneObjectData); cloneObjectData.name = name; cloneObjectData.position = result; cloneObjectData.rotation = (flag ? new Vector3?(sceneModificationsParser.GetParsedRotation()) : null); cloneObjectData.fishParticleData = (flag2 ? new FishParticleData?(sceneModificationsParser.GetParsedFishParticleData()) : null); cloneObjectData.surfaceWaterRegion = (flag3 ? new float?(sceneModificationsParser.GetParsedSurfaceWaterRegion()) : null); cloneObjectData.scale = (flag4 ? new Vector2?(sceneModificationsParser.GetParsedScale()) : null); CloneObjectData item = cloneObjectData; parsedClonedObjects.Add(item); return true; } private bool ParseAdd(string data) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00cd: Unknown result type (might be due to invalid IL or missing references) string[] array = data.Split("@"); if (array.Length != 2) { return false; } string spriteName = array[0]; SceneModificationsParser sceneModificationsParser = new SceneModificationsParser(); if (!sceneModificationsParser.ParseVector3(array[1], out var result)) { return false; } bool flag = sceneModificationsParser.ParseArgument("rotation", array[1]); bool flag2 = sceneModificationsParser.ParseArgument("scale", array[1]); bool flag3 = sceneModificationsParser.ParseArgument("color", array[1]); AddObjectData addObjectData = default(AddObjectData); addObjectData.spriteName = spriteName; addObjectData.position = result; addObjectData.rotation = (flag ? new Vector3?(sceneModificationsParser.GetParsedRotation()) : null); addObjectData.scale = (flag2 ? new Vector2?(sceneModificationsParser.GetParsedScale()) : null); addObjectData.color = (flag3 ? new Color?(sceneModificationsParser.GetParsedColor()) : null); AddObjectData item = addObjectData; parsedAddedObjects.Add(item); return true; } private bool ParseWaterfall(string data) { //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) string[] array = data.Split('@'); if (array.Length != 2) { return false; } string[] array2 = array[0].Split(";"); if (array2.Length != 2 && array2.Length != 3) { return false; } WaterfallLength length; switch (array2[0]) { case "thin": length = WaterfallLength.THIN; break; case "normal": length = WaterfallLength.NORMAL; break; case "wide": length = WaterfallLength.WIDE; break; case "huge": length = WaterfallLength.HUGE; break; default: return false; } string text = array2[1]; WaterfallType type; if (!(text == "bg")) { if (!(text == "fg")) { return false; } type = WaterfallType.FG; } else { type = WaterfallType.BG; } bool noEffects = false; if (array2.Length == 3) { if (array2[2] != "noEffects") { return false; } noEffects = true; } SceneModificationsParser sceneModificationsParser = new SceneModificationsParser(); if (!sceneModificationsParser.ParseVector3(array[1], out var result)) { return false; } bool flag = sceneModificationsParser.ParseArgument("rotation", array[1]); bool flag2 = sceneModificationsParser.ParseArgument("scale", array[1]); bool flag3 = sceneModificationsParser.ParseArgument("offsetY", array[1]); bool flag4 = sceneModificationsParser.ParseArgument("color", array[1]); WaterfallObjectData waterfallObjectData = default(WaterfallObjectData); waterfallObjectData.length = length; waterfallObjectData.type = type; waterfallObjectData.noEffects = noEffects; waterfallObjectData.position = result; waterfallObjectData.rotation = (flag ? new Vector3?(sceneModificationsParser.GetParsedRotation()) : null); waterfallObjectData.scale = (flag2 ? new Vector2?(sceneModificationsParser.GetParsedScale()) : null); waterfallObjectData.offsetY = (flag3 ? new float?(sceneModificationsParser.GetParsedOffsetY()) : null); waterfallObjectData.color = (flag4 ? new Color?(sceneModificationsParser.GetParsedColor()) : null); WaterfallObjectData item = waterfallObjectData; parsedWaterfallObjects.Add(item); return true; } private bool ParseWaterfallEffects(string data) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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) string[] array = data.Split('@'); if (array.Length != 2) { return false; } string[] array2 = array[0].Split(";"); if (array2.Length != 2) { return false; } WaterfallLength length; switch (array2[0]) { case "thin": length = WaterfallLength.THIN; break; case "normal": length = WaterfallLength.NORMAL; break; case "wide": length = WaterfallLength.WIDE; break; case "huge": length = WaterfallLength.HUGE; break; default: return false; } string text = array2[1]; WaterfallType type; if (!(text == "bg")) { if (!(text == "fg")) { return false; } type = WaterfallType.FG; } else { type = WaterfallType.BG; } SceneModificationsParser sceneModificationsParser = new SceneModificationsParser(); if (!sceneModificationsParser.ParseVector3(array[1], out var result)) { return false; } bool flag = sceneModificationsParser.ParseArgument("rotation", array[1]); bool flag2 = sceneModificationsParser.ParseArgument("scale", array[1]); WaterfallEffectsObjectData waterfallEffectsObjectData = default(WaterfallEffectsObjectData); waterfallEffectsObjectData.length = length; waterfallEffectsObjectData.type = type; waterfallEffectsObjectData.position = result; waterfallEffectsObjectData.rotation = (flag ? new Vector3?(sceneModificationsParser.GetParsedRotation()) : null); waterfallEffectsObjectData.scale = (flag2 ? new Vector2?(sceneModificationsParser.GetParsedScale()) : null); WaterfallEffectsObjectData item = waterfallEffectsObjectData; parsedWaterfallEffectObjects.Add(item); return true; } private bool ParseRiver(string data) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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) string[] array = data.Split('@'); if (array.Length != 2) { return false; } string[] array2 = array[0].Split(";"); if (array2.Length != 2) { return false; } RiverOrientation orientation; switch (array2[0]) { case "slope": orientation = RiverOrientation.SLOPE; break; case "horizontal": orientation = RiverOrientation.HORIZONTAL; break; case "vertical": orientation = RiverOrientation.VERTICAL; break; case "corner": orientation = RiverOrientation.CORNER; break; default: return false; } string text = array2[1]; RiverType type; if (!(text == "bg")) { if (!(text == "fg")) { return false; } type = RiverType.FG; } else { type = RiverType.BG; } SceneModificationsParser sceneModificationsParser = new SceneModificationsParser(); if (!sceneModificationsParser.ParseVector3(array[1], out var result)) { return false; } bool flag = sceneModificationsParser.ParseArgument("rotation", array[1]); bool flag2 = sceneModificationsParser.ParseArgument("scale", array[1]); RiverObjectData riverObjectData = default(RiverObjectData); riverObjectData.orientation = orientation; riverObjectData.type = type; riverObjectData.position = result; riverObjectData.rotation = (flag ? new Vector3?(sceneModificationsParser.GetParsedRotation()) : null); riverObjectData.scale = (flag2 ? new Vector2?(sceneModificationsParser.GetParsedScale()) : null); RiverObjectData item = riverObjectData; parsedRiverObjects.Add(item); return true; } private bool ParseMove(string data) { //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) string[] array = data.Split("@"); if (array.Length != 2) { return false; } string name = array[0]; if (!new SceneModificationsParser().ParseVector2(array[1], out var result)) { return false; } MoveObjectData moveObjectData = default(MoveObjectData); moveObjectData.name = name; moveObjectData.offset = result; MoveObjectData item = moveObjectData; parsedMoveObjects.Add(item); return true; } private bool ParseSpriteModifyPoint(string data) { //IL_001d: 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) if (!new SceneModificationsParser().ParseSpriteAlterPoint(data, out var position, out var radius)) { return false; } SpriteAlterPointData spriteAlterPointData = default(SpriteAlterPointData); spriteAlterPointData.position = position; spriteAlterPointData.radius = radius; spriteAlterPointData.mapZone = null; SpriteAlterPointData item = spriteAlterPointData; parsedSpriteModifyPoints.Add(item); return true; } private bool ParseSpriteIgnorePoint(string data) { //IL_001d: 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) if (!new SceneModificationsParser().ParseSpriteAlterPoint(data, out var position, out var radius)) { return false; } SpriteAlterPointData spriteAlterPointData = default(SpriteAlterPointData); spriteAlterPointData.position = position; spriteAlterPointData.radius = radius; spriteAlterPointData.mapZone = null; SpriteAlterPointData item = spriteAlterPointData; parsedSpriteIgnorePoints.Add(item); return true; } private bool ParseSpriteModifyObjectWithMapZone(string data) { string[] array = data.Split("@"); if (array.Length != 2) { return false; } string name = array[0]; if (!int.TryParse(array[1], out var result)) { return false; } SpriteModifyObjectData spriteModifyObjectData = default(SpriteModifyObjectData); spriteModifyObjectData.name = name; spriteModifyObjectData.mapZone = (MapZone)result; SpriteModifyObjectData item = spriteModifyObjectData; parsedSpriteModifyObjectsWithMapZone.Add(item); return true; } private bool ParseSpriteModifyPointWithMapZone(string data) { //IL_006b: 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) string[] array = data.Split("@"); if (array.Length != 2) { return false; } string[] array2 = array[0].Split(";"); if (array2.Length != 2) { return false; } if (!new SceneModificationsParser().ParseVector2(array2[0], out var result) || !float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) || !int.TryParse(array[1], out var result3)) { return false; } SpriteAlterPointData spriteAlterPointData = default(SpriteAlterPointData); spriteAlterPointData.position = result; spriteAlterPointData.radius = result2; spriteAlterPointData.mapZone = (MapZone)result3; SpriteAlterPointData item = spriteAlterPointData; parsedSpriteModifyPointsWithMapZone.Add(item); return true; } private bool ParseOverrideMapZone(string data) { if (!int.TryParse(data, out var result)) { return false; } overrideMapZone = (MapZone)result; return true; } private bool ParseHeroLightColor(string data) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!new SceneModificationsParser().ParseColor(data, out var result)) { return false; } parsedHeroLightColor = result; return true; } private bool ParseAmbientLightColor(string data) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!new SceneModificationsParser().ParseColor(data, out var result)) { return false; } parsedAmbientLightColor = result; return true; } private bool ParseTransition(string data) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) string[] array = data.Split("@"); if (array.Length != 2) { return false; } string key = array[0]; if (!new SceneModificationsParser().ParseColor(array[1], out var result)) { return false; } return parsedTransitions.TryAdd(key, result); } private void DeactivateGameObjects(Scene scene) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0038: Expected O, but got Unknown GameManager gm = GameManager.instance; SceneTransitionFinishEvent deactivateObjects = null; deactivateObjects = (SceneTransitionFinishEvent)delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) DeactivateIndividualObjects(scene); DeactivatePoints(scene); DeactivateAudioObjects(scene); DeactivateDelayed(scene); gm.OnFinishedSceneTransition -= deactivateObjects; }; gm.OnFinishedSceneTransition += deactivateObjects; } private void DeactivateIndividualObjects(Scene scene) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, GameObject> allGameObjectsAsDictionary = Util.GetAllGameObjectsAsDictionary(scene); foreach (string parsedDeactivatedObject in parsedDeactivatedObjects) { if (allGameObjectsAsDictionary.TryGetValue(parsedDeactivatedObject, out var value) && (Object)(object)value != (Object)null) { value.SetActive(false); } } } private void DeactivatePoints(Scene scene) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject allGameObject in Util.GetAllGameObjects(scene)) { if ((Object)(object)allGameObject == (Object)null || !allGameObject.activeSelf) { continue; } SpriteRenderer component = allGameObject.GetComponent<SpriteRenderer>(); if ((Object)(object)((component != null) ? component.sprite : null) == (Object)null) { continue; } Vector3 position = allGameObject.transform.position; foreach (DeactivatePointWithSpriteData item in parsedDeactivatedPointsWithSprite) { if (Util.GetSpriteNameWithTextureNameOnly(component.sprite) == item.spriteName && Vector2.Distance(Vector2.op_Implicit(allGameObject.transform.position), item.position) <= item.radius && (!item.depth.HasValue || !(position.z < item.depth))) { allGameObject.SetActive(false); } } } } private void DeactivateAudioObjects(Scene scene) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject go in Util.GetAllGameObjects(scene)) { if ((Object)(object)go != (Object)null && parsedDeactivatedAudioObjects.Any((string name) => ((Object)go).name.ToLower().Replace(" ", "_").Contains(name))) { go.SetActive(false); } } } private void DeactivateDelayed(Scene scene) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) foreach (DeactivateDelayedObjectData parsedDeactivateDelayedObject in parsedDeactivateDelayedObjects) { ((MonoBehaviour)GameManager.instance).StartCoroutine(DeactivateDelayedRoutine(scene, parsedDeactivateDelayedObject.name, parsedDeactivateDelayedObject.delay)); } } [IteratorStateMachine(typeof(<DeactivateDelayedRoutine>d__73))] private IEnumerator DeactivateDelayedRoutine(Scene scene, string name, float delay) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DeactivateDelayedRoutine>d__73(0) { scene = scene, name = name, delay = delay }; } private void ModifySpriteRenderers(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown GameManager gm = GameManager.instance; SceneTransitionFinishEvent modifySpriteRenderers = null; modifySpriteRenderers = (SceneTransitionFinishEvent)delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) SpriteRendererModifier.instance.LoadSpriteRenderersWithIgnores(scene, parsedSpriteIgnoreObjects, parsedSpriteIgnorePoints); SpriteRendererModifier.instance.SetMapZone(overrideMapZone); if (modifyAllSprites) { foreach (SpriteAlterPointData item in parsedSpriteModifyPointsWithMapZone) { SpriteRendererModifier.instance.UpdatePoint(item); } SpriteRendererModifier.instance.UpdateLoaded(); } else { SpriteRendererModifier.instance.UpdateOnly(parsedSpriteModifyObjects.Concat(parsedSpriteModifyObjectsWithMapZone).ToList()); foreach (SpriteAlterPointData item2 in parsedSpriteModifyPoints.Concat(parsedSpriteModifyPointsWithMapZone)) { SpriteRendererModifier.instance.UpdatePoint(item2); } } gm.OnFinishedSceneTransition -= modifySpriteRenderers; }; gm.OnFinishedSceneTransition += modifySpriteRenderers; } private void ModifySpriteCollections() { TK2DSpriteModifier.instance.LoadSpriteCollections(); TK2DSpriteModifier.instance.UpdateLoaded(); } private void AddGameObjects() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown foreach (GameObject currentlyAddedGameObject in currentlyAddedGameObjects) { if (!((Object)(object)currentlyAddedGameObject == (Object)null)) { Object.Destroy((Object)(object)currentlyAddedGameObject); } } currentlyAddedGameObjects.Clear(); GameManager gm = GameManager.instance; SceneTransitionFinishEvent addObjects = null; addObjects = (SceneTransitionFinishEvent)delegate { AddClonedObjects(); AddNewObjects(); AddWaterfallObjects(); AddWaterfallEffectsObjects(); AddRiverObjects(); gm.OnFinishedSceneTransition -= addObjects; }; gm.OnFinishedSceneTransition += addObjects; } private void AddClonedObjects() { //IL_0055: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) foreach (CloneObjectData parsedClonedObject in parsedClonedObjects) { if (!AssetManager.instance.GetAsset(parsedClonedObject.name, out ManagedAsset<GameObject> asset)) { Plugin.LogError("Failed to get requested asset " + parsedClonedObject.name); continue; } GameObject val = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset); val.transform.position = parsedClonedObject.position; val.transform.rotation = (parsedClonedObject.rotation.HasValue ? Quaternion.Euler(parsedClonedObject.rotation.Value) : Quaternion.identity); val.SetActive(true); if (parsedClonedObject.scale.HasValue) { ScaleObject(val, parsedClonedObject.scale.Value); } currentlyAddedGameObjects.Add(val); if (parsedClonedObject.fishParticleData.HasValue) { HandleFishParticle(val, parsedClonedObject.fishParticleData.Value, ManagedAssetExtensions.InstantiateAsset<GameObject>(asset)); } if (parsedClonedObject.surfaceWaterRegion.HasValue) { HandleSurfaceWaterRegion(val, parsedClonedObject.surfaceWaterRegion.Value); } } } private void HandleFishParticle(GameObject go, FishParticleData data, GameObject original) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0022: 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) GameObject val = new GameObject(Util.GetGameObjectUniqueName(go) + " manager"); val.transform.position = go.transform.position; val.transform.rotation = go.transform.rotation; go.transform.parent = val.transform; FishParticleManager fishParticleManager = val.AddComponent<FishParticleManager>(); fishParticleManager.original = original; fishParticleManager.original.SetActive(false); fishParticleManager.data = data; fishParticleManager.current = go; fishParticleManager.StartReloadLoop(); currentlyAddedGameObjects.Remove(go); currentlyAddedGameObjects.Add(val); } private void HandleSurfaceWaterRegion(GameObject go, float flowSpeed) { SurfaceWaterRegion component = go.GetComponent<SurfaceWaterRegion>(); FieldInfo field = typeof(SurfaceWaterRegion).GetField("flowSpeed", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Plugin.LogError("Failed to get flowSpeed field info"); } else { field.SetValue(component, flowSpeed); } } private void AddNewObjects() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00f7: 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_011d: Unknown result type (might be due to invalid IL or missing references) foreach (AddObjectData parsedAddedObject in parsedAddedObjects) { if (!SpriteRendererModifier.instance.GetTexture(parsedAddedObject.spriteName, out Texture2D texture)) { Plugin.LogError("Failed to add object, the sprite " + parsedAddedObject.spriteName + " is not loaded"); continue; } GameObject val = new GameObject(parsedAddedObject.spriteName); val.transform.position = parsedAddedObject.position; val.transform.rotation = (parsedAddedObject.rotation.HasValue ? Quaternion.Euler(parsedAddedObject.rotation.Value) : Quaternion.identity); if (parsedAddedObject.scale.HasValue) { ScaleObject(val, parsedAddedObject.scale.Value); } SpriteRenderer val2 = val.AddComponent<SpriteRenderer>(); val2.sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f)); if (parsedAddedObject.color.HasValue) { val2.color = parsedAddedObject.color.Value; } currentlyAddedGameObjects.Add(val); } } private void AddWaterfallObjects() { //IL_003d: 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_0042: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_01ca: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) Vector2 val2 = default(Vector2); foreach (WaterfallObjectData parsedWaterfallObject in parsedWaterfallObjects) { string text = ((parsedWaterfallObject.type == WaterfallType.BG) ? "waterfall_base_large (1)/particle_barrel_splash (4)" : "waterfall_base_large (1)/particle_barrel_splash (5)"); Color val = ((parsedWaterfallObject.type == WaterfallType.BG) ? Color.white : Color.black); if (parsedWaterfallObject.color.HasValue) { val = parsedWaterfallObject.color.Value; } WaterfallModifiers waterfallModifiers = GetWaterfallModifiers(parsedWaterfallObject.length); string baseObjectPath = waterfallModifiers.baseObjectPath; ((Vector2)(ref val2))..ctor(waterfallModifiers.baseScale, 1f); float steamScale = waterfallModifiers.steamScale; float splashScale = waterfallModifiers.splashScale; if (!AssetManager.instance.GetAsset(baseObjectPath, out ManagedAsset<GameObject> asset)) { Plugin.LogError("Failed to get base object asset " + baseObjectPath + " for waterfall"); continue; } GameObject val3 = new GameObject($"waterfall-{parsedWaterfallObject.length}-{parsedWaterfallObject.type}-x{(int)parsedWaterfallObject.position.x}y{(int)parsedWaterfallObject.position.y}"); val3.transform.position = parsedWaterfallObject.position; Quaternion rotation = (parsedWaterfallObject.rotation.HasValue ? Quaternion.Euler(parsedWaterfallObject.rotation.Value) : Quaternion.identity); val2 *= (Vector2)(((??)parsedWaterfallObject.scale) ?? Vector2.one); steamScale *= (parsedWaterfallObject.scale.HasValue ? parsedWaterfallObject.scale.Value.x : 1f); splashScale *= (parsedWaterfallObject.scale.HasValue ? parsedWaterfallObject.scale.Value.x : 1f); if (parsedWaterfallObject.type == WaterfallType.FG) { splashScale *= 3.6f; } GameObject val4 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset); val4.transform.position = parsedWaterfallObject.position; val4.transform.rotation = rotation; val4.SetActive(true); val4.transform.parent = val3.transform; MeshRenderer component = val4.GetComponent<MeshRenderer>(); Material[] materials = ((Renderer)component).materials; foreach (Material obj in materials) { int num = Shader.PropertyToID("_TintColor"); if (obj.HasProperty(num)) { int num2 = num; MaterialPropertyBlock val5 = new MaterialPropertyBlock(); ((Renderer)component).GetPropertyBlock(val5); val5.SetColor(num2, val); ((Renderer)component).SetPropertyBlock(val5); } } ScaleObject(val4, val2); if (parsedWaterfallObject.offsetY.HasValue) { Extensions.SetPositionY(val4.transform, Extensions.GetPositionY(val4.transform) + parsedWaterfallObject.offsetY.Value); } if (parsedWaterfallObject.noEffects) { currentlyAddedGameObjects.Add(val3); continue; } if (parsedWaterfallObject.type != WaterfallType.FG) { if (!AssetManager.instance.GetAsset("waterfall_base_large (1)/Fungus_Steam (2)", out ManagedAsset<GameObject> asset2)) { Plugin.LogError("Failed to get steam asset waterfall_base_large (1)/Fungus_Steam (2) for waterfall"); continue; } GameObject val6 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset2); val6.transform.position = parsedWaterfallObject.position; val6.transform.rotation = rotation; val6.SetActive(true); val6.transform.parent = val3.transform; Extensions.SetPositionZ(val6.transform, Extensions.GetPositionZ(val6.transform) - 1f); ScaleObject(val6, steamScale); } if (!AssetManager.instance.GetAsset(text, out ManagedAsset<GameObject> asset3)) { Plugin.LogError("Failed to get splash asset " + text + " for waterfall"); continue; } GameObject val7 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset3); val7.transform.position = parsedWaterfallObject.position; val7.transform.rotation = rotation; val7.SetActive(true); val7.transform.parent = val3.transform; Extensions.SetPositionZ(val7.transform, val7.transform.position.z + 0.05f); ScaleObject(val7, splashScale); if (!AssetManager.instance.GetAsset("Group (6)/Audio Waterfall Small", out ManagedAsset<GameObject> asset4)) { Plugin.LogError("Failed to get audio asset Group (6)/Audio Waterfall Small for waterfall"); continue; } GameObject obj2 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset4); obj2.transform.position = parsedWaterfallObject.position; obj2.transform.rotation = Quaternion.identity; obj2.SetActive(true); obj2.transform.parent = val3.transform; currentlyAddedGameObjects.Add(val3); } } private WaterfallModifiers GetWaterfallModifiers(WaterfallLength length) { switch (length) { case WaterfallLength.THIN: { WaterfallModifiers result = default(WaterfallModifiers); result.baseObjectPath = AssetManager.instance.GetPathFromRename("waterfallNormal"); result.baseScale = 0.2f; result.steamScale = 0.03f; result.splashScale = 0.06f; return result; } case WaterfallLength.NORMAL: { WaterfallModifiers result = default(WaterfallModifiers); result.baseObjectPath = AssetManager.instance.GetPathFromRename("waterfallNormal"); result.baseScale = 0.7f; result.steamScale = 0.2f; result.splashScale = 0.15f; return result; } case WaterfallLength.WIDE: { WaterfallModifiers result = default(WaterfallModifiers); result.baseObjectPath = AssetManager.instance.GetPathFromRename("waterfallWide"); result.baseScale = 1f; result.steamScale = 0.2f; result.splashScale = 0.3f; return result; } case WaterfallLength.HUGE: { WaterfallModifiers result = default(WaterfallModifiers); result.baseObjectPath = AssetManager.instance.GetPathFromRename("waterfallHuge"); result.baseScale = 1f; result.steamScale = 0.6f; result.splashScale = 0.6f; return result; } default: return default(WaterfallModifiers); } } private void ScaleObject(GameObject go, Vector2 scale) { //IL_0011: 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) Extensions.SetScaleX(go.transform, Extensions.GetScaleX(go.transform) * scale.x); Extensions.SetScaleY(go.transform, Extensions.GetScaleY(go.transform) * scale.y); } private void ScaleObject(GameObject go, float scale) { Extensions.SetScaleX(go.transform, Extensions.GetScaleX(go.transform) * scale); Extensions.SetScaleY(go.transform, Extensions.GetScaleY(go.transform) * scale); } private void AddWaterfallEffectsObjects() { //IL_0072: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) foreach (WaterfallEffectsObjectData parsedWaterfallEffectObject in parsedWaterfallEffectObjects) { string text = ((parsedWaterfallEffectObject.type == WaterfallType.BG) ? "waterfall_base_large (1)/particle_barrel_splash (4)" : "waterfall_base_large (1)/particle_barrel_splash (5)"); WaterfallModifiers waterfallModifiers = GetWaterfallModifiers(parsedWaterfallEffectObject.length); float steamScale = waterfallModifiers.steamScale; float splashScale = waterfallModifiers.splashScale; GameObject val = new GameObject($"waterfallEffects-{parsedWaterfallEffectObject.length}-{parsedWaterfallEffectObject.type}-x{(int)parsedWaterfallEffectObject.position.x}y{(int)parsedWaterfallEffectObject.position.y}"); val.transform.position = parsedWaterfallEffectObject.position; Quaternion rotation = (parsedWaterfallEffectObject.rotation.HasValue ? Quaternion.Euler(parsedWaterfallEffectObject.rotation.Value) : Quaternion.identity); steamScale *= (parsedWaterfallEffectObject.scale.HasValue ? parsedWaterfallEffectObject.scale.Value.x : 1f); splashScale *= (parsedWaterfallEffectObject.scale.HasValue ? parsedWaterfallEffectObject.scale.Value.x : 1f); if (parsedWaterfallEffectObject.type == WaterfallType.FG) { splashScale *= 3.6f; } if (parsedWaterfallEffectObject.type != WaterfallType.FG) { if (!AssetManager.instance.GetAsset("waterfall_base_large (1)/Fungus_Steam (2)", out ManagedAsset<GameObject> asset)) { Plugin.LogError("Failed to get steam asset waterfall_base_large (1)/Fungus_Steam (2) for waterfall effects"); continue; } GameObject val2 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset); val2.transform.position = parsedWaterfallEffectObject.position; val2.transform.rotation = rotation; val2.SetActive(true); val2.transform.parent = val.transform; Extensions.SetPositionZ(val2.transform, Extensions.GetPositionZ(val2.transform) - 1f); ScaleObject(val2, steamScale); } if (!AssetManager.instance.GetAsset(text, out ManagedAsset<GameObject> asset2)) { Plugin.LogError("Failed to get splash asset " + text + " for waterfall effects"); continue; } GameObject val3 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset2); val3.transform.position = parsedWaterfallEffectObject.position; val3.transform.rotation = rotation; val3.SetActive(true); val3.transform.parent = val.transform; Extensions.SetPositionZ(val3.transform, val3.transform.position.z + 0.05f); ScaleObject(val3, splashScale); if (!AssetManager.instance.GetAsset("Group (6)/Audio Waterfall Small", out ManagedAsset<GameObject> asset3)) { Plugin.LogError("Failed to get audio asset Group (6)/Audio Waterfall Small for waterfall effects"); continue; } GameObject obj = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset3); obj.transform.position = parsedWaterfallEffectObject.position; obj.transform.rotation = Quaternion.identity; obj.SetActive(true); obj.transform.parent = val.transform; currentlyAddedGameObjects.Add(val); } } private void AddRiverObjects() { //IL_0035: 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_0027: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) foreach (RiverObjectData parsedRiverObject in parsedRiverObjects) { Quaternion rotation = (parsedRiverObject.rotation.HasValue ? Quaternion.Euler(parsedRiverObject.rotation.Value) : Quaternion.identity); switch (parsedRiverObject.orientation) { case RiverOrientation.SLOPE: { string text2 = ((parsedRiverObject.type == RiverType.BG) ? "blue" : "black"); string resourcePath3 = "coral_river_tiled_0001_side_back-" + text2; string resourcePath4 = "coral_river_tiled_0000_side_front-" + text2; if (!AssetManager.instance.GetAsset("coral_river_chunk/river_top", out ManagedAsset<GameObject> asset5)) { Plugin.LogError("Failed to get river asset coral_river_chunk/river_top for slope river"); break; } GameObject val5 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset5); val5.transform.position = parsedRiverObject.position; val5.transform.rotation = rotation; val5.SetActive(true); if (parsedRiverObject.scale.HasValue) { ScaleObject(val5, parsedRiverObject.scale.Value); } currentlyAddedGameObjects.Add(val5); HandleRiverClone(val5, "river_top/Base_End", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath3 }); HandleRiverClone(val5, "river_top/Base_End/Top", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath4 }); HandleRiverClone(val5, "river_top/Base", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath3 }); HandleRiverClone(val5, "river_top/Base/Top", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath4 }); break; } case RiverOrientation.HORIZONTAL: { if (!AssetManager.instance.GetAsset("water_components_short_simple_white/StillWater", out ManagedAsset<GameObject> asset3)) { Plugin.LogError("Failed to get river asset water_components_short_simple_white/StillWater for horizontal river"); break; } GameObject val3 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset3); val3.transform.position = parsedRiverObject.position; val3.transform.rotation = rotation; val3.SetActive(true); if (parsedRiverObject.scale.HasValue) { ScaleObject(val3, parsedRiverObject.scale.Value); } currentlyAddedGameObjects.Add(val3); HandleRiverClone(val3, "StillWater", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = "gradientBlue" }); if (!AssetManager.instance.GetAsset("water_components_short_simple_white/waterways_water_components/acid_water_top", out ManagedAsset<GameObject> asset4)) { Plugin.LogError("Failed to get glow asset water_components_short_simple_white/waterways_water_components/acid_water_top for horizontal river"); break; } GameObject val4 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset4); val4.transform.position = parsedRiverObject.position; val4.transform.rotation = rotation; val4.SetActive(true); Extensions.SetPositionX(val4.transform, Extensions.GetPositionX(val4.transform) + 46f * (parsedRiverObject.scale?.x ?? 1f)); Extensions.SetPositionY(val4.transform, Extensions.GetPositionY(val4.transform) + 2.75f * (parsedRiverObject.scale?.y ?? 1f)); ScaleObject(val4, new Vector2(25f, 2f) * (Vector2)(((??)parsedRiverObject.scale) ?? Vector2.one)); currentlyAddedGameObjects.Add(val4); val4.AddComponent<RiverHorizontalGlowManager>(); break; } case RiverOrientation.VERTICAL: { string text = ((parsedRiverObject.type == RiverType.BG) ? "blue" : "black"); string resourcePath = "coral_river_tiled_0003_straight_back-" + text; string resourcePath2 = "coral_river_tiled_0002_straight_front-" + text; if (!AssetManager.instance.GetAsset("coral_river_chunk/waterfall", out ManagedAsset<GameObject> asset2)) { Plugin.LogError("Failed to get river asset coral_river_chunk/waterfall for vertical river"); break; } GameObject val2 = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset2); val2.transform.position = parsedRiverObject.position; val2.transform.rotation = rotation; val2.SetActive(true); if (parsedRiverObject.scale.HasValue) { ScaleObject(val2, parsedRiverObject.scale.Value); } currentlyAddedGameObjects.Add(val2); HandleRiverClone(val2, "waterfall/Base_End", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath }); HandleRiverClone(val2, "waterfall/Base_End/Top", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath2 }); HandleRiverClone(val2, "waterfall/Base", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath }); HandleRiverClone(val2, "waterfall/Base/Top", new AssetManager.RiverCloneData { component = AssetManager.RiverCloneData.ComponentType.MESH_RENDERER, resourceType = AssetManager.RiverCloneData.ResourceType.TEXTURE, resourcePath = resourcePath2 }); break; } case RiverOrientation.CORNER: { string spriteSuffix = ((parsedRiverObject.type == RiverType.BG) ? "blue" : "black"); if (!AssetManager.instance.GetAsset("coral_river_chunk/corner", out ManagedAsset<GameObject> asset)) { Plugin.LogError("Failed to get river asset coral_river_chunk/corner for river corner"); break; } GameObject val = ManagedAssetExtensions.InstantiateAsset<GameObject>(asset); val.transform.position = parsedRiverObject.position; val.transform.rotation = rotation; val.SetActive(true); if (parsedRiverObject.scale.HasValue) { ScaleObject(val, parsedRiverObject.scale.Value); } currentlyAddedGameObjects.Add(val); val.AddComponent<RiverCornerManager>().spriteSuffix = spriteSuffix; break; } } } } private void HandleRiverClone(GameObject go, string? overrideChildPath = null, AssetManager.RiverCloneData? overrideData = null) { if (overrideChildPath != null && overrideData.HasValue) { ApplyRiverCloneData(go, overrideChildPath, overrideData.Value); return; } foreach (Dictionary<string, List<AssetManager.RiverCloneData>> riverClonesDatum in AssetManager.instance.GetRiverClonesData()) { foreach (KeyValuePair<string, List<AssetManager.RiverCloneData>> item in riverClonesDatum) { if (!(item.Key.Split("/")[0] == ((Object)go).name.Replace("(Clone)", ""))) { continue; } foreach (AssetManager.RiverCloneData item2 in item.Value) { ApplyRiverCloneData(go, item.Key, item2); } } } } private void ApplyRiverCloneData(GameObject go, string childPath, AssetManager.RiverCloneData data) { //IL_010c: 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) string text = ((Object)go).name.Replace("(Clone)", ""); Texture2D texture = null; Shader val = null; switch (data.resourceType) { case AssetManager.RiverCloneData.ResourceType.TEXTURE: if (!SpriteRendererModifier.instance.GetTexture(data.resourcePath, out texture, (MapZone)41)) { Plugin.LogError("Failed to get texture " + data.resourcePath + " in river clone data of " + text); return; } break; case AssetManager.RiverCloneData.ResourceType.SHADER: val = Shader.Find(data.resourcePath); if ((Object)(object)val == (Object)null) { Plugin.LogError("Failed to get shader " + data.resourcePath + " in river clone data of " + text); return; } break; default: Plugin.LogError("Invalid resource type in river clone data of " + text); return; } if (data.component == AssetManager.RiverCloneData.ComponentType.MESH_RENDERER) { if (!ParseRiverCloneDataPath(childPath, go, out GameObject child)) { Plugin.LogError("Failed to parse path " + childPath + " in river clone data of " + text); return; } MeshRenderer component = child.GetComponent<MeshRenderer>(); if ((Object)(object)texture != (Object)null) { Material[] materials = ((Renderer)component).materials; for (int i = 0; i < materials.Length; i++) { materials[i].color = new Color(1f, 1f, 1f, 0f); } ((Renderer)component).material.mainTexture = (Texture)(object)texture; ((Renderer)component).material.color = new Color(1f, 1f, 1f, 1f); } if ((Object)(object)val != (Object)null) { ((Renderer)component).material.shader = val; } } else { Plugin.LogError("Invalid component type in river clone data of " + text); } } private bool ParseRiverCloneDataPath(string path, GameObject go, out GameObject child) { child = go; string[] array = path.Split('/'); if (array[0] != ((Object)go).name.Replace("(Clone)", "")) { return false; } for (int i = 1; i < array.Length; i++) { Transform[] componentsInChildren = child.GetComponentsInChildren<Transform>(); foreach (Transform val in componentsInChildren) { if (((Object)((Component)val).gameObject).name == array[i] && (Object)(object)val.parent == (Object)(object)child.transform) { child = ((Component)val).gameObject; } } } return true; } private void MoveObjects(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown GameManager gm = GameManager.instance; SceneTransitionFinishEvent moveObjects = null; moveObjects = (SceneTransitionFinishEvent)delegate { //IL_0001: 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_006c: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, GameObject> allGameObjectsAsDictionary = Util.GetAllGameObjectsAsDictionary(scene); foreach (MoveObjectData parsedMoveObject in parsedMoveObjects) { if (allGameObjectsAsDictionary.TryGetValue(parsedMoveObject.name, out var value)) { Extensions.SetPositionX(value.transform, Extensions.GetPositionX(value.transform) + parsedMoveObject.offset.x); Extensions.SetPositionY(value.transform, Extensions.GetPositionY(value.transform) + parsedMoveObject.offset.y); } } gm.OnFinishedSceneTransition -= moveObjects; }; gm.OnFinishedSceneTransition += moveObjects; } private void ModifySceneManager() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown GameManager gm = GameManager.instance; SceneTransitionFinishEvent modifySM = null; modifySM = (SceneTransitionFinishEvent)delegate { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) CustomSceneManager sm = gm.sm; if (!((Object)(object)sm == (Object)null)) { if (parsedParticleType.HasValue) { sm.overrideParticlesWith = parsedParticleType.Value; } if (parsedEnvironmentType.HasValue) { sm.environmentType = parsedEnvironmentType.Value; } if (sm.isWindy) { sm.isWindy = false; } gm.OnBeforeFinishedSceneTransition -= modifySM; } }; gm.OnBeforeFinishedSceneTransition += modifySM; } private void ModifyTransitions(Scene scene) { //IL_0000: 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) Dictionary<string, GameObject> allGameObjectsAsDictionary = Util.GetAllGameObjectsAsDictionary(scene); foreach (KeyValuePair<string, Color> parsedTransition in parsedTransitions) { if (allGameObjectsAsDictionary.TryGetValue(parsedTransition.Key, out var value)) { SpriteRenderer componentInChildren = value.GetComponentInChildren<SpriteRenderer>(); if (componentInChildren != null) { componentInChildren.color = parsedTransition.Value; } } } } } public class SpriteRendererModifier { internal static SpriteRendererModifier instance; private readonly Dictionary<MapZone, Dictionary<string, Texture2D>> spriteTextures = new Dictionary<MapZone, Dictionary<string, Texture2D>>(); private readonly Dictionary<MapZone, Dictionary<string, Sprite>> updatedSprites = new Dictionary<MapZone, Dictionary<string, Sprite>>(); private readonly Dictionary<MapZone, Dictionary<string, Vector2>> pivotOffsets = new Dictionary<MapZone, Dictionary<string, Vector2>>(); private MapZone? overrideMapZone; private readonly Dictionary<string, Texture2D> hudSpriteTextures = new Dictionary<string, Texture2D>(); private readonly Dictionary<string, Sprite> updatedHudSprites = new Dictionary<string, Sprite>(); private readonly Dictionary<string, Vector2> hudPivotOffsets = new Dictionary<string, Vector2>(); private reado