mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 12:47:38 +02:00
Integration of Jukebox Library (#451)
* add Jukebox library todo: - saving / loading of new format - inferrence of unknown data like past versions - move the temporary float casts to proper use of double - make sound related functions take double for timing - inform people that the Jukebox sound player was renamed to SoundByte lol * make sound, input scheduling, and super curve use double precision * successfully load charts * editor works again v1 riqs can be saved and loaded * first tempo and volume markers are unmovable fix loading of charts' easing values * use gsync / freesync * update Jukebox refs to SoundByte * game events use double part 1 Air Rally - Glee Club converted * don't load song if chart load fails * finish conversion of all minigames * remove editor waveform toggle * timeline now respects added song offset length clear cache files on app close prepped notes for dsp sync * update timeline length when offset changed * update to latest Jukebox * make error panel object in global game manager * improve conductor music scheduling * added error message box fix first game events sometimes not playing
This commit is contained in:
@ -4,6 +4,7 @@ using HeavenStudio.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
@ -64,14 +65,14 @@ namespace HeavenStudio.Games
|
||||
float grassWidth;
|
||||
float dotsWidth = 19.2f;
|
||||
|
||||
private float newBeat = -1f; // So that marching can happen on beat 0.
|
||||
private float marchStartBeat = -1f;
|
||||
private float marchOffset;
|
||||
private double newBeat = -1f; // So that marching can happen on beat 0.
|
||||
private double marchStartBeat = -1f;
|
||||
private double marchOffset;
|
||||
private int currentMarchBeat;
|
||||
private int stepCount;
|
||||
private bool isStepping;
|
||||
|
||||
private static float inactiveStart = -1f;
|
||||
private static double inactiveStart = -1f;
|
||||
|
||||
public bool isMarching => marchStartBeat != -1f;
|
||||
|
||||
@ -111,10 +112,10 @@ namespace HeavenStudio.Games
|
||||
|
||||
// Initialize vegetables.
|
||||
var cond = Conductor.instance;
|
||||
var entities = GameManager.instance.Beatmap.entities;
|
||||
var entities = GameManager.instance.Beatmap.Entities;
|
||||
|
||||
float startBeat = cond.songPositionInBeats;
|
||||
float endBeat = Single.MaxValue;
|
||||
double startBeat = cond.songPositionInBeatsAsDouble;
|
||||
double endBeat = double.MaxValue;
|
||||
|
||||
if (inactiveStart == -1f)
|
||||
{
|
||||
@ -123,7 +124,7 @@ namespace HeavenStudio.Games
|
||||
for (int i = 0; i < marchStarts.Count; i++)
|
||||
{
|
||||
var sampleBeat = marchStarts[i].beat;
|
||||
if (cond.songPositionInBeats <= sampleBeat + 0.25f) // 0.25-beat buffer in case the start marching event is directly next to the game switch event.
|
||||
if (cond.songPositionInBeatsAsDouble <= sampleBeat + 0.25f) // 0.25-beat buffer in case the start marching event is directly next to the game switch event.
|
||||
{
|
||||
startBeat = sampleBeat;
|
||||
break;
|
||||
@ -135,7 +136,7 @@ namespace HeavenStudio.Games
|
||||
// Find the beat of the next step, assuming marching started at inactiveStart.
|
||||
int stepsPassed = 0;
|
||||
|
||||
while (inactiveStart + (stepsPassed * 2f) < cond.songPositionInBeats)
|
||||
while (inactiveStart + (stepsPassed * 2f) < cond.songPositionInBeatsAsDouble)
|
||||
{
|
||||
stepsPassed++;
|
||||
|
||||
@ -210,7 +211,7 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
}
|
||||
|
||||
List<DynamicBeatmap.DynamicEntity> cuedMoleSounds = new List<DynamicBeatmap.DynamicEntity>();
|
||||
List<RiqEntity> cuedMoleSounds = new List<RiqEntity>();
|
||||
private void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
@ -219,12 +220,12 @@ namespace HeavenStudio.Games
|
||||
return;
|
||||
|
||||
// Mole sounds.
|
||||
var moleEvents = GameManager.instance.Beatmap.entities.FindAll(m => m.datamodel == "cropStomp/mole");
|
||||
var moleEvents = GameManager.instance.Beatmap.Entities.FindAll(m => m.datamodel == "cropStomp/mole");
|
||||
for (int i = 0; i < moleEvents.Count; i++)
|
||||
{
|
||||
var moleEvent = moleEvents[i];
|
||||
if (moleEvent["mute"]) continue;
|
||||
var timeToEvent = moleEvent.beat - cond.songPositionInBeats;
|
||||
var timeToEvent = moleEvent.beat - cond.songPositionInBeatsAsDouble;
|
||||
if (timeToEvent <= 4f && timeToEvent > 2f && !cuedMoleSounds.Contains(moleEvent))
|
||||
{
|
||||
cuedMoleSounds.Add(moleEvent);
|
||||
@ -328,7 +329,7 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
}
|
||||
|
||||
public void StartMarching(float beat)
|
||||
public void StartMarching(double beat)
|
||||
{
|
||||
marchStartBeat = beat;
|
||||
marchOffset = marchStartBeat % 1;
|
||||
@ -348,7 +349,7 @@ namespace HeavenStudio.Games
|
||||
|
||||
legsAnim.Play(stompAnim, 0, 0);
|
||||
|
||||
Jukebox.PlayOneShotGame("cropStomp/stomp");
|
||||
SoundByte.PlayOneShotGame("cropStomp/stomp");
|
||||
|
||||
if (shakeTween != null)
|
||||
shakeTween.Kill(true);
|
||||
@ -359,29 +360,29 @@ namespace HeavenStudio.Games
|
||||
isStepping = true;
|
||||
}
|
||||
|
||||
private void SpawnVeggie(float beat, float startBeat, bool isMole)
|
||||
private void SpawnVeggie(double beat, double startBeat, bool isMole)
|
||||
{
|
||||
var newVeggie = GameObject.Instantiate(isMole ? baseMole : baseVeggie, veggieHolder).GetComponent<Veggie>();
|
||||
|
||||
newVeggie.targetBeat = beat;
|
||||
|
||||
var veggieX = (beat - startBeat) * -stepDistance / 2f;
|
||||
newVeggie.transform.localPosition = new Vector3(veggieX, 0f, 0f);
|
||||
newVeggie.transform.localPosition = new Vector3((float)veggieX, 0f, 0f);
|
||||
newVeggie.Init();
|
||||
newVeggie.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public static void MarchInactive(float beat)
|
||||
public static void MarchInactive(double beat)
|
||||
{
|
||||
if (GameManager.instance.currentGame == "cropStomp") //this function is only meant for making march sounds while the game is inactive
|
||||
{
|
||||
return;
|
||||
}
|
||||
inactiveStart = beat;
|
||||
DynamicBeatmap.DynamicEntity gameSwitch = GameManager.instance.Beatmap.entities.Find(c => c.beat >= beat && c.datamodel == "gameManager/switchGame/cropStomp");
|
||||
RiqEntity gameSwitch = GameManager.instance.Beatmap.Entities.Find(c => c.beat >= beat && c.datamodel == "gameManager/switchGame/cropStomp");
|
||||
if (gameSwitch == null)
|
||||
return;
|
||||
int length = Mathf.CeilToInt((gameSwitch.beat - beat)/2);
|
||||
int length = (int)Math.Ceiling((gameSwitch.beat - beat)/2);
|
||||
MultiSound.Sound[] sounds = new MultiSound.Sound[length];
|
||||
for(int i = 0; i < length; i++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user