Skip to content

Commit

Permalink
Updated to game version v210530.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Jun 1, 2021
1 parent cdaba8f commit 870431d
Show file tree
Hide file tree
Showing 20 changed files with 728 additions and 139 deletions.
10 changes: 9 additions & 1 deletion Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ public enum Character
/// </summary>
KEVIN,
/// <summary>
/// Subaru as a duck. Popularized in a meme during May 2021.
/// </summary>
SHUBA,
/// <summary>
/// A cow that is supposed to the be the game creator Kevin.
/// </summary>
GURA_CAT,
/// <summary>
/// A character with nothing attached.
/// </summary>
NONE
NONE// = -1,
}
}
2 changes: 1 addition & 1 deletion Console/Commands/CompleteLevelCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public override bool Execute(string[] args)
var potClose = Object.FindObjectOfType<PotCloseTrigger>();
if (potClose != null)
{
SAObjects.GetRootGameObject("PotTrap").SetActiveRecursivelyExt(true);
Patches.PotClosedPatch.OnPotClosed += CompleteRedHeart;
potClose.OnTriggerEnter2D(Main.CreatePlayerCollider());
return true;
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Console/Commands/LoadLevelCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class LoadLevelCommand : ConsoleCommand
public static int Increment()
{
i += 1;
if (i > 9)
if (i > (int)EnumUtils.GetHighestValue<Level>())
i = 0;
return i;
}
Expand Down
4 changes: 2 additions & 2 deletions Console/Commands/SwitchCharacterCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions Extensions/GameObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ public static void PrintNamesOfComponents(this GameObject gameObject)

public static void RemoveComponent<T>(this GameObject go) where T : Component => UnityEngine.Object.Destroy(go.GetComponent<T>());

public static void RemoveComponentImmediate<T>(this GameObject go) where T : Component => UnityEngine.Object.DestroyImmediate(go.GetComponent<T>());

public static T AddComponent<T>(this GameObject go, T toAdd) where T : Component => go.AddComponent<T>().GetCopyOf<T>(toAdd);

public static void AddChild(this GameObject obj, GameObject child)
Expand Down
109 changes: 108 additions & 1 deletion Extensions/OtherExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<TextAssetTranslation> ToAssetTranslations(this string text)
{
return new List<TextAssetTranslation>
{
new TextAssetTranslation
{
language = Language.English,
text = new TextAsset(text),
},
new TextAssetTranslation
{
language = Language.Japanese,
text = new TextAsset(text),
}
};
}

public static List<TextAssetTranslation> ToAssetTranslations(this string text, string jtext)
{
return new List<TextAssetTranslation>
{
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<Translation> ToTranslations(this string text)
{
return new List<Translation>
{
new Translation
{
language = Language.English,
text = text,
},
new Translation
{
language = Language.Japanese,
text = text,
}
};
}

public static List<Translation> ToTranslations(this string text, string jtext)
{
return new List<Translation>
{
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);
}
}
71 changes: 45 additions & 26 deletions Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,33 +211,33 @@ public static string ToRoman(this int i)
/// Surround string with "i" tag
/// </summary>
public static string Italics(this string message) => $"<i>{message}</i>";

/// <summary>
/// Checks to see if a string that came from translation is a comment.
/// </summary>
public static bool IsTranslationComment(this string line)
{
return (line.StartsWith("#") || line.Equals(string.Empty) || !line.Contains(":"));
}

public static Tuple<string, string> ToTranslation(this string line)
{
string key = line.Substring(0, line.IndexOf(':'));
string value = line.Replace($"{key}:", string.Empty);
return new Tuple<string, string>(key.Trim('"'), value.FixTranslatedString());
}

/// <summary>
/// Fixes the string that came from translation
/// </summary>
public static string FixTranslatedString(this string toFix)
{
return toFix.TrimStart()
.TrimStart('"')
.TrimEnd('"')
.Replace("\\n", "\n")
.Replace("\\\"", "\"");
}
// /// <summary>
// /// Checks to see if a string that came from translation is a comment.
// /// </summary>
// public static bool IsTranslationComment(this string line)
// {
// return (line.StartsWith("#") || line.Equals(string.Empty) || !line.Contains(":"));
// }

//public static Tuple<string, string> ToTranslation(this string line)
//{
// string key = line.Substring(0, line.IndexOf(':'));
// string value = line.Replace($"{key}:", string.Empty);
// return new Tuple<string, string>(key.Trim('"'), value.FixTranslatedString());
//}

// /// <summary>
// /// Fixes the string that came from translation
// /// </summary>
// public static string FixTranslatedString(this string toFix)
// {
// return toFix.TrimStart()
// .TrimStart('"')
// .TrimEnd('"')
// .Replace("\\n", "\n")
// .Replace("\\\"", "\"");
//}

internal static string ToQuotedString(this string str)
{
Expand Down Expand Up @@ -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;
}
}

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion Level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public enum Level
TO_THE_MOON,
NOTHING,
MOGU_MOGU,
INUMORE
INUMORE,
RUSHIA,
INASCAPABLE_MADNESS
}
}
41 changes: 32 additions & 9 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,24 +24,41 @@ 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<MainScript>() : 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<PlayerScript>() : null);

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<Rigidbody2D>().velocity.magnitude <= 0.25f)
// actualPlayer.SpawnCharacter(num);
}
Expand Down Expand Up @@ -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<TextMeshProUGUI>();
txt.text = UI.TimerUI.defaultTime;
//txt.alignment = TextAlignmentOptions.TopRight;
Expand Down Expand Up @@ -238,16 +255,22 @@ private static void MainMenu()
modUI.name = "Mods";
GameObject modsTitle = modUI.FindChild("Text (TMP)", true);
modsTitle.name = "modsTitle";
modsTitle.GetComponent<TextMeshProUGUI>().text = modsTitle.GetComponent<TextMeshProUGUI>().text.Replace("Credits", "SALT (Smol Ame Loader Thing)");
TextLanguageScript textLanguageScript = modsTitle.GetComponent<TextLanguageScript>();
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<TextMeshProUGUI>().text = loaderCreator.GetComponent<TextMeshProUGUI>().text.Replace("Game by Kevin Stevens", "Mod Loader by MegaPiggy");
string oldText = loaderCreator.GetComponent<TextMeshProUGUI>().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<TextMeshProUGUI>().text = enText;
loaderCreator.AddComponent<TextLanguageScript>().Edit(enText, jaText);
GameObject modList = desk.FindChild(creditsObject.name, true);
modList.name = "ModsEmpty";
modList.AddComponent<UI.ModListUI>();
TextArea modsArea = modList.GetComponentInChildren<TextArea>();
string modText = $"<size=25>Press Ctrl+Tab to open up the command console.</size><size=5>{System.Environment.NewLine}{System.Environment.NewLine}</size><size=40>Mods:</size><size=10>{System.Environment.NewLine}{System.Environment.NewLine}</size>";
modsArea.Edit(modText);
string modJaText = $"<size=25>CTRL+TABを押し: オープンcommand console</size><size=5>{System.Environment.NewLine}{System.Environment.NewLine}</size><size=40>Mods:</size><size=10>{System.Environment.NewLine}{System.Environment.NewLine}</size>";
modsArea.Edit(modText, modJaText);

GameObject bookObject = UnityEngine.Object.FindObjectsOfType<BookRandomColor>().FirstOrDefault(b => b.GetComponent<BouncyScript>().bounceFactor == 1.5f).gameObject;
GameObject book = bookObject.CloneInstance();
Expand Down

0 comments on commit 870431d

Please sign in to comment.