Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 13 additions & 63 deletions Assembly-CSharp/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RestorePackagesPath>packages</RestorePackagesPath>
<LangVersion>latest</LangVersion>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

<ItemGroup>
<Files Include="../Vanilla/*" />

<BuildDir Include="$(TargetDir)" />

<Dependencies Include="$(TargetDir)Newtonsoft.Json.dll" />
<Dependencies Include="$(TargetDir)MMHOOK_Assembly-CSharp.dll" />
<Dependencies Include="$(TargetDir)MMHOOK_PlayMaker.dll" />
<Dependencies Include="$(TargetDir)MonoMod.Utils.dll" />
Expand Down Expand Up @@ -72,10 +72,8 @@
<!-- Make the output directory -->
<MakeDir Directories="$(OutputDir)/" />

<!-- Copy the API, the documentation, the overridden mscorlib, and the README. -->
<!-- Copy the API, the documentation, and the README. -->
<Copy SourceFiles="../README.ModdingApi.md" DestinationFiles="$(OutputDir)/README.md" />
<Copy SourceFiles="../override/mscorlib.dll" DestinationFiles="$(OutputDir)/mscorlib.dll" />
<Copy SourceFiles="../override/mscorlib.xml" DestinationFiles="$(OutputDir)/mscorlib.xml" />
<Copy SourceFiles="$(TargetDir)MONOMODDED_Assembly-CSharp.dll" DestinationFiles="$(OutputDir)/Assembly-CSharp.dll" />
<Copy SourceFiles="$(TargetDir)Assembly-CSharp.mm.xml" DestinationFiles="$(OutputDir)/Assembly-CSharp.xml" />

Expand Down Expand Up @@ -141,64 +139,16 @@
</ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>../Vanilla/Assembly-CSharp.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<HintPath>..\override\mscorlib.dll</HintPath>
</Reference>
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>../Vanilla/netstandard.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../JsonNet/Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PlayMaker, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>../Vanilla/PlayMaker.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.AnimationModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.ImageConversionModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.JSONSerializeModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Physics2DModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.Physics2DModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>../Vanilla/UnityEngine.UIModule.dll</HintPath>
</Reference>
<Reference Include="../Vanilla/Assembly-CSharp.dll"/>
<Reference Include="../Vanilla/mscorlib.dll"/>
<!--<Reference Include="../override/mscorlib.dll"/>-->
<Reference Include="../Vanilla/netstandard.dll"/>
<Reference Include="../Vanilla/Newtonsoft.Json.dll"/>
<Reference Include="../Vanilla/PlayMaker.dll"/>
<Reference Include="../Vanilla/UnityEngine.dll"/>
<Reference Include="../Vanilla/UnityEngine.*.dll"/>
<Reference Include="../Vanilla/TeamCherry.*.dll"/>
<Reference Include="../Vanilla/System.dll"/>
<Reference Include="../Vanilla/System.*.dll"/>
</ItemGroup>
</Project>
80 changes: 80 additions & 0 deletions Assembly-CSharp/Language/Language.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UObject = UnityEngine.Object;
using USystemLanguage = UnityEngine.SystemLanguage;

namespace Language;

