diff --git a/.gitattributes b/.gitattributes index 7cbd95a4..ffcbd162 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,5 @@ SCHIZO/Resources/AssetBundles/* merge=ours *.asset text eol=lf *.prefab text eol=lf -*.meta text eol=lf \ No newline at end of file +*.meta text eol=lf +*.asmdef text eol=lf \ No newline at end of file diff --git a/SCHIZO/Loading/BZErmsharkLoadingIcon.BelowZero.cs b/SCHIZO/Loading/BZErmsharkLoadingIcon.BelowZero.cs index ead07688..a3a13f12 100644 --- a/SCHIZO/Loading/BZErmsharkLoadingIcon.BelowZero.cs +++ b/SCHIZO/Loading/BZErmsharkLoadingIcon.BelowZero.cs @@ -59,18 +59,26 @@ private void Awake() originalRows = loadingScreen.rows; originalCols = loadingScreen.cols; - SaveUtils.RegisterOnStartLoadingEvent(() => - { - if (Utils.GetContinueMode()) - SetOurs(); - else - SetOriginal(); - }); + SaveUtils.RegisterOnStartLoadingEvent(OnLoading); + } + + private void OnDestroy() + { + SaveUtils.UnregisterOnStartLoadingEvent(OnLoading); + } + + private void OnLoading() + { + if (Utils.GetContinueMode()) + SetOurs(); + else + SetOriginal(); } private void SetOurs() { if (isOurs) return; + if (!loadingScreen) loadingScreen = GetComponentInParent(); loadingScreen.materialPengling.mainTexture = texture; loadingScreen.pengling.texture = texture; @@ -87,6 +95,7 @@ private void SetOurs() private void SetOriginal() { if (!isOurs) return; + if (!loadingScreen) loadingScreen = GetComponentInParent(); loadingScreen.materialPengling.mainTexture = originalTexture; loadingScreen.pengling.texture = originalTexture; @@ -144,7 +153,7 @@ private static bool Patch1_SmallerThresholdToStartMoving(CodeMatcher matcher) // patch 1 - smaller gap to start moving from idle (it's a proportion of the sprite width) matcher.MatchForward(false, new CodeMatch(OpCodes.Ldc_R4, 0.8f)); if (!matcher.IsValid) return false; - + matcher.Set(OpCodes.Call, new Func(GetMoveThresholdProportion).Method); return true; } @@ -162,7 +171,7 @@ private static bool Patch2_WaitForIdleLoopToStartMoving(CodeMatcher matcher) new CodeMatch(OpCodes.Ble_Un) ); if (!matcher.IsValid) return false; - + Label breakLabel = (Label) matcher.Operand; matcher.Advance(1); matcher.InsertAndAdvance( @@ -200,7 +209,7 @@ private static bool CustomIconAnimFramerate(out float __result) if (!instance || !instance.isOurs) return true; // technically a sin... but get_duration is only ever called inside Update - FrameAnimation ourAnim = (int)instance.loadingScreen.state switch + FrameAnimation ourAnim = (int) instance.loadingScreen.state switch { 0 => instance.idle, 1 => instance.moving, @@ -244,5 +253,5 @@ private bool HasAnimJustLooped(uGUI_SceneLoading loading) } private static int GetCurrentFrame(BZAnimation anim, float time) - => anim.from + (int)((time / anim.duration) * (anim.to - anim.from)); + => anim.from + (int) ((time / anim.duration) * (anim.to - anim.from)); } diff --git a/SCHIZO/Subtitles/SubtitlesData.cs b/SCHIZO/Subtitles/SubtitlesData.cs index 8da18419..1b786154 100644 --- a/SCHIZO/Subtitles/SubtitlesData.cs +++ b/SCHIZO/Subtitles/SubtitlesData.cs @@ -23,7 +23,7 @@ partial class SubtitleLine { global::SubtitlesData.Entry entry = new() { - key = $"{subtitlesKey}_{index}", + key = key, actor = actor, line = index, status = global::SubtitlesData.Status.Valid, diff --git a/SCHIZO/Subtitles/SubtitlesHandler.cs b/SCHIZO/Subtitles/SubtitlesHandler.cs index 56e4e4cb..a3acf95a 100644 --- a/SCHIZO/Subtitles/SubtitlesHandler.cs +++ b/SCHIZO/Subtitles/SubtitlesHandler.cs @@ -3,6 +3,7 @@ using System.Linq; using HarmonyLib; using Nautilus.Handlers; +using Nautilus.Utility; using UWE; using GameSubtitles = Subtitles; @@ -17,26 +18,29 @@ internal static class SubtitlesHandler // runtime data public static readonly Dictionary ActorTurns = []; #endif + static SubtitlesHandler() + { + SaveUtils.RegisterOnStartLoadingEvent(() => CoroutineHost.StartCoroutine(RegisterWhenReady())); + } public static void Register(SubtitlesData data) { Subtitles[data.key] = data; data.lines.ForEach(line => LanguageHandler.SetLanguageLine(line.key, line.text)); - - CoroutineHost.StartCoroutine(RegisterWhenReady(data)); } - private static IEnumerator RegisterWhenReady(SubtitlesData data) + private static IEnumerator RegisterWhenReady() { #if BELOWZERO while (!GameSubtitles._main) yield return null; - ActorTurns[data.key] = data.lines.Select(l => (Actor)l.actor).ToArray(); - GameSubtitles.main.subtitles[data.key] = ActorTurns[data.key]; - foreach (SubtitlesData.SubtitleLine line in data.lines) + foreach (SubtitlesData data in Subtitles.Values) { - GameSubtitles.main.sounds[line.key] = line.ToSubEntry(); + ActorTurns[data.key] = data.lines.Select(l => (Actor)l.actor).ToArray(); + GameSubtitles.main.subtitles[data.key] = ActorTurns[data.key]; + + data.lines.ForEach(line => GameSubtitles.main.sounds[line.key] = line.ToSubEntry()); } #else yield break; diff --git a/Unity/.gitignore b/Unity/.gitignore index b61efa83..4ce7ffab 100644 --- a/Unity/.gitignore +++ b/Unity/.gitignore @@ -80,6 +80,7 @@ AssetBundles .vscode/ # install FMOD yourself Assets/Plugins/FMOD* +!Assets/Plugins/FMODUnity.dll Assets/Editor Default Resources/FMOD* Assets/Editor Default Resources.meta Assets/Gizmos/FMOD* diff --git a/Unity/Assets/Plugins/FMODUnity.dll b/Unity/Assets/Plugins/FMODUnity.dll new file mode 100644 index 00000000..2cda0b43 Binary files /dev/null and b/Unity/Assets/Plugins/FMODUnity.dll differ