From 8501e4805c5cec5779fae120fc0e4e0fc27a0d08 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 1/2] 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++; From 10572ab35dd97c5fd0611147b3cabfd9c481f86b Mon Sep 17 00:00:00 2001 From: Slaith <34562469+Slaith12@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:01:31 -0800 Subject: [PATCH 2/2] Actually fixed event system Somehow I didn't notice while testing before that everything was wrong. I was already suspecting these lines of code would do something weird, and they certainly did. --- Assets/Scripts/EventCaller.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/Scripts/EventCaller.cs b/Assets/Scripts/EventCaller.cs index 31e90cbf..2581694e 100644 --- a/Assets/Scripts/EventCaller.cs +++ b/Assets/Scripts/EventCaller.cs @@ -57,8 +57,7 @@ namespace RhythmHeavenMania private void Update() { - if (GameManager.instance.currentEvent >= 0 && GameManager.instance.currentEvent < GameManager.instance.Beatmap.entities.Count) - currentEntity.beat = GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].beat; + } public void CallEvent(Beatmap.Entity entity)