de-static-ify game manager and conductor for minigame logic

This commit is contained in:
minenice55 2024-01-18 23:52:38 -05:00
parent 96af9cf90e
commit ba02f2a56f
4 changed files with 21 additions and 17 deletions

View file

@ -1109,6 +1109,8 @@ namespace HeavenStudio
{ {
_currentMinigame = minigame; _currentMinigame = minigame;
minigame.minigameName = game; minigame.minigameName = game;
minigame.gameManager = this;
minigame.conductor = Conductor.instance;
} }
Vector3 originalScale = currentGameO.transform.localScale; Vector3 originalScale = currentGameO.transform.localScale;
currentGameO.transform.parent = eventCaller.GamesHolder.transform; currentGameO.transform.parent = eventCaller.GamesHolder.transform;

View file

@ -305,7 +305,7 @@ namespace HeavenStudio.Games
var amieWalkEvts = EventCaller.GetAllInGameManagerList("fanClub", new string[] { "friend walk" }); var amieWalkEvts = EventCaller.GetAllInGameManagerList("fanClub", new string[] { "friend walk" });
foreach (var e in amieWalkEvts) 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"]); 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" }); var choreoTypeEvts = EventCaller.GetAllInGameManagerList("fanClub", new string[] { "set performance type" });
foreach (var e in choreoTypeEvts) foreach (var e in choreoTypeEvts)
{ {
if (e.beat <= Conductor.instance.songPositionInBeatsAsDouble) if (e.beat <= conductor.songPositionInBeatsAsDouble)
{ {
FanClub.SetPerformanceType(e["type"]); FanClub.SetPerformanceType(e["type"]);
} }
@ -363,13 +363,12 @@ namespace HeavenStudio.Games
public override void OnBeatPulse(double beat) public override void OnBeatPulse(double beat)
{ {
var cond = Conductor.instance;
int whoBops = BeatIsInBopRegionInt(beat); int whoBops = BeatIsInBopRegionInt(beat);
bool goBopIdol = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Idol; bool goBopIdol = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Idol;
bool goBopSpec = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Spectators; bool goBopSpec = whoBops == (int)IdolBopType.Both || whoBops == (int)IdolBopType.Spectators;
if (goBopIdol) 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); idolAnimator.Play("IdolBeat" + GetPerformanceSuffix(), 0, 0);
Blue.PlayAnimState("Beat"); Blue.PlayAnimState("Beat");
@ -378,19 +377,17 @@ namespace HeavenStudio.Games
} }
if (goBopSpec) 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(); BopAll();
} }
} }
private void Update() private void Update()
{ {
var cond = Conductor.instance;
//idol jumping physics //idol jumping physics
float jumpPos = cond.GetPositionFromBeat(idolJumpStartTime, 1f); float jumpPos = conductor.GetPositionFromBeat(idolJumpStartTime, 1f);
float IDOL_SHADOW_SCALE = 1.18f; float IDOL_SHADOW_SCALE = 1.18f;
if (cond.songPositionInBeatsAsDouble >= idolJumpStartTime && cond.songPositionInBeatsAsDouble < idolJumpStartTime + 1f) if (conductor.songPositionInBeatsAsDouble >= idolJumpStartTime && conductor.songPositionInBeatsAsDouble < idolJumpStartTime + 1f)
{ {
hasJumped = true; hasJumped = true;
float yMul = jumpPos * 2f - 1f; float yMul = jumpPos * 2f - 1f;
@ -460,7 +457,7 @@ namespace HeavenStudio.Games
private void DisableSpecBop(double beat, float length) 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) if (bt >= noSpecBop.startBeat && bt < noSpecBop.startBeat + noSpecBop.length)
{ {
double thisStToNextSt = beat - noSpecBop.startBeat; double thisStToNextSt = beat - noSpecBop.startBeat;
@ -594,7 +591,7 @@ namespace HeavenStudio.Games
{ {
if (!responseToggle) 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); idolAnimator.Play("IdolCrap" + GetPerformanceSuffix(), -1, 0);
Blue.PlayAnimState("Crap"); Blue.PlayAnimState("Crap");
@ -605,7 +602,7 @@ namespace HeavenStudio.Games
private void DoIdolPeace(bool sync = true) 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) if (sync)
idolAnimator.Play("IdolPeace" + GetPerformanceSuffix(), -1, 0); idolAnimator.Play("IdolPeace" + GetPerformanceSuffix(), -1, 0);
@ -620,14 +617,14 @@ namespace HeavenStudio.Games
{ {
if (responseToggle) 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); idolAnimator.Play("IdolResponse" + GetPerformanceSuffix(), -1, 0);
} }
} }
private void DoIdolCall(int part = 0, bool big = false) 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) if (big)
{ {
@ -846,7 +843,7 @@ namespace HeavenStudio.Games
{ {
if (who == 3) if (who == 3)
{ {
if (GameManager.instance.autoplay) if (gameManager.autoplay)
{ {
Player.ClapStart(true, false, 0.1f); Player.ClapStart(true, false, 0.1f);
} }

View file

@ -27,6 +27,9 @@ namespace HeavenStudio.Games
[NonSerialized] public string minigameName; [NonSerialized] public string minigameName;
[NonSerialized] public GameManager gameManager;
[NonSerialized] public Conductor conductor;
#region Premade Input Actions #region Premade Input Actions
protected const int IAEmptyCat = -1; protected const int IAEmptyCat = -1;
protected const int IAPressCat = 0; protected const int IAPressCat = 0;

View file

@ -13,13 +13,15 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
AutoEmitOnScriptUpdate: 1 AutoEmitOnScriptUpdate: 1
AutoEmitDisabledPaths: AutoEmitDisabledPaths: []
- Assets/Scripts/SourceGenerators/ControllerLoaderGenerator.cs
DenseViewWidthThreshold: 512 DenseViewWidthThreshold: 512
_disableAutoReloadInBackground: 0 _disableAutoReloadInBackground: 0
ImportedScriptPaths: ImportedScriptPaths:
- Assets/Scripts/Minigames.cs - Assets/Scripts/Minigames.cs
- Assets/Editor/CreateAssetBundles.cs - Assets/Editor/CreateAssetBundles.cs
- Assets/Editor/CreateMinigameScriptTemplate.cs - Assets/Editor/CreateMinigameScriptTemplate.cs
- Assets/Scripts/Games/Minigame.cs
- Assets/Scripts/Games/FanClub/FanClub.cs
- Assets/Scripts/GameManager.cs
PathsToSkipImportEvent: [] PathsToSkipImportEvent: []
PathsToIgnoreOverwriteSettingOnAttribute: [] PathsToIgnoreOverwriteSettingOnAttribute: []