From 554a8833ec5dea3640d588f6ae745344c5c42382 Mon Sep 17 00:00:00 2001 From: Slaith <34562469+Slaith12@users.noreply.github.com> Date: Sun, 27 Feb 2022 10:49:06 -0800 Subject: [PATCH] Made the call event function more reliable I have no idea why the function was set up the way it was before but it should be fine now. --- Assets/Scripts/EventCaller.cs | 13 +++++++------ Assets/Scripts/GameManager.cs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/EventCaller.cs b/Assets/Scripts/EventCaller.cs index 52189195..31e90cbf 100644 --- a/Assets/Scripts/EventCaller.cs +++ b/Assets/Scripts/EventCaller.cs @@ -41,9 +41,11 @@ namespace RhythmHeavenMania List minigamesInBeatmap = new List(); for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++) { - if (!minigamesInBeatmap.Contains(minigames.Find(c => c.name == GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0])) && !FXOnlyGames().Contains(GetMinigame(GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0]))) + //go through every entity in the timeline and add the game that they're from to the minigamesInBeatmap list (ignore entities from FX only categories, i.e. Game Manager and Count-Ins) + Minigames.Minigame game = GetMinigame(GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0]); + if (!minigamesInBeatmap.Contains(game) && !FXOnlyGames().Contains(game)) { - minigamesInBeatmap.Add(minigames.Find(c => c.name == GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0])); + minigamesInBeatmap.Add(game); } } @@ -59,14 +61,13 @@ namespace RhythmHeavenMania currentEntity.beat = GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].beat; } - public void CallEvent(string event_) + public void CallEvent(Beatmap.Entity entity) { - string[] details = event_.Split('/'); + string[] details = entity.datamodel.Split('/'); Minigames.Minigame game = minigames.Find(c => c.name == details[0]); - try { - currentEntity = (Beatmap.Entity)GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].Clone(); + currentEntity = entity; if (details.Length > 2) currentSwitchGame = details[2]; diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index e0ab92b9..159633c5 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -162,7 +162,7 @@ namespace RhythmHeavenMania // FX entities should ALWAYS execute before gameplay entities for (int i = 0; i < fxEntities.Count; i++) { - eventCaller.CallEvent(fxEntities[i].datamodel); + eventCaller.CallEvent(fxEntities[i]); currentEvent++; } @@ -174,7 +174,7 @@ namespace RhythmHeavenMania { PreloadGame(entitesAtSameBeat[i].datamodel.Split('/')[0]); } - eventCaller.CallEvent(entitesAtSameBeat[i].datamodel); + eventCaller.CallEvent(entitesAtSameBeat[i]); // Thank you to @shshwdr for bring this to my attention currentEvent++;