mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-29 04:53:06 +00:00
Asset Loading Fix (#843)
* (hopefullyt) fix asset loading issue * let mis-packed games load from res timing display tweak * fix initial pre-load not actually preloading needed games fix mr upbeat metronome * let's try this resyncing again
This commit is contained in:
parent
9045d1d8f1
commit
e2302216a2
7 changed files with 112 additions and 85 deletions
|
@ -96,9 +96,7 @@ namespace HeavenStudio
|
||||||
private float timelineVolume = 1f;
|
private float timelineVolume = 1f;
|
||||||
private float minigameVolume = 1f;
|
private float minigameVolume = 1f;
|
||||||
|
|
||||||
const bool doPitchResync = false;
|
public void SetTimelinePitch(float pitch)
|
||||||
|
|
||||||
public void SetTimelinePitch(float pitch, bool resync = false)
|
|
||||||
{
|
{
|
||||||
if (isPaused || deferTimeKeeping) return;
|
if (isPaused || deferTimeKeeping) return;
|
||||||
if (pitch != 0 && pitch != timelinePitch)
|
if (pitch != 0 && pitch != timelinePitch)
|
||||||
|
@ -111,17 +109,17 @@ namespace HeavenStudio
|
||||||
if (musicSource != null && musicSource.clip != null)
|
if (musicSource != null && musicSource.clip != null)
|
||||||
{
|
{
|
||||||
musicSource.pitch = SongPitch;
|
musicSource.pitch = SongPitch;
|
||||||
if (doPitchResync && isPlaying && resync && !deferTimeKeeping)
|
if (isPlaying && !(isPaused || deferTimeKeeping))
|
||||||
{
|
{
|
||||||
time = MapTimeToPitchChanges(absTime + absTimeAdjust);
|
time = MapTimeToPitchChanges(absTime + absTimeAdjust);
|
||||||
songPos = startPos + time;
|
songPos = startPos + time;
|
||||||
songPosBeat = GetBeatFromSongPos(songPos);
|
songPosBeat = GetBeatFromSongPos(songPos);
|
||||||
SeekMusicToTime(songPos, firstBeatOffset);
|
songPositionInBeatsAsDouble = GetSwungBeat(songPosBeat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMinigamePitch(float pitch, bool resync = false)
|
public void SetMinigamePitch(float pitch)
|
||||||
{
|
{
|
||||||
if (isPaused || deferTimeKeeping || !isPlaying) return;
|
if (isPaused || deferTimeKeeping || !isPlaying) return;
|
||||||
if (pitch != 0 && pitch != minigamePitch)
|
if (pitch != 0 && pitch != minigamePitch)
|
||||||
|
@ -134,12 +132,12 @@ namespace HeavenStudio
|
||||||
if (musicSource != null && musicSource.clip != null)
|
if (musicSource != null && musicSource.clip != null)
|
||||||
{
|
{
|
||||||
musicSource.pitch = SongPitch;
|
musicSource.pitch = SongPitch;
|
||||||
if (doPitchResync && isPlaying && resync && !deferTimeKeeping)
|
if (isPlaying && !(isPaused || deferTimeKeeping))
|
||||||
{
|
{
|
||||||
time = MapTimeToPitchChanges(absTime + absTimeAdjust);
|
time = MapTimeToPitchChanges(absTime + absTimeAdjust);
|
||||||
songPos = startPos + time;
|
songPos = startPos + time;
|
||||||
songPosBeat = GetBeatFromSongPos(songPos);
|
songPosBeat = GetBeatFromSongPos(songPos);
|
||||||
SeekMusicToTime(songPos, firstBeatOffset);
|
songPositionInBeatsAsDouble = GetSwungBeat(songPosBeat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +169,7 @@ namespace HeavenStudio
|
||||||
|
|
||||||
songPosBeat = GetBeatFromSongPos(time);
|
songPosBeat = GetBeatFromSongPos(time);
|
||||||
|
|
||||||
gameManager.SetCurrentEventToClosest(beat);
|
gameManager.SetCurrentEventToClosest(beat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlaySetup(double beat)
|
public void PlaySetup(double beat)
|
||||||
|
|
|
@ -118,24 +118,22 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public static List<RiqEntity> GetAllInGameManagerList(string gameName, string[] include)
|
public static List<RiqEntity> GetAllInGameManagerList(string gameName, string[] include)
|
||||||
{
|
{
|
||||||
List<RiqEntity> temp1 = instance.gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
Predicate<RiqEntity> match = c =>
|
||||||
List<RiqEntity> temp2 = new List<RiqEntity>();
|
|
||||||
foreach (string s in include)
|
|
||||||
{
|
{
|
||||||
temp2.AddRange(temp1.FindAll(c => c.datamodel.Split('/')[1].Equals(s)));
|
string[] details = c.datamodel.Split('/');
|
||||||
}
|
return details[0] == gameName && include.Contains(details[1]);
|
||||||
return temp2;
|
};
|
||||||
|
return instance.gameManager.Beatmap.Entities.FindAll(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<RiqEntity> GetAllInGameManagerListExclude(string gameName, string[] exclude)
|
public static List<RiqEntity> GetAllInGameManagerListExclude(string gameName, string[] exclude)
|
||||||
{
|
{
|
||||||
List<RiqEntity> temp1 = instance.gameManager.Beatmap.Entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
Predicate<RiqEntity> match = c =>
|
||||||
List<RiqEntity> temp2 = new List<RiqEntity>();
|
|
||||||
foreach (string s in exclude)
|
|
||||||
{
|
{
|
||||||
temp2.AddRange(temp1.FindAll(c => !c.datamodel.Split('/')[1].Equals(s)));
|
string[] details = c.datamodel.Split('/');
|
||||||
}
|
return details[0] == gameName && !exclude.Contains(details[1]);
|
||||||
return temp2;
|
};
|
||||||
|
return instance.gameManager.Beatmap.Entities.FindAll(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Minigames.Minigame> FXOnlyGames()
|
public static List<Minigames.Minigame> FXOnlyGames()
|
||||||
|
|
|
@ -22,7 +22,6 @@ namespace HeavenStudio
|
||||||
|
|
||||||
[Header("Lists")]
|
[Header("Lists")]
|
||||||
[NonSerialized] public RiqBeatmap Beatmap = new();
|
[NonSerialized] public RiqBeatmap Beatmap = new();
|
||||||
private Dictionary<string, GameObject> cachedGamePrefabs = new();
|
|
||||||
[NonSerialized] public ObjectPool<Sound> SoundObjects;
|
[NonSerialized] public ObjectPool<Sound> SoundObjects;
|
||||||
|
|
||||||
[Header("Components")]
|
[Header("Components")]
|
||||||
|
@ -372,7 +371,7 @@ namespace HeavenStudio
|
||||||
List<RiqEntity> entitiesAtSameBeat = ListPool<RiqEntity>.Get();
|
List<RiqEntity> entitiesAtSameBeat = ListPool<RiqEntity>.Get();
|
||||||
Minigames.Minigame inf;
|
Minigames.Minigame inf;
|
||||||
|
|
||||||
//seek ahead to preload games that have assetbundles
|
// seek ahead to preload games that have assetbundles
|
||||||
if (currentPreSwitch < allGameSwitches.Count && currentPreSwitch >= 0)
|
if (currentPreSwitch < allGameSwitches.Count && currentPreSwitch >= 0)
|
||||||
{
|
{
|
||||||
if (start + seekTime >= allGameSwitches[currentPreSwitch].beat)
|
if (start + seekTime >= allGameSwitches[currentPreSwitch].beat)
|
||||||
|
@ -723,7 +722,7 @@ namespace HeavenStudio
|
||||||
conductor.SetVolume(Beatmap.VolumeChanges[0]["volume"]);
|
conductor.SetVolume(Beatmap.VolumeChanges[0]["volume"]);
|
||||||
conductor.firstBeatOffset = Beatmap.data.offset;
|
conductor.firstBeatOffset = Beatmap.data.offset;
|
||||||
conductor.PlaySetup(beat);
|
conductor.PlaySetup(beat);
|
||||||
SetCurrentEventToClosest(beat);
|
SetCurrentEventToClosest(beat, true);
|
||||||
Debug.Log("Playing at " + beat);
|
Debug.Log("Playing at " + beat);
|
||||||
KillAllSounds();
|
KillAllSounds();
|
||||||
|
|
||||||
|
@ -845,7 +844,7 @@ namespace HeavenStudio
|
||||||
WaitUntil yieldBeatmap = new WaitUntil(() => Beatmap != null && BeatmapEntities() > 0);
|
WaitUntil yieldBeatmap = new WaitUntil(() => Beatmap != null && BeatmapEntities() > 0);
|
||||||
WaitUntil yieldAudio = new WaitUntil(() => AudioLoadDone || (ChartLoadError && !GlobalGameManager.IsShowingDialog));
|
WaitUntil yieldAudio = new WaitUntil(() => AudioLoadDone || (ChartLoadError && !GlobalGameManager.IsShowingDialog));
|
||||||
WaitUntil yieldGame = null;
|
WaitUntil yieldGame = null;
|
||||||
List<Minigames.Minigame> gamesToPreload = SeekAheadAndPreload(beat, 4f);
|
List<Minigames.Minigame> gamesToPreload = SetCurrentEventToClosest(beat, true);
|
||||||
Debug.Log($"Preloading {gamesToPreload.Count} games");
|
Debug.Log($"Preloading {gamesToPreload.Count} games");
|
||||||
if (gamesToPreload.Count > 0)
|
if (gamesToPreload.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -974,9 +973,10 @@ namespace HeavenStudio
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCurrentEventToClosest(double beat, bool canPreload = false)
|
public List<Minigames.Minigame> SetCurrentEventToClosest(double beat, bool canPreload = false)
|
||||||
{
|
{
|
||||||
SortEventsList();
|
SortEventsList();
|
||||||
|
List<Minigames.Minigame> preload = new();
|
||||||
onBeatChanged?.Invoke(beat);
|
onBeatChanged?.Invoke(beat);
|
||||||
if (Beatmap.Entities.Count > 0)
|
if (Beatmap.Entities.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -984,15 +984,13 @@ namespace HeavenStudio
|
||||||
currentPreEvent = GetIndexAfter(eventBeats, beat);
|
currentPreEvent = GetIndexAfter(eventBeats, beat);
|
||||||
currentPreSequence = GetIndexAfter(eventBeats, beat);
|
currentPreSequence = GetIndexAfter(eventBeats, beat);
|
||||||
|
|
||||||
var gameSwitchs = Beatmap.Entities.FindAll(c => c.datamodel.Split("/")[1] == "switchGame");
|
|
||||||
|
|
||||||
string newGame = Beatmap.Entities[Math.Min(currentEvent, eventBeats.Count - 1)].datamodel.Split(0);
|
string newGame = Beatmap.Entities[Math.Min(currentEvent, eventBeats.Count - 1)].datamodel.Split(0);
|
||||||
|
|
||||||
if (gameSwitchs.Count > 0)
|
if (allGameSwitches.Count > 0)
|
||||||
{
|
{
|
||||||
int index = GetIndexBefore(gameSwitchs.Select(c => c.beat).ToList(), beat);
|
int index = GetIndexBefore(allGameSwitches.Select(c => c.beat).ToList(), beat);
|
||||||
currentPreSwitch = index;
|
currentPreSwitch = index;
|
||||||
var closestGameSwitch = gameSwitchs[index];
|
var closestGameSwitch = allGameSwitches[index];
|
||||||
if (closestGameSwitch.beat <= beat)
|
if (closestGameSwitch.beat <= beat)
|
||||||
{
|
{
|
||||||
newGame = closestGameSwitch.datamodel.Split(2);
|
newGame = closestGameSwitch.datamodel.Split(2);
|
||||||
|
@ -1007,7 +1005,7 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
if (index - 1 >= 0)
|
if (index - 1 >= 0)
|
||||||
{
|
{
|
||||||
newGame = gameSwitchs[index - 1].datamodel.Split(2);
|
newGame = allGameSwitches[index - 1].datamodel.Split(2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1015,13 +1013,17 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// newGame = gameSwitchs[gameSwitchs.IndexOf(gameSwitchs.Find(c => c.beat == MathUtils.GetClosestInList(gameSwitchs.Select(c => c.beat).ToList(), beat)))].datamodel.Split(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetGameInfo(newGame).fxOnly)
|
if (!GetGameInfo(newGame).fxOnly)
|
||||||
{
|
{
|
||||||
if (canPreload)
|
if (canPreload)
|
||||||
{
|
{
|
||||||
|
Minigames.Minigame inf = GetGameInfo(newGame);
|
||||||
|
if (inf != null)
|
||||||
|
{
|
||||||
|
preload.Add(inf);
|
||||||
|
}
|
||||||
StartCoroutine(WaitAndSetGame(newGame));
|
StartCoroutine(WaitAndSetGame(newGame));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1091,7 +1093,8 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
onSectionChange?.Invoke(currentSection, lastSection);
|
onSectionChange?.Invoke(currentSection, lastSection);
|
||||||
|
|
||||||
SeekAheadAndPreload(beat);
|
preload.AddRange(SeekAheadAndPreload(beat));
|
||||||
|
return preload;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -1124,7 +1127,7 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (beat + 0.25 > Math.Max(conductor.songPositionInBeatsAsDouble, 0))
|
while (conductor.GetUnSwungBeat(beat + 0.25) > Math.Max(conductor.unswungSongPositionInBeatsAsDouble, 0))
|
||||||
{
|
{
|
||||||
if (!conductor.isPlaying)
|
if (!conductor.isPlaying)
|
||||||
{
|
{
|
||||||
|
@ -1165,13 +1168,18 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public void DestroyGame()
|
public void DestroyGame()
|
||||||
{
|
{
|
||||||
cachedGamePrefabs.Clear();
|
|
||||||
SoundByte.UnloadAudioClips();
|
SoundByte.UnloadAudioClips();
|
||||||
SetGame("noGame");
|
SetGame("noGame");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string currentGameRequest = null;
|
||||||
private IEnumerator WaitAndSetGame(string game, bool useMinigameColor = true)
|
private IEnumerator WaitAndSetGame(string game, bool useMinigameColor = true)
|
||||||
{
|
{
|
||||||
|
if (game == currentGameRequest)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
currentGameRequest = game;
|
||||||
var inf = GetGameInfo(game);
|
var inf = GetGameInfo(game);
|
||||||
if (inf != null && inf.usesAssetBundle)
|
if (inf != null && inf.usesAssetBundle)
|
||||||
{
|
{
|
||||||
|
@ -1179,13 +1187,15 @@ namespace HeavenStudio
|
||||||
{
|
{
|
||||||
// Debug.Log($"ASYNC loading assetbundles for game {game}");
|
// Debug.Log($"ASYNC loading assetbundles for game {game}");
|
||||||
inf.LoadAssetsAsync().Forget();
|
inf.LoadAssetsAsync().Forget();
|
||||||
}
|
|
||||||
yield return new WaitUntil(() => inf.AssetsLoaded);
|
yield return new WaitUntil(() => inf.AssetsLoaded);
|
||||||
|
}
|
||||||
SetGame(game, useMinigameColor);
|
SetGame(game, useMinigameColor);
|
||||||
|
currentGameRequest = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetGame(game, useMinigameColor);
|
SetGame(game, useMinigameColor);
|
||||||
|
currentGameRequest = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,10 +1210,14 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public GameObject GetGame(string name)
|
public GameObject GetGame(string name)
|
||||||
{
|
{
|
||||||
var gameInfo = GetGameInfo(name);
|
if (name is null or "" or "noGame")
|
||||||
|
{
|
||||||
|
return Resources.Load<GameObject>($"Games/noGame");
|
||||||
|
}
|
||||||
|
|
||||||
|
Minigames.Minigame gameInfo = GetGameInfo(name);
|
||||||
if (gameInfo != null)
|
if (gameInfo != null)
|
||||||
{
|
{
|
||||||
GameObject prefab;
|
|
||||||
if (gameInfo.inferred)
|
if (gameInfo.inferred)
|
||||||
{
|
{
|
||||||
return Resources.Load<GameObject>($"Games/noGame");
|
return Resources.Load<GameObject>($"Games/noGame");
|
||||||
|
@ -1226,6 +1240,8 @@ namespace HeavenStudio
|
||||||
return Resources.Load<GameObject>($"Games/noGame");
|
return Resources.Load<GameObject>($"Games/noGame");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameObject prefab;
|
||||||
if (gameInfo.usesAssetBundle)
|
if (gameInfo.usesAssetBundle)
|
||||||
{
|
{
|
||||||
//game is packed in an assetbundle, load from that instead
|
//game is packed in an assetbundle, load from that instead
|
||||||
|
@ -1251,6 +1267,7 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// games with no assetbundle (usually indev games)
|
||||||
prefab = Resources.Load<GameObject>($"Games/{name}");
|
prefab = Resources.Load<GameObject>($"Games/{name}");
|
||||||
if (prefab != null)
|
if (prefab != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,8 @@ namespace HeavenStudio.Games.Loaders
|
||||||
using static Minigames;
|
using static Minigames;
|
||||||
public static class AgbUpbeatLoader
|
public static class AgbUpbeatLoader
|
||||||
{
|
{
|
||||||
public static Minigame AddGame(EventCaller eventCaller) {
|
public static Minigame AddGame(EventCaller eventCaller)
|
||||||
|
{
|
||||||
RiqEntity BackgroundUpdater(string datamodel, RiqEntity e)
|
RiqEntity BackgroundUpdater(string datamodel, RiqEntity e)
|
||||||
{
|
{
|
||||||
if (datamodel == "mrUpbeat/changeBG" && e.dynamicData.ContainsKey("toggle") && !e.dynamicData.ContainsKey("ease"))
|
if (datamodel == "mrUpbeat/changeBG" && e.dynamicData.ContainsKey("toggle") && !e.dynamicData.ContainsKey("ease"))
|
||||||
|
@ -133,9 +134,9 @@ namespace HeavenStudio.Games.Loaders
|
||||||
resizable = true,
|
resizable = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new List<string>() {"agb", "keep"},
|
new List<string>() { "agb", "keep" },
|
||||||
"agboffbeat", "en",
|
"agboffbeat", "en",
|
||||||
new List<string>() {},
|
new List<string>() { },
|
||||||
chronologicalSortKey: 101
|
chronologicalSortKey: 101
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +198,8 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
List<RiqEntity> prevEntities = GameManager.instance.Beatmap.Entities.FindAll(c => c.beat <= beat && c.datamodel.Split(0) == "mrUpbeat");
|
List<RiqEntity> prevEntities = GameManager.instance.Beatmap.Entities.FindAll(c => c.beat <= beat && c.datamodel.Split(0) == "mrUpbeat");
|
||||||
|
|
||||||
if (beat >= startBlippingBeat) {
|
if (beat >= startBlippingBeat)
|
||||||
|
{
|
||||||
double tempBeat = ((beat % 1 == 0.5) ? Mathf.Floor((float)beat) : Mathf.Round((float)beat)) + (startBlippingBeat % 1);
|
double tempBeat = ((beat % 1 == 0.5) ? Mathf.Floor((float)beat) : Mathf.Round((float)beat)) + (startBlippingBeat % 1);
|
||||||
BeatAction.New(instance, new List<BeatAction.Action>() {
|
BeatAction.New(instance, new List<BeatAction.Action>() {
|
||||||
new BeatAction.Action(tempBeat, delegate { man.RecursiveBlipping(tempBeat); })
|
new BeatAction.Action(tempBeat, delegate { man.RecursiveBlipping(tempBeat); })
|
||||||
|
@ -209,17 +211,22 @@ namespace HeavenStudio.Games
|
||||||
var bgColorEntity = prevEntities.FindLast(x => x.datamodel.Split(1) == "changeBG" && x.beat <= beat);
|
var bgColorEntity = prevEntities.FindLast(x => x.datamodel.Split(1) == "changeBG" && x.beat <= beat);
|
||||||
var upbeatColorEntity = prevEntities.FindLast(x => x.datamodel.Split(1) == "upbeatColors" && x.beat <= beat);
|
var upbeatColorEntity = prevEntities.FindLast(x => x.datamodel.Split(1) == "upbeatColors" && x.beat <= beat);
|
||||||
|
|
||||||
if (bgColorEntity != null) {
|
if (bgColorEntity != null)
|
||||||
|
{
|
||||||
bg.color = bgColorEntity["end"];
|
bg.color = bgColorEntity["end"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upbeatColorEntity != null) {
|
if (upbeatColorEntity != null)
|
||||||
|
{
|
||||||
blipMaterial.SetColor("_ColorBravo", upbeatColorEntity["blipColor"]);
|
blipMaterial.SetColor("_ColorBravo", upbeatColorEntity["blipColor"]);
|
||||||
Color shadowColor = upbeatColorEntity["shadowColor"];
|
Color shadowColor = upbeatColorEntity["shadowColor"];
|
||||||
if (upbeatColorEntity["setShadow"]) foreach (var shadow in shadowSr) {
|
if (upbeatColorEntity["setShadow"]) foreach (var shadow in shadowSr)
|
||||||
|
{
|
||||||
shadow.color = new Color(shadowColor.r, shadowColor.g, shadowColor.b, 1);
|
shadow.color = new Color(shadowColor.r, shadowColor.g, shadowColor.b, 1);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
blipMaterial.SetColor("_ColorBravo", new Color(0, 1f, 0));
|
blipMaterial.SetColor("_ColorBravo", new Color(0, 1f, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,31 +234,33 @@ namespace HeavenStudio.Games
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
bg.color = bgColorEase.GetColor();
|
bg.color = bgColorEase.GetColor();
|
||||||
if (conductor.isPlaying && !conductor.isPaused) {
|
if (conductor.isPlaying && !conductor.isPaused)
|
||||||
var songPos = conductor.songPositionInBeatsAsDouble;
|
{
|
||||||
|
double songPos = conductor.songPositionInBeatsAsDouble;
|
||||||
|
|
||||||
if (songPos >= startSteppingBeat - 2) {
|
if (songPos >= startSteppingBeat - 2)
|
||||||
|
{
|
||||||
man.canStep = true;
|
man.canStep = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (songPos >= startSteppingBeat) {
|
if (songPos >= startSteppingBeat)
|
||||||
|
{
|
||||||
RecursiveStepping(startSteppingBeat);
|
RecursiveStepping(startSteppingBeat);
|
||||||
startSteppingBeat = double.MaxValue;
|
startSteppingBeat = double.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (songPos >= startBlippingBeat) {
|
if (songPos >= startBlippingBeat)
|
||||||
|
{
|
||||||
man.RecursiveBlipping(startBlippingBeat);
|
man.RecursiveBlipping(startBlippingBeat);
|
||||||
startBlippingBeat = double.MaxValue;
|
startBlippingBeat = double.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (songPos > metronomeBeat + 1)
|
if (metronomeBeat != double.MaxValue)
|
||||||
{
|
{
|
||||||
metronomeAnim.Play("MetronomeGo" + currentMetronomeDir, -1, 1);
|
currentMetronomeDir = songPos >= metronomeBeat && songPos <= metronomeBeat + 1
|
||||||
metronomeAnim.speed = 0;
|
? (stepIterate % 2 == 0) ? "Right" : "Left"
|
||||||
}
|
: (stepIterate % 2 == 1) ? "Right" : "Left";
|
||||||
else if (songPos >= metronomeBeat)
|
metronomeAnim.DoScaledAnimation("MetronomeGo" + currentMetronomeDir, metronomeBeat, 1, clamp: true, ignoreSwing: false);
|
||||||
{
|
|
||||||
metronomeAnim.DoScaledAnimation("MetronomeGo" + currentMetronomeDir, metronomeBeat, 1, ignoreSwing: false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,7 +291,8 @@ namespace HeavenStudio.Games
|
||||||
public static void PrePrepare(double beat, float length, bool mrDownbeat)
|
public static void PrePrepare(double beat, float length, bool mrDownbeat)
|
||||||
{
|
{
|
||||||
bool isGame = GameManager.instance.currentGame == "mrUpbeat";
|
bool isGame = GameManager.instance.currentGame == "mrUpbeat";
|
||||||
if (!mrDownbeat) {
|
if (!mrDownbeat)
|
||||||
|
{
|
||||||
beat = Mathf.Floor((float)beat) + 0.5;
|
beat = Mathf.Floor((float)beat) + 0.5;
|
||||||
length = Mathf.Round(length);
|
length = Mathf.Round(length);
|
||||||
}
|
}
|
||||||
|
@ -299,12 +309,12 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
private void RecursiveStepping(double beat)
|
private void RecursiveStepping(double beat)
|
||||||
{
|
{
|
||||||
if (stopStepping) {
|
if (stopStepping)
|
||||||
|
{
|
||||||
stopStepping = false;
|
stopStepping = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentMetronomeDir = (stepIterate % 2 == 1) ? "Right" : "Left";
|
SoundByte.PlayOneShotGame($"mrUpbeat/metronome{((stepIterate % 2 == 1) ? "Right" : "Left")}");
|
||||||
SoundByte.PlayOneShotGame($"mrUpbeat/metronome{currentMetronomeDir}");
|
|
||||||
metronomeBeat = beat;
|
metronomeBeat = beat;
|
||||||
ScheduleStep(beat);
|
ScheduleStep(beat);
|
||||||
BeatAction.New(this, new List<BeatAction.Action>() {
|
BeatAction.New(this, new List<BeatAction.Action>() {
|
||||||
|
@ -319,9 +329,9 @@ namespace HeavenStudio.Games
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
ScheduleStep(beat + i);
|
ScheduleStep(beat + i);
|
||||||
actions.Add(new BeatAction.Action(beat + i, delegate {
|
actions.Add(new BeatAction.Action(beat + i, delegate
|
||||||
currentMetronomeDir = (stepIterate % 2 == 1) ? "Right" : "Left";
|
{
|
||||||
SoundByte.PlayOneShotGame($"mrUpbeat/metronome{currentMetronomeDir}");
|
SoundByte.PlayOneShotGame($"mrUpbeat/metronome{((stepIterate % 2 == 1) ? "Right" : "Left")}");
|
||||||
metronomeBeat = beat + i;
|
metronomeBeat = beat + i;
|
||||||
stepIterate++;
|
stepIterate++;
|
||||||
}));
|
}));
|
||||||
|
@ -335,7 +345,8 @@ namespace HeavenStudio.Games
|
||||||
if (gameSwitch.beat <= beat || gameSwitch.beat >= beat + length + 1) return;
|
if (gameSwitch.beat <= beat || gameSwitch.beat >= beat + length + 1) return;
|
||||||
|
|
||||||
List<MultiSound.Sound> inactiveBlips = new();
|
List<MultiSound.Sound> inactiveBlips = new();
|
||||||
for (int i = 0; i < gameSwitch.beat - beat; i++) {
|
for (int i = 0; i < gameSwitch.beat - beat; i++)
|
||||||
|
{
|
||||||
inactiveBlips.Add(new MultiSound.Sound("mrUpbeat/blip", beat + i));
|
inactiveBlips.Add(new MultiSound.Sound("mrUpbeat/blip", beat + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +373,8 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
blipMaterial.SetColor("_ColorBravo", blipColor);
|
blipMaterial.SetColor("_ColorBravo", blipColor);
|
||||||
|
|
||||||
if (setShadow) foreach (var shadow in shadowSr) {
|
if (setShadow) foreach (var shadow in shadowSr)
|
||||||
|
{
|
||||||
shadow.color = new Color(shadowColor.r, shadowColor.g, shadowColor.b, 1);
|
shadow.color = new Color(shadowColor.r, shadowColor.g, shadowColor.b, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,8 +396,9 @@ namespace HeavenStudio.Games
|
||||||
public static void CountIn(double beat, float length, bool a)
|
public static void CountIn(double beat, float length, bool a)
|
||||||
{
|
{
|
||||||
var sound = new List<MultiSound.Sound>();
|
var sound = new List<MultiSound.Sound>();
|
||||||
if (a) sound.Add(new MultiSound.Sound("mrUpbeat/a", beat - (0.5f * (length/4))));
|
if (a) sound.Add(new MultiSound.Sound("mrUpbeat/a", beat - (0.5f * (length / 4))));
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
sound.Add(new MultiSound.Sound("mrUpbeat/" + (i + 1), beat + (i * (length / 4)), offset: (i == 3) ? 0.05 : 0));
|
sound.Add(new MultiSound.Sound("mrUpbeat/" + (i + 1), beat + (i * (length / 4)), offset: (i == 3) ? 0.05 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace HeavenStudio.Games
|
||||||
}
|
}
|
||||||
if (Conductor.instance.isPlaying)
|
if (Conductor.instance.isPlaying)
|
||||||
{
|
{
|
||||||
Conductor.instance.SetMinigamePitch(1f, true);
|
Conductor.instance.SetMinigamePitch(1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,8 +395,10 @@ namespace HeavenStudio
|
||||||
|
|
||||||
public bool usesAssetBundle => wantAssetBundle is not null or "";
|
public bool usesAssetBundle => wantAssetBundle is not null or "";
|
||||||
public bool hasLocales => supportedLocales.Count > 0;
|
public bool hasLocales => supportedLocales.Count > 0;
|
||||||
public bool AssetsLoaded => ((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded && loadComplete;
|
public bool AssetsLoaded => ((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded && (!loadingPrefab) && loadComplete;
|
||||||
public bool AlreadyLoading => alreadyLoading;
|
public bool AlreadyLoading => alreadyLoading;
|
||||||
|
public bool LoadingPrefab => loadingPrefab;
|
||||||
|
|
||||||
public bool SequencesPreloaded => soundSequences != null;
|
public bool SequencesPreloaded => soundSequences != null;
|
||||||
public string LoadableName => inferred ? "noGame" : name;
|
public string LoadableName => inferred ? "noGame" : name;
|
||||||
public GameObject LoadedPrefab => loadedPrefab;
|
public GameObject LoadedPrefab => loadedPrefab;
|
||||||
|
@ -410,6 +412,7 @@ namespace HeavenStudio
|
||||||
private bool localePreloaded = false;
|
private bool localePreloaded = false;
|
||||||
private GameObject loadedPrefab = null;
|
private GameObject loadedPrefab = null;
|
||||||
|
|
||||||
|
bool loadingPrefab = false;
|
||||||
bool loadComplete = false;
|
bool loadComplete = false;
|
||||||
|
|
||||||
private SoundSequence.SequenceKeyValue[] soundSequences = null;
|
private SoundSequence.SequenceKeyValue[] soundSequences = null;
|
||||||
|
@ -510,6 +513,7 @@ namespace HeavenStudio
|
||||||
if (alreadyLoading || AssetsLoaded || !usesAssetBundle) return;
|
if (alreadyLoading || AssetsLoaded || !usesAssetBundle) return;
|
||||||
loadComplete = false;
|
loadComplete = false;
|
||||||
alreadyLoading = true;
|
alreadyLoading = true;
|
||||||
|
loadingPrefab = true;
|
||||||
await UniTask.WhenAll(LoadCommonAssetBundleAsync(), LoadLocalizedAssetBundleAsync());
|
await UniTask.WhenAll(LoadCommonAssetBundleAsync(), LoadLocalizedAssetBundleAsync());
|
||||||
await UniTask.WhenAll(LoadGamePrefabAsync(), LoadCommonAudioClips(), LoadLocalizedAudioClips());
|
await UniTask.WhenAll(LoadGamePrefabAsync(), LoadCommonAudioClips(), LoadLocalizedAudioClips());
|
||||||
SoundByte.PreloadGameAudioClips(this);
|
SoundByte.PreloadGameAudioClips(this);
|
||||||
|
@ -585,6 +589,7 @@ namespace HeavenStudio
|
||||||
soundSequences = minigame.SoundSequences;
|
soundSequences = minigame.SoundSequences;
|
||||||
}
|
}
|
||||||
loadedPrefab = prefab;
|
loadedPrefab = prefab;
|
||||||
|
loadingPrefab = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject LoadGamePrefab()
|
public GameObject LoadGamePrefab()
|
||||||
|
@ -636,6 +641,7 @@ namespace HeavenStudio
|
||||||
}
|
}
|
||||||
SoundByte.UnloadAudioClips(name);
|
SoundByte.UnloadAudioClips(name);
|
||||||
loadComplete = false;
|
loadComplete = false;
|
||||||
|
loadingPrefab = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,8 @@ namespace HeavenStudio.Common
|
||||||
{
|
{
|
||||||
case Rating.OK:
|
case Rating.OK:
|
||||||
it = OK;
|
it = OK;
|
||||||
|
// makes the explosion smaller with less accurate inputs
|
||||||
|
it.transform.localScale = Vector3.one * (1f - (frac / 2f));
|
||||||
break;
|
break;
|
||||||
case Rating.Just:
|
case Rating.Just:
|
||||||
it = Just;
|
it = Just;
|
||||||
|
@ -165,13 +167,6 @@ namespace HeavenStudio.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// makes the explosion smaller with less accurate inputs
|
|
||||||
if (it == OK)
|
|
||||||
{
|
|
||||||
float okScalar = 1 - (frac / 2);
|
|
||||||
it.transform.localScale = new Vector3(okScalar, okScalar, it.transform.localScale.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
it.transform.position = barTransform.position + new Vector3(0, barTransform.localScale.y * y, 0);
|
it.transform.position = barTransform.position + new Vector3(0, barTransform.localScale.y * y, 0);
|
||||||
it.GetComponent<ParticleSystem>().Play();
|
it.GetComponent<ParticleSystem>().Play();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue