From 870431de411e4355109a519a91e9909177c0fd7a Mon Sep 17 00:00:00 2001 From: MegaPiggy <34462599+MegaPiggy@users.noreply.github.com> Date: Mon, 31 May 2021 20:54:14 -0400 Subject: [PATCH] Updated to game version v210530.1 --- Character.cs | 10 +- Console/Commands/CompleteLevelCommand.cs | 2 +- Console/Commands/LoadLevelCommand.cs | 2 +- Console/Commands/SwitchCharacterCommand.cs | 4 +- Extensions/GameObjectExtensions.cs | 2 + Extensions/OtherExtensions.cs | 109 +++++++- Extensions/StringExtensions.cs | 71 ++++-- Level.cs | 4 +- Main.cs | 41 ++- Patches/OptionPatches.cs | 170 ++++++------ Patches/PausePatches.cs | 284 +++++++++++++++++++++ Patches/VFXPatches.cs | 35 +++ Registries/CharacterRegistry.cs | 18 +- SALT.csproj | 3 + SAObjects.cs | 2 + Timer.cs | 3 +- UI/ModListUI.cs | 8 +- UI/TimerUI.cs | 8 +- Utils/EnumUtils.cs | 33 +++ VFXOption.cs | 58 +++++ 20 files changed, 728 insertions(+), 139 deletions(-) create mode 100644 Patches/PausePatches.cs create mode 100644 Patches/VFXPatches.cs create mode 100644 VFXOption.cs diff --git a/Character.cs b/Character.cs index 77e75c3..e142619 100644 --- a/Character.cs +++ b/Character.cs @@ -40,8 +40,16 @@ public enum Character /// KEVIN, /// + /// Subaru as a duck. Popularized in a meme during May 2021. + /// + SHUBA, + /// + /// A cow that is supposed to the be the game creator Kevin. + /// + GURA_CAT, + /// /// A character with nothing attached. /// - NONE + NONE// = -1, } } diff --git a/Console/Commands/CompleteLevelCommand.cs b/Console/Commands/CompleteLevelCommand.cs index 1f974d3..ff02b1c 100644 --- a/Console/Commands/CompleteLevelCommand.cs +++ b/Console/Commands/CompleteLevelCommand.cs @@ -28,7 +28,6 @@ public override bool Execute(string[] args) var potClose = Object.FindObjectOfType(); if (potClose != null) { - SAObjects.GetRootGameObject("PotTrap").SetActiveRecursivelyExt(true); Patches.PotClosedPatch.OnPotClosed += CompleteRedHeart; potClose.OnTriggerEnter2D(Main.CreatePlayerCollider()); return true; @@ -41,6 +40,7 @@ public override bool Execute(string[] args) private static void CompleteRedHeart() { + SAObjects.GetRootGameObject("PotTrap").SetChildActive("LevelClearEmpty", true); CompleteLevel(); Patches.PotClosedPatch.OnPotClosed -= CompleteRedHeart; } diff --git a/Console/Commands/LoadLevelCommand.cs b/Console/Commands/LoadLevelCommand.cs index 03439d3..96bc8bf 100644 --- a/Console/Commands/LoadLevelCommand.cs +++ b/Console/Commands/LoadLevelCommand.cs @@ -18,7 +18,7 @@ internal class LoadLevelCommand : ConsoleCommand public static int Increment() { i += 1; - if (i > 9) + if (i > (int)EnumUtils.GetHighestValue()) i = 0; return i; } diff --git a/Console/Commands/SwitchCharacterCommand.cs b/Console/Commands/SwitchCharacterCommand.cs index 6b1b882..5f2e31a 100644 --- a/Console/Commands/SwitchCharacterCommand.cs +++ b/Console/Commands/SwitchCharacterCommand.cs @@ -38,7 +38,7 @@ public override bool Execute(string[] args) if (name.StartsWith(UnknownStart)) { int characterNumber = name.Replace(UnknownStart, "").ToInt() + ((player.characterPacks.Count+1) - 1); - Main.ChangeCharacter(characterNumber); + Main.SetCharacter(characterNumber); Console.LogSuccess("Successfully changed character"); return true; } @@ -48,7 +48,7 @@ public override bool Execute(string[] args) // Console.LogError("Character change failed"); // return false; //} - Main.ChangeCharacter((int)character); + Main.SetCharacter((int)character); Console.LogSuccess("Successfully changed character"); return true; } diff --git a/Extensions/GameObjectExtensions.cs b/Extensions/GameObjectExtensions.cs index aa09ec7..f996f17 100644 --- a/Extensions/GameObjectExtensions.cs +++ b/Extensions/GameObjectExtensions.cs @@ -296,6 +296,8 @@ public static void PrintNamesOfComponents(this GameObject gameObject) public static void RemoveComponent(this GameObject go) where T : Component => UnityEngine.Object.Destroy(go.GetComponent()); + public static void RemoveComponentImmediate(this GameObject go) where T : Component => UnityEngine.Object.DestroyImmediate(go.GetComponent()); + public static T AddComponent(this GameObject go, T toAdd) where T : Component => go.AddComponent().GetCopyOf(toAdd); public static void AddChild(this GameObject obj, GameObject child) diff --git a/Extensions/OtherExtensions.cs b/Extensions/OtherExtensions.cs index 3a81160..221113b 100644 --- a/Extensions/OtherExtensions.cs +++ b/Extensions/OtherExtensions.cs @@ -1,9 +1,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Text.RegularExpressions; using UnityEngine; +using UnityEngine.Events; #if UNITY_EDITOR using UnityEditor; @@ -419,11 +421,116 @@ public static string GetTypeAlias(this Type type) return !m_TypeAliases.TryGetValue(type, out string str) ? type.ToString() : str; } + public static List ToAssetTranslations(this string text) + { + return new List + { + new TextAssetTranslation + { + language = Language.English, + text = new TextAsset(text), + }, + new TextAssetTranslation + { + language = Language.Japanese, + text = new TextAsset(text), + } + }; + } + + public static List ToAssetTranslations(this string text, string jtext) + { + return new List + { + new TextAssetTranslation + { + language = Language.English, + text = new TextAsset(text), + }, + new TextAssetTranslation + { + language = Language.Japanese, + text = new TextAsset(jtext), + } + }; + } + public static void Edit(this TextArea textArea, string text) { - textArea.text = new TextAsset(text); + textArea.texts = text.ToAssetTranslations(); + textArea.SetText(); + } + + public static void Edit(this TextArea textArea, string text, string jtext) + { + textArea.texts = text.ToAssetTranslations(jtext); + textArea.SetText(); + } + + public static string GetText(this TextArea textArea, Language language) => textArea.texts.FirstOrDefault(tat => tat.language == language).text.text; + public static string GetEnglishText(this TextArea textArea) => textArea.GetText(Language.English); + public static string GetJapaneseText(this TextArea textArea) => textArea.GetText(Language.Japanese); + + public static List ToTranslations(this string text) + { + return new List + { + new Translation + { + language = Language.English, + text = text, + }, + new Translation + { + language = Language.Japanese, + text = text, + } + }; + } + + public static List ToTranslations(this string text, string jtext) + { + return new List + { + new Translation + { + language = Language.English, + text = text, + }, + new Translation + { + language = Language.Japanese, + text = jtext, + } + }; + } + + public static void Edit(this TextLanguageScript textLanguageScript, string text) + { + textLanguageScript.translations = text.ToTranslations(); + textLanguageScript.SetLanguage(); } + public static void Edit(this TextLanguageScript textLanguageScript, string text, string jtext) + { + textLanguageScript.translations = text.ToTranslations(jtext); + textLanguageScript.SetLanguage(); + } + + public static string GetText(this TextLanguageScript textLanguageScript, Language language) => textLanguageScript.translations.FirstOrDefault(translation => translation.language == language).text; + public static string GetEnglishText(this TextLanguageScript textLanguageScript) => textLanguageScript.GetText(Language.English); + public static string GetJapaneseText(this TextLanguageScript textLanguageScript) => textLanguageScript.GetText(Language.Japanese); + public static void Log(this string str, bool logToFile = true) => Console.Console.Log(str, logToFile); + + public static void EditLabels(this PauseOption pauseOption, string text) => pauseOption.labels = new TranslationCollection { translations = text.ToTranslations() }; + public static void EditLabels(this PauseOption pauseOption, string text, string jtext) => pauseOption.labels = new TranslationCollection { translations = text.ToTranslations(jtext) }; + public static void AddMethod(this PauseOption pauseOption, UnityAction state) => pauseOption.methods.AddListener(state); + public static void RemoveAllMethods(this PauseOption pauseOption) => pauseOption.methods.RemoveAllListeners(); + + + public static void SetText(this TranslationCollection translationCollection, Language language, string text) => translationCollection.translations[translationCollection.translations.IndexOf(translationCollection.translations.FirstOrDefault(translation => translation.language == language))] = new Translation { language = language, text = text }; + public static string GetEnglishText(this TranslationCollection translationCollection) => translationCollection.GetText(Language.English); + public static string GetJapaneseText(this TranslationCollection translationCollection) => translationCollection.GetText(Language.Japanese); } } diff --git a/Extensions/StringExtensions.cs b/Extensions/StringExtensions.cs index 2913bd8..6c65340 100644 --- a/Extensions/StringExtensions.cs +++ b/Extensions/StringExtensions.cs @@ -211,33 +211,33 @@ public static string ToRoman(this int i) /// Surround string with "i" tag /// public static string Italics(this string message) => $"{message}"; - - /// - /// Checks to see if a string that came from translation is a comment. - /// - public static bool IsTranslationComment(this string line) - { - return (line.StartsWith("#") || line.Equals(string.Empty) || !line.Contains(":")); - } - public static Tuple ToTranslation(this string line) - { - string key = line.Substring(0, line.IndexOf(':')); - string value = line.Replace($"{key}:", string.Empty); - return new Tuple(key.Trim('"'), value.FixTranslatedString()); - } - - /// - /// Fixes the string that came from translation - /// - public static string FixTranslatedString(this string toFix) - { - return toFix.TrimStart() - .TrimStart('"') - .TrimEnd('"') - .Replace("\\n", "\n") - .Replace("\\\"", "\""); - } + // /// + // /// Checks to see if a string that came from translation is a comment. + // /// + // public static bool IsTranslationComment(this string line) + // { + // return (line.StartsWith("#") || line.Equals(string.Empty) || !line.Contains(":")); + // } + + //public static Tuple ToTranslation(this string line) + //{ + // string key = line.Substring(0, line.IndexOf(':')); + // string value = line.Replace($"{key}:", string.Empty); + // return new Tuple(key.Trim('"'), value.FixTranslatedString()); + //} + + // /// + // /// Fixes the string that came from translation + // /// + // public static string FixTranslatedString(this string toFix) + // { + // return toFix.TrimStart() + // .TrimStart('"') + // .TrimEnd('"') + // .Replace("\\n", "\n") + // .Replace("\\\"", "\""); + //} internal static string ToQuotedString(this string str) { @@ -278,6 +278,25 @@ internal static string FromQuotedString(this string str) } return str1; } + + public static string ToYesOrNo(this bool torf) => torf ? "Yes" : "No"; + public static string ToOnOff(this bool torf, bool japanese = false) => japanese ? (torf ? "オン" : "オフ") : (torf ? "On" : "Off"); + + public static string ReplaceWithJapanese(this string str) + { + string amelia = str.Replace("Amelia", "アメリア").Replace("amelia", "アメリア"); + string watson = amelia.Replace("Watson", "ワトソン"); + string smol = watson.Replace("Smol", "スモール").Replace("SMOL", "スモール"); + string ame = smol.Replace("Ame", "アメ").Replace("AME", "アメ"); + string beeg = ame;//.Replace("Beeg", "ビーグ"); + string infinity = beeg.Replace("Infinite ", "無限"); + string increased = infinity;//.Replace("Increased ", "倍"); + string jump = increased.Replace("Jump", "ジャンプ"); + string speed = jump;//.Replace("Speed", "速度");//スピード"); + string slower = speed;//.Replace("Slower ", "ゆっくりと");//遅い"); + string groundpound = slower.Replace("Ground Pound", "グラウンドパウンド"); + return groundpound; + } } /// diff --git a/Level.cs b/Level.cs index bcb5d87..cd6acde 100644 --- a/Level.cs +++ b/Level.cs @@ -11,6 +11,8 @@ public enum Level TO_THE_MOON, NOTHING, MOGU_MOGU, - INUMORE + INUMORE, + RUSHIA, + INASCAPABLE_MADNESS } } diff --git a/Main.cs b/Main.cs index 79bd41c..fa38364 100644 --- a/Main.cs +++ b/Main.cs @@ -15,7 +15,7 @@ namespace SALT { public class Main { - public const string Version = "1.1"; + public const string Version = "1.1b"; private static string NewLine { get => System.Environment.NewLine + " "; } private static bool isPreInitialized; @@ -24,7 +24,10 @@ public class Main public static GameObject context { get; internal set; } public static MainScript mainScript => MainScript.main != null ? MainScript.main : (Main.context != null ? Main.context.GetComponent() : null); + + [Obsolete("Please use characterOption instead.")] public static OptionsScript options { get; internal set; } + public static CharacterOption characterOption { get; internal set; } public static GameObject player { get; internal set; } public static PlayerScript actualPlayer => PlayerScript.player != null ? PlayerScript.player : (Main.player != null ? Main.player.GetComponent() : null); @@ -32,16 +35,30 @@ public class Main internal static void NextCharacter() { int num = (MainScript.currentCharacter + 1) % actualPlayer.characterPacks.Count; - ChangeCharacter(num); + SetCharacter(num); } - internal static void ChangeCharacter(int num) + internal static void LastCharacter() + { + int num = MainScript.currentCharacter; + --num; + if (num < 0) + num = actualPlayer.characterPacks.Count - 1; + SetCharacter(num); + } + + internal static void SetCharacter(int num) { MainScript.currentCharacter = num; PlayerPrefs.SetInt("character", num); actualPlayer.currentCharacter = num; - if (Main.options != null) - Main.options.charSpriteRend.sprite = Main.options.charSprites[MainScript.currentCharacter]; + if (characterOption != null) + { + characterOption.po.currentSelection = MainScript.currentCharacter; + characterOption.charSprite.sprite = characterOption.charIcons[MainScript.currentCharacter]; + } + //if (Main.options != null) + // Main.options.charSpriteRend.sprite = Main.options.charSprites[MainScript.currentCharacter]; //if (actualPlayer.GetComponent().velocity.magnitude <= 0.25f) // actualPlayer.SpawnCharacter(num); } @@ -208,7 +225,7 @@ private static void MainMenu() tmrRT.offsetMax = vRT.offsetMax; tmrRT.anchoredPosition3D = vRT.anchoredPosition3D; tmrRT.SetSiblingIndex(vRT.GetSiblingIndex() + 2); - tmrRT.localPosition = tmrRT.localPosition.SetY((-vRT.localPosition.y) + 20); + tmrRT.localPosition = tmrRT.localPosition.SetY((-vRT.localPosition.y) + 4.5f); var txt = timerObject.GetComponent(); txt.text = UI.TimerUI.defaultTime; //txt.alignment = TextAlignmentOptions.TopRight; @@ -238,16 +255,22 @@ private static void MainMenu() modUI.name = "Mods"; GameObject modsTitle = modUI.FindChild("Text (TMP)", true); modsTitle.name = "modsTitle"; - modsTitle.GetComponent().text = modsTitle.GetComponent().text.Replace("Credits", "SALT (Smol Ame Loader Thing)"); + TextLanguageScript textLanguageScript = modsTitle.GetComponent(); + textLanguageScript.Edit(textLanguageScript.GetEnglishText().Replace("Credits", "SALT (Smol Ame Loader Thing)"), textLanguageScript.GetEnglishText().Replace("Credits", "SALT (スモール アメ ローダー シング)")); GameObject loaderCreator = modUI.FindChild("Text (TMP) (1)", true); loaderCreator.name = "LoaderCreator"; - loaderCreator.GetComponent().text = loaderCreator.GetComponent().text.Replace("Game by Kevin Stevens", "Mod Loader by MegaPiggy"); + string oldText = loaderCreator.GetComponent().text; + string enText = oldText.Replace("Game by Kevin Stevens", "Mod Loader by MegaPiggy"); + string jaText = oldText.Replace("Game by Kevin Stevens", "Modローダー by MegaPiggy");//"MegaPiggyによるModローダー"); + loaderCreator.GetComponent().text = enText; + loaderCreator.AddComponent().Edit(enText, jaText); GameObject modList = desk.FindChild(creditsObject.name, true); modList.name = "ModsEmpty"; modList.AddComponent(); TextArea modsArea = modList.GetComponentInChildren