Skip to content

Commit

Permalink
commit the dependency
Browse files Browse the repository at this point in the history
fix a few reload bugs
  • Loading branch information
Govorunb committed Dec 6, 2023
1 parent 4480685 commit bdcfe75
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ SCHIZO/Resources/AssetBundles/* merge=ours

*.asset text eol=lf
*.prefab text eol=lf
*.meta text eol=lf
*.meta text eol=lf
*.asmdef text eol=lf
31 changes: 20 additions & 11 deletions SCHIZO/Loading/BZErmsharkLoadingIcon.BelowZero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<uGUI_SceneLoading>();

loadingScreen.materialPengling.mainTexture = texture;
loadingScreen.pengling.texture = texture;
Expand All @@ -87,6 +95,7 @@ private void SetOurs()
private void SetOriginal()
{
if (!isOurs) return;
if (!loadingScreen) loadingScreen = GetComponentInParent<uGUI_SceneLoading>();

loadingScreen.materialPengling.mainTexture = originalTexture;
loadingScreen.pengling.texture = originalTexture;
Expand Down Expand Up @@ -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<float>(GetMoveThresholdProportion).Method);
return true;
}
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));
}
2 changes: 1 addition & 1 deletion SCHIZO/Subtitles/SubtitlesData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 11 additions & 7 deletions SCHIZO/Subtitles/SubtitlesHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using HarmonyLib;
using Nautilus.Handlers;
using Nautilus.Utility;
using UWE;
using GameSubtitles = Subtitles;

Expand All @@ -17,26 +18,29 @@ internal static class SubtitlesHandler
// runtime data
public static readonly Dictionary<string, Actor[]> 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;
Expand Down
1 change: 1 addition & 0 deletions Unity/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
Binary file added Unity/Assets/Plugins/FMODUnity.dll
Binary file not shown.

0 comments on commit bdcfe75

Please sign in to comment.