Files
ichni_Official/Assets/Scripts/Manager/ProjectLoader.cs
SoulliesOfficial 150ef744e8 更新
2025-07-08 14:28:40 -04:00

104 lines
3.8 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Sirenix.OdinInspector;
using UniRx;
using UnityEngine;
namespace Ichni
{
public class ProjectLoader
{
public float loadPercent;
public static readonly ES3Settings SaveSettings = new ES3Settings
{
compressionType = ES3.CompressionType.None,
encryptionType = ES3.EncryptionType.None,
format = ES3.Format.JSON,
location = ES3.Location.Resources
};
private static readonly ES3Settings LoadSettings = new ES3Settings
{
compressionType = ES3.CompressionType.Gzip,
encryptionType = ES3.EncryptionType.AES,
encryptionPassword = "Soullies515",
format = ES3.Format.JSON,
location = ES3.Location.Resources
};
[Button("TestLoad")]
public void TestLoad()
{
ThemeBundleManager.instance.LoadThemeBundles(new List<string>(){"departure_to_multiverse"});
loadPercent = 0f;
Observable.EveryUpdate()
.Where(_ => ThemeBundleManager.instance.waitingBundleAmount.Value == 0)
.First()
.Subscribe(_ =>
{
Load(InformationTransistor.instance.chapterName,
InformationTransistor.instance.songName,
InformationTransistor.instance.difficultyName);
});
Observable.EveryUpdate()
.Where(_ => ThemeBundleManager.instance.waitingBundleAmount.Value == 0 &&
(GameManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM).remainingElementAmount.Value == 0)
.First()
.Subscribe(_ =>
{
Observable.Timer(TimeSpan.FromSeconds(2)).First().Subscribe(_ =>
{
GameManager.instance.audioManager.isStarting = false;
});
});
Observable.EveryUpdate()
.Where(_ => !GameManager.instance.audioManager.isStarting)
.First()
.Subscribe(_ =>
{
GameManager.instance.audioManager.songPlayer.PlaySong();
});
}
public void Load(string chapterName, string musicName, string difficultyName)
{
string beatMapFolderPath = "Beatmaps/" + chapterName + "/" + musicName + "/" + difficultyName;
LoadProjectInfo(beatMapFolderPath);
LoadSongInfo(beatMapFolderPath);
LoadCommandScripts(beatMapFolderPath);
LoadBeatMap(beatMapFolderPath);
}
private void LoadProjectInfo(string beatMapFolderPath)
{
string projectInfoPath = beatMapFolderPath + "/ProjectInfo.bytes";
ES3.Load<ProjectInformation_BM>("ProjectInformation", projectInfoPath, LoadSettings).ExecuteBM();
}
private void LoadSongInfo(string beatMapFolderPath)
{
string songInfoPath = beatMapFolderPath + "/SongInfo.bytes";
ES3.Load<SongInformation_BM>("SongInformation",songInfoPath, LoadSettings).ExecuteBM();
}
private void LoadBeatMap(string beatMapFolderPath)
{
string beatmapPath = beatMapFolderPath + "/Beatmap.bytes";
ES3.Load<BeatmapContainer_BM>("Beatmap", beatmapPath, LoadSettings).ExecuteBM();
}
private void LoadCommandScripts(string beatMapFolderPath)
{
string commandScriptsPath = beatMapFolderPath + "/CommandScripts.bytes";
ES3.Load<CommandScripts_BM>("CommandScripts", commandScriptsPath, LoadSettings).ExecuteBM();
}
}
}