diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index b6e383dbb..d243fc624 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -258,15 +258,20 @@ namespace HeavenStudio } } - public void SeekAheadAndDoPreEvent(double start, float seekTime = 2f) + public void SeekAheadAndDoPreEvent(double start) { List entities = Beatmap.entities.Select(c => c.beat).ToList(); if (currentPreSequence < Beatmap.entities.Count && currentPreSequence >= 0) { + var seekEntity = Beatmap.entities[currentPreSequence]; + + float seekTime = EventCaller.instance.GetGameAction( + EventCaller.instance.GetMinigame(seekEntity.datamodel.Split(0)), seekEntity.datamodel.Split(1)).preFunctionLength; + if (start + seekTime >= entities[currentPreSequence]) { - float beat = Beatmap.entities[currentPreSequence].beat; - var entitiesAtSameBeat = Beatmap.entities.FindAll(c => c.beat == Beatmap.entities[currentPreSequence].beat); + float beat = seekEntity.beat; + var entitiesAtSameBeat = Beatmap.entities.FindAll(c => c.beat == seekEntity.beat); SortEventsByPriority(entitiesAtSameBeat); foreach (DynamicBeatmap.DynamicEntity entity in entitiesAtSameBeat) { @@ -340,7 +345,7 @@ namespace HeavenStudio //seek ahead to preload games that have assetbundles SeekAheadAndPreload(Conductor.instance.songPositionInBeatsAsDouble, seekTime); - SeekAheadAndDoPreEvent(Conductor.instance.songPositionInBeatsAsDouble, 2f); + SeekAheadAndDoPreEvent(Conductor.instance.songPositionInBeatsAsDouble); if (currentEvent < Beatmap.entities.Count && currentEvent >= 0) { diff --git a/Assets/Scripts/Games/Spaceball/Spaceball.cs b/Assets/Scripts/Games/Spaceball/Spaceball.cs index 04fc9b7f0..3117370e5 100644 --- a/Assets/Scripts/Games/Spaceball/Spaceball.cs +++ b/Assets/Scripts/Games/Spaceball/Spaceball.cs @@ -13,7 +13,9 @@ namespace HeavenStudio.Games.Loaders { new GameAction("shoot", "Pitch Ball") { - function = delegate { Spaceball.instance.Shoot(eventCaller.currentEntity.beat, false, eventCaller.currentEntity["type"]); }, + function = delegate { Spaceball.instance.Shoot(eventCaller.currentEntity.beat, false, eventCaller.currentEntity["type"]); }, + preFunction = delegate { Spaceball.instance.PrepareDispenser(); }, + preFunctionLength = 1, defaultLength = 2, parameters = new List() { @@ -22,7 +24,9 @@ namespace HeavenStudio.Games.Loaders }, new GameAction("shootHigh", "Pitch High Ball") { - function = delegate { Spaceball.instance.Shoot(eventCaller.currentEntity.beat, true, eventCaller.currentEntity["type"]); }, + function = delegate { Spaceball.instance.Shoot(eventCaller.currentEntity.beat, true, eventCaller.currentEntity["type"]); }, + preFunction = delegate { Spaceball.instance.PrepareDispenser(); }, + preFunctionLength = 1, defaultLength = 3, parameters = new List() { @@ -56,7 +60,7 @@ namespace HeavenStudio.Games.Loaders { function = delegate { Spaceball.instance.PrepareDispenser(); }, }, - }); + });; } } } diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index f24855523..a05874da7 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -155,6 +155,7 @@ namespace HeavenStudio public int priority = 0; public EventCallback inactiveFunction = delegate { }; public EventCallback preFunction = delegate { }; + public float preFunctionLength = 2.0f; /// /// Creates a block that can be used in the editor. The block's function and attributes are defined in the parentheses. @@ -172,7 +173,7 @@ namespace HeavenStudio /// Prevents the block from being shown in the game list. Block will still function normally if it is in the timeline. /// Runs two beats before this event is reached. /// Priority of this event. Higher priority events will be run first. - public GameAction(string actionName, string displayName, float defaultLength = 1, bool resizable = false, List parameters = null, EventCallback function = null, EventCallback inactiveFunction = null, EventCallback prescheduleFunction = null, bool hidden = false, EventCallback preFunction = null, int priority = 0) + public GameAction(string actionName, string displayName, float defaultLength = 1, bool resizable = false, List parameters = null, EventCallback function = null, EventCallback inactiveFunction = null, EventCallback prescheduleFunction = null, bool hidden = false, EventCallback preFunction = null, int priority = 0, float preFunctionLength = 2.0f) { this.actionName = actionName; if (displayName == String.Empty) this.displayName = actionName; @@ -186,6 +187,7 @@ namespace HeavenStudio this.inactiveFunction = inactiveFunction ?? delegate { }; this.preFunction = prescheduleFunction ?? delegate { }; this.priority = priority; + this.preFunctionLength = preFunctionLength; //todo: converting to new versions of GameActions