// for backwards compatibility
[MonoMod.MonoModLinkFrom("TeamCherry.Localization.Language")]
public static class Language
{
static Language()
{
TllType = Type.GetType("TeamCherry.Localization.Language, TeamCherry.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
TllLoadLanguage = TllType.GetMethod("LoadLanguage", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
TllLoadAvailableLanguages = TllType.GetMethod("LoadAvailableLanguages", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
TllGetLanguages = TllType.GetMethod("GetLanguages", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
TllSwitchLanguageStr = TllType.GetMethod("SwitchLanguage", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
TllSwitchLanguageLc = TllType.GetMethod("SwitchLanguage", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(TeamCherry.Localization.LanguageCode) }, Array.Empty<ParameterModifier>());
TllGetAsset = TllType.GetMethod("GetAsset", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
TllCurrentLanguage = TllType.GetMethod("CurrentLanguage", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
TllGet1 = TllType.GetMethod("Get", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
TllGetSheets = TllType.GetMethod("GetSheets", BindingFlags.Public | BindingFlags.Static, null, Array.Empty<Type>(), Array.Empty<ParameterModifier>());
TllGetKeys = TllType.GetMethod("GetKeys", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
TllHas1 = TllType.GetMethod("Has", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
TllHas2 = TllType.GetMethod("Has", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string), typeof(string) }, Array.Empty<ParameterModifier>());
TllHasSheet = TllType.GetMethod("HasSheet", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, Array.Empty<ParameterModifier>());
TllLanguageNameToCode = TllType.GetMethod("LanguageNameToCode", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(USystemLanguage) }, Array.Empty<ParameterModifier>());
TllGet2 = TllType.GetMethod("Get", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string), typeof(string) }, Array.Empty<ParameterModifier>());
}
private static readonly Type TllType;

private static readonly MethodInfo TllLoadLanguage;
public static void LoadLanguage() => TllLoadLanguage.Invoke(null, Array.Empty<object>());

private static readonly MethodInfo TllLoadAvailableLanguages;
public static void LoadAvailableLanguages() => TllLoadAvailableLanguages.Invoke(null, Array.Empty<object>());

private static readonly MethodInfo TllGetLanguages;
public static string[] GetLanguages() => (string[])(TllGetLanguages.Invoke(null, Array.Empty<object>()));

private static readonly MethodInfo TllSwitchLanguageStr;
public static bool SwitchLanguage(string langCode) => (bool)(TllSwitchLanguageStr.Invoke(null, new object[] { langCode }));

private static readonly MethodInfo TllSwitchLanguageLc;
public static bool SwitchLanguage(TeamCherry.Localization.LanguageCode code) => (bool)(TllSwitchLanguageLc.Invoke(null, new object[] { code }));

private static readonly MethodInfo TllGetAsset;
public static UObject GetAsset(string name) => (UObject)(TllGetAsset.Invoke(null, new object[] { name }));

private static readonly MethodInfo TllCurrentLanguage;
public static TeamCherry.Localization.LanguageCode CurrentLanguage() => (TeamCherry.Localization.LanguageCode)(TllCurrentLanguage.Invoke(null, Array.Empty<object>()));

private static readonly MethodInfo TllGet1;
public static string Get(string key) => (string)(TllGet1.Invoke(null, new object[] { key }));

private static readonly MethodInfo TllGetSheets;
public static IEnumerable<string> GetSheets() => (IEnumerable<string>)(TllGetSheets.Invoke(null, Array.Empty<object>()));

private static readonly MethodInfo TllGetKeys;
public static IEnumerable<string> GetKeys(string sheetTitle) => (IEnumerable<string>)(TllGetKeys.Invoke(null, new object[] { sheetTitle }));

private static readonly MethodInfo TllHas1;
public static bool Has(string key) => (bool)(TllHas1.Invoke(null, new object[] { key }));

private static readonly MethodInfo TllHas2;
public static bool Has(string key, string sheet) => (bool)(TllHas2.Invoke(null, new object[] { key, sheet }));

private static readonly MethodInfo TllHasSheet;
public static bool HasSheet(string sheet) => (bool)(TllHasSheet.Invoke(null, new object[] { sheet }));

private static readonly MethodInfo TllLanguageNameToCode;
public static TeamCherry.Localization.LanguageCode LanguageNameToCode(USystemLanguage name) => (TeamCherry.Localization.LanguageCode)(TllLanguageNameToCode.Invoke(null, new object[] { name }));

private static readonly MethodInfo TllGet2;
public static string GetInternal(string key, string sheetTitle) => (string)(TllGet2.Invoke(null, new object[] { key, sheetTitle }));

public static string Get(string key, string sheetTitle) => Modding.ModHooks.LanguageGet(key, sheetTitle);
}
10 changes: 5 additions & 5 deletions Assembly-CSharp/ModHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using JetBrains.Annotations;
using Modding.Patches;
using MonoMod;
using Newtonsoft.Json;

Check failure on line 10 in Assembly-CSharp/ModHooks.cs

View workflow job for this annotation

GitHub Actions / pr-build / build (windows, main)

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 10 in Assembly-CSharp/ModHooks.cs

View workflow job for this annotation

GitHub Actions / pr-build / build (linux, main)

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
using UnityEngine;
using System.Linq;
using Modding.Delegates;
Expand Down Expand Up @@ -61,10 +61,10 @@
{
string[] versionNums = Constants.GAME_VERSION.Split('.');

gameVersion.major = Convert.ToInt32(versionNums[0]);
gameVersion.minor = Convert.ToInt32(versionNums[1]);
gameVersion.revision = Convert.ToInt32(versionNums[2]);
gameVersion.package = Convert.ToInt32(versionNums[3]);
gameVersion.major = versionNums.Length > 0 ? Convert.ToInt32(versionNums[0]) : 0;
gameVersion.minor = versionNums.Length > 1 ? Convert.ToInt32(versionNums[1]) : 0;
gameVersion.revision = versionNums.Length > 2 ? Convert.ToInt32(versionNums[2]) : 0;
gameVersion.package = versionNums.Length > 3 ? Convert.ToInt32(versionNums[3]) : 0;
}
catch (Exception e)
{
Expand Down Expand Up @@ -225,7 +225,7 @@
/// <remarks>N/A</remarks>
internal static string LanguageGet(string key, string sheet)
{
string res = Patches.Language.GetInternal(key, sheet);
string res = Language.Language.GetInternal(key, sheet);

if (LanguageGetHook == null)
return res;
Expand Down
75 changes: 36 additions & 39 deletions Assembly-CSharp/Patches/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.SceneManagement;
using Encryption = TeamCherry.SharedUtils.Encryption;

// ReSharper disable all
#pragma warning disable 1591, 649, 414, 169, CS0108, CS0626
Expand Down Expand Up @@ -196,9 +197,7 @@ public void SaveGame(int saveSlot, Action<bool> callback)
text = JsonUtility.ToJson(obj);
}

bool flag = this.gameConfig.useSaveEncryption && !Platform.Current.IsFileSystemProtected;

if (flag)
if (this.gameConfig.useSaveEncryption && !Platform.Current.IsFileSystemProtected)
{
string graph = Encryption.Encrypt(text);
BinaryFormatter binaryFormatter = new BinaryFormatter();
Expand Down Expand Up @@ -578,12 +577,12 @@ public IEnumerator LoadSceneAdditive(string destScene)
AsyncOperation loadop = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(destScene, LoadSceneMode.Additive);
loadop.allowSceneActivation = true;
yield return loadop;
yield return UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(exitingScene);
UnityEngine.SceneManagement.SceneManager.UnloadScene(exitingScene);
ModHooks.OnSceneChanged(destScene);
this.RefreshTilemapInfo(destScene);
if (this.IsUnloadAssetsRequired(exitingScene, destScene))
{
Debug.LogFormat(this, "Unloading assets due to zone transition", new object[0]);
Debug.LogFormat(this, "Unloading assets due to zone transition", Array.Empty<object>());
yield return Resources.UnloadUnusedAssets();
}

Expand Down Expand Up @@ -628,48 +627,46 @@ public void OnWillActivateFirstLevel()
[MonoModIgnore]
public extern void SetTimeScale(float timescale);

[MonoModIgnore]
private extern void SetPausedState(bool value);

// code has been copied from PauseGameToggle
public IEnumerator PauseToggleDynamicMenu(MenuScreen screen, bool allowUnpause = false)
{
if (!this.TimeSlowed)
if (this.TimeSlowed)
{
yield break;
}
if (!this.playerData.GetBool(nameof(PlayerData.disablePause)) && this.gameState == GlobalEnums.GameState.PLAYING)
{
if (!this.playerData.GetBool(nameof(PlayerData.disablePause)) && this.gameState == GlobalEnums.GameState.PLAYING)
this.isPaused = true;
this.ui.SetState(GlobalEnums.UIState.PAUSED);
this.SetPausedState(true);
this.SetState(GlobalEnums.GameState.PAUSED);
if (HeroController.instance != null)
{
this.gameCams.StopCameraShake();
this.inputHandler.PreventPause();
this.inputHandler.StopUIInput();
this.actorSnapshotPaused.TransitionTo(0f);
this.isPaused = true;
this.SetState(GlobalEnums.GameState.PAUSED);
this.ui.AudioGoToPauseMenu(0.2f);
this.ui.UIPauseToDynamicMenu(screen);
if (HeroController.instance != null)
{
HeroController.instance.Pause();
}
this.gameCams.MoveMenuToHUDCamera();
this.SetTimeScale(0f);
yield return new WaitForSecondsRealtime(0.8f);
this.inputHandler.AllowPause();
HeroController.instance.Pause();
}
else if (allowUnpause && this.gameState == GlobalEnums.GameState.PAUSED)
this.gameCams.MoveMenuToHUDCamera();
this.inputHandler.PreventPause();
this.inputHandler.StopUIInput();
yield return new WaitForSecondsRealtime(0.3f);
this.inputHandler.AllowPause();
}
else if (allowUnpause && this.gameState == GlobalEnums.GameState.PAUSED)
{
this.isPaused = false;
this.inputHandler.PreventPause();
this.ui.SetState(GlobalEnums.UIState.PLAYING);
this.SetPausedState(false);
this.SetState(GlobalEnums.GameState.PLAYING);
if (HeroController.instance != null)
{
this.gameCams.ResumeCameraShake();
this.inputHandler.PreventPause();
this.actorSnapshotUnpaused.TransitionTo(0f);
this.isPaused = false;
this.ui.AudioGoToGameplay(0.2f);
this.ui.SetState( GlobalEnums.UIState.PLAYING);
this.SetState( GlobalEnums.GameState.PLAYING);
if (HeroController.instance != null)
{
HeroController.instance.UnPause();
}
MenuButtonList.ClearAllLastSelected();
this.SetTimeScale(1f);
yield return new WaitForSecondsRealtime(0.8f);
this.inputHandler.AllowPause();
HeroController.instance.UnPause();
}
MenuButtonList.ClearAllLastSelected();
yield return new WaitForSecondsRealtime(0.3f);
this.inputHandler.AllowPause();
}
yield break;
}
Expand Down
Loading
Loading