From ba02f2a56f2a1c4b833b9d692931868ff506164c Mon Sep 17 00:00:00 2001 From: minenice55 Date: Thu, 18 Jan 2024 23:52:38 -0500 Subject: [PATCH] de-static-ify game manager and conductor for minigame logic --- Assets/Scripts/GameManager.cs | 2 ++ Assets/Scripts/Games/FanClub/FanClub.cs | 27 +++++++++---------- Assets/Scripts/Games/Minigame.cs | 3 +++ ...Generator.Editor.ProjectSettingsData.asset | 6 +++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 2fe4cb6f..ab31751b 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -1109,6 +1109,8 @@ namespace HeavenStudio { _currentMinigame = minigame; minigame.minigameName = game; + minigame.gameManager = this; + minigame.conductor = Conductor.instance; } Vector3 originalScale = currentGameO.transform.localScale; currentGameO.transform.parent = eventCaller.GamesHolder.transform; diff --git a/Assets/Scripts/Games/FanClub/FanClub.cs b/Assets/Scripts/Games/FanClub/FanClub.cs index 53f7ffb9..474ec746 100644 --- a/Assets/Scripts/Games/FanClub/FanClub.cs +++ b/Assets/Scripts/Games/FanClub/FanClub.cs @@ -305,7 +305,7 @@ namespace HeavenStudio.Games var amieWalkEvts = EventCaller.GetAllInGameManagerList("fanClub", new string[] { "friend walk" }); foreach (var e in amieWalkEvts) { - if (e.beat <= Conductor.instance.songPositionInBeatsAsDouble) + if (e.beat <= conductor.songPositionInBeatsAsDouble) { DancerTravel(e.beat, e.length, e["exit"], e["instant"]); } @@ -315,7 +315,7 @@ namespace HeavenStudio.Games var choreoTypeEvts = EventCaller.GetAllInGameManagerList("fanClub", new string[] { "set performance type" }); foreach (var e in choreoTypeEvts) { - if (e.beat <= Conductor.instance.songPositionInBeatsAsDouble) + if (e.beat <= conductor.songPositionInBeatsAsDouble) { FanClub.SetPerformanceType(e["type"]); } @@ -363,13 +363,12 @@ namespace HeavenStudio.Games public override void OnBeatPulse(double beat) { - var cond = Conductor.instance; int whoBops = BeatIsInBopRegionInt(beat); bool goBopIdol = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Idol; bool goBopSpec = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Spectators; if (goBopIdol) { - if (!(cond.songPositionInBeatsAsDouble >= noBop.startBeat && cond.songPositionInBeatsAsDouble < noBop.startBeat + noBop.length)) + if (!(conductor.songPositionInBeatsAsDouble >= noBop.startBeat && conductor.songPositionInBeatsAsDouble < noBop.startBeat + noBop.length)) { idolAnimator.Play("IdolBeat" + GetPerformanceSuffix(), 0, 0); Blue.PlayAnimState("Beat"); @@ -378,19 +377,17 @@ namespace HeavenStudio.Games } if (goBopSpec) { - if (!(cond.songPositionInBeatsAsDouble >= noSpecBop.startBeat && cond.songPositionInBeatsAsDouble < noSpecBop.startBeat + noSpecBop.length)) + if (!(conductor.songPositionInBeatsAsDouble >= noSpecBop.startBeat && conductor.songPositionInBeatsAsDouble < noSpecBop.startBeat + noSpecBop.length)) BopAll(); } } private void Update() { - var cond = Conductor.instance; - //idol jumping physics - float jumpPos = cond.GetPositionFromBeat(idolJumpStartTime, 1f); + float jumpPos = conductor.GetPositionFromBeat(idolJumpStartTime, 1f); float IDOL_SHADOW_SCALE = 1.18f; - if (cond.songPositionInBeatsAsDouble >= idolJumpStartTime && cond.songPositionInBeatsAsDouble < idolJumpStartTime + 1f) + if (conductor.songPositionInBeatsAsDouble >= idolJumpStartTime && conductor.songPositionInBeatsAsDouble < idolJumpStartTime + 1f) { hasJumped = true; float yMul = jumpPos * 2f - 1f; @@ -460,7 +457,7 @@ namespace HeavenStudio.Games private void DisableSpecBop(double beat, float length) { - double bt = Conductor.instance.songPositionInBeatsAsDouble; + double bt = conductor.songPositionInBeatsAsDouble; if (bt >= noSpecBop.startBeat && bt < noSpecBop.startBeat + noSpecBop.length) { double thisStToNextSt = beat - noSpecBop.startBeat; @@ -594,7 +591,7 @@ namespace HeavenStudio.Games { if (!responseToggle) { - if (!(Conductor.instance.songPositionInBeatsAsDouble >= noResponse.startBeat && Conductor.instance.songPositionInBeatsAsDouble < noResponse.startBeat + noResponse.length)) + if (!(conductor.songPositionInBeatsAsDouble >= noResponse.startBeat && conductor.songPositionInBeatsAsDouble < noResponse.startBeat + noResponse.length)) { idolAnimator.Play("IdolCrap" + GetPerformanceSuffix(), -1, 0); Blue.PlayAnimState("Crap"); @@ -605,7 +602,7 @@ namespace HeavenStudio.Games private void DoIdolPeace(bool sync = true) { - if (!(Conductor.instance.songPositionInBeatsAsDouble >= noCall.startBeat && Conductor.instance.songPositionInBeatsAsDouble < noCall.startBeat + noCall.length)) + if (!(conductor.songPositionInBeatsAsDouble >= noCall.startBeat && conductor.songPositionInBeatsAsDouble < noCall.startBeat + noCall.length)) { if (sync) idolAnimator.Play("IdolPeace" + GetPerformanceSuffix(), -1, 0); @@ -620,14 +617,14 @@ namespace HeavenStudio.Games { if (responseToggle) { - if (!(Conductor.instance.songPositionInBeatsAsDouble >= noResponse.startBeat && Conductor.instance.songPositionInBeatsAsDouble < noResponse.startBeat + noResponse.length)) + if (!(conductor.songPositionInBeatsAsDouble >= noResponse.startBeat && conductor.songPositionInBeatsAsDouble < noResponse.startBeat + noResponse.length)) idolAnimator.Play("IdolResponse" + GetPerformanceSuffix(), -1, 0); } } private void DoIdolCall(int part = 0, bool big = false) { - if (!(Conductor.instance.songPositionInBeatsAsDouble >= noCall.startBeat && Conductor.instance.songPositionInBeatsAsDouble < noCall.startBeat + noCall.length)) + if (!(conductor.songPositionInBeatsAsDouble >= noCall.startBeat && conductor.songPositionInBeatsAsDouble < noCall.startBeat + noCall.length)) { if (big) { @@ -846,7 +843,7 @@ namespace HeavenStudio.Games { if (who == 3) { - if (GameManager.instance.autoplay) + if (gameManager.autoplay) { Player.ClapStart(true, false, 0.1f); } diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index 957eba45..6c01f9aa 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -27,6 +27,9 @@ namespace HeavenStudio.Games [NonSerialized] public string minigameName; + [NonSerialized] public GameManager gameManager; + [NonSerialized] public Conductor conductor; + #region Premade Input Actions protected const int IAEmptyCat = -1; protected const int IAPressCat = 0; diff --git a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset index 1c5f64d9..125bfb10 100644 --- a/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset +++ b/ProjectSettings/SatorImaging.UnitySourceGenerator.Editor.ProjectSettingsData.asset @@ -13,13 +13,15 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: AutoEmitOnScriptUpdate: 1 - AutoEmitDisabledPaths: - - Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs + AutoEmitDisabledPaths: [] DenseViewWidthThreshold: 512 _disableAutoReloadInBackground: 0 ImportedScriptPaths: - Assets/Scripts/Minigames.cs - Assets/Editor/CreateAssetBundles.cs - Assets/Editor/CreateMinigameScriptTemplate.cs + - Assets/Scripts/Games/Minigame.cs + - Assets/Scripts/Games/FanClub/FanClub.cs + - Assets/Scripts/GameManager.cs PathsToSkipImportEvent: [] PathsToIgnoreOverwriteSettingOnAttribute: []