Merge pull request #17 from Slaith12/main

Fixed event caller
This commit is contained in:
Jenny Crowe 2022-02-27 14:51:17 -07:00 committed by GitHub
commit 5a7268c3dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -41,9 +41,11 @@ namespace RhythmHeavenMania
List<Minigames.Minigame> minigamesInBeatmap = new List<Minigames.Minigame>(); List<Minigames.Minigame> minigamesInBeatmap = new List<Minigames.Minigame>();
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++) 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);
} }
} }
@ -55,18 +57,16 @@ namespace RhythmHeavenMania
private void Update() 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(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]); Minigames.Minigame game = minigames.Find(c => c.name == details[0]);
try try
{ {
currentEntity = (Beatmap.Entity)GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].Clone(); currentEntity = entity;
if (details.Length > 2) currentSwitchGame = details[2]; if (details.Length > 2) currentSwitchGame = details[2];

View file

@ -162,7 +162,7 @@ namespace RhythmHeavenMania
// FX entities should ALWAYS execute before gameplay entities // FX entities should ALWAYS execute before gameplay entities
for (int i = 0; i < fxEntities.Count; i++) for (int i = 0; i < fxEntities.Count; i++)
{ {
eventCaller.CallEvent(fxEntities[i].datamodel); eventCaller.CallEvent(fxEntities[i]);
currentEvent++; currentEvent++;
} }
@ -174,7 +174,7 @@ namespace RhythmHeavenMania
{ {
PreloadGame(entitesAtSameBeat[i].datamodel.Split('/')[0]); 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 // Thank you to @shshwdr for bring this to my attention
currentEvent++; currentEvent++;