2025-07-21 05:42:20 -04:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
{
|
|
|
|
|
public partial class SkyboxSubsetter : GameElement
|
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
#region [核心组件与天空盒列表] Core Components & Skybox Lists
|
2025-07-21 05:42:20 -04:00
|
|
|
public SkyboxBlender skyboxBlender;
|
|
|
|
|
public List<string> skyBoxThemeBundleList;
|
|
|
|
|
public List<string> skyboxNameList;
|
|
|
|
|
public List<Material> skyboxMaterialList;
|
|
|
|
|
public List<float> blendSpeedList;
|
|
|
|
|
public List<float> blendTimeList;
|
|
|
|
|
public int currentSkyboxIndex = 0;
|
2026-03-14 03:13:10 -04:00
|
|
|
#endregion
|
2025-07-21 05:42:20 -04:00
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
#region [编辑器UI支持] Editor Selection Tools
|
2025-07-21 05:42:20 -04:00
|
|
|
public List<string> themeBundleListForSelection;
|
|
|
|
|
public List<string> skyboxNameListForSelection;
|
|
|
|
|
public string selectedThemeBundle;
|
|
|
|
|
public string selectedSkybox;
|
2026-03-14 03:13:10 -04:00
|
|
|
#endregion
|
2025-07-21 05:42:20 -04:00
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
#region [生命周期] Lifecycle & Factory
|
2025-07-21 05:42:20 -04:00
|
|
|
public static SkyboxSubsetter GenerateElement(string elementName, Guid id, List<string> tags,
|
|
|
|
|
bool isFirstGenerated, GameElement parentElement, List<string> themeBundleList,List<string> skyboxList,
|
|
|
|
|
List<float> blendTimeList, List<float> blendSpeedList)
|
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
SkyboxSubsetter skyboxSubsetter = Instantiate(GameManager.Instance.basePrefabs.emptyObject)
|
2025-07-21 05:42:20 -04:00
|
|
|
.AddComponent<SkyboxSubsetter>();
|
2026-03-14 03:13:10 -04:00
|
|
|
GameManager.Instance.backgroundSetter.skyboxSubsetter = skyboxSubsetter;
|
2025-07-21 05:42:20 -04:00
|
|
|
skyboxSubsetter.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
|
|
|
|
skyboxSubsetter.skyBoxThemeBundleList = themeBundleList;
|
|
|
|
|
skyboxSubsetter.skyboxNameList = skyboxList;
|
|
|
|
|
skyboxSubsetter.skyboxMaterialList = new List<Material>();
|
|
|
|
|
skyboxSubsetter.blendTimeList = blendTimeList;
|
|
|
|
|
skyboxSubsetter.blendSpeedList = blendSpeedList;
|
|
|
|
|
skyboxSubsetter.SetUpBlender();
|
|
|
|
|
skyboxSubsetter.themeBundleListForSelection = ThemeBundleManager.instance.loadedThemeBundleList.ConvertAll(x => x.themeBundleName);
|
|
|
|
|
skyboxSubsetter.skyboxNameListForSelection = new List<string>();
|
|
|
|
|
skyboxSubsetter.selectedThemeBundle = String.Empty;
|
|
|
|
|
skyboxSubsetter.selectedSkybox = String.Empty;
|
|
|
|
|
return skyboxSubsetter;
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
#endregion
|
2025-07-21 05:42:20 -04:00
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
#region [内部设置与工具] Internal Configs & Utils
|
2025-07-21 05:42:20 -04:00
|
|
|
private void SetUpBlender()
|
|
|
|
|
{
|
|
|
|
|
skyboxBlender = gameObject.AddComponent<SkyboxBlender>();
|
|
|
|
|
skyboxBlender.loop = false;
|
|
|
|
|
skyboxBlender.timeToWait = 0f;
|
|
|
|
|
skyboxBlender.updateLighting = false;
|
|
|
|
|
skyboxBlender.updateReflections = false;
|
|
|
|
|
skyboxBlender.skyboxMaterials = new List<Material>();
|
|
|
|
|
for (int i = 0; i < skyBoxThemeBundleList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Material skybox = ThemeBundleManager.instance.GetObject<Material>(skyBoxThemeBundleList[i], skyboxNameList[i]);
|
|
|
|
|
skyboxMaterialList.Add(skybox);
|
|
|
|
|
skyboxBlender.skyboxMaterials.Add(skybox);
|
|
|
|
|
}
|
|
|
|
|
skyboxBlender.makeFirstMaterialSkybox = true;
|
|
|
|
|
skyboxBlender.InspectorAndAwakeChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddSkybox(string skyboxThemeBundleName, string skyboxObjectName)
|
|
|
|
|
{
|
|
|
|
|
Material skybox = ThemeBundleManager.instance.GetObject<Material>(skyboxThemeBundleName, skyboxObjectName);
|
|
|
|
|
if (skybox != null)
|
|
|
|
|
{
|
|
|
|
|
skyBoxThemeBundleList.Add(skyboxThemeBundleName);
|
|
|
|
|
skyboxNameList.Add(skyboxObjectName);
|
|
|
|
|
skyboxMaterialList.Add(skybox);
|
|
|
|
|
skyboxBlender.skyboxMaterials.Add(skybox);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
#endregion
|
2025-07-21 05:42:20 -04:00
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
#region [轮询更新] Main Update
|
2025-07-21 05:42:20 -04:00
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (skyBoxThemeBundleList.Count > 1)
|
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
float songTime = CoreServices.TimeProvider.SongTime;
|
|
|
|
|
float delay = GameManager.Instance.songInformation.delay;
|
2025-07-21 05:42:20 -04:00
|
|
|
float finalTime = 32767; // 曲目长度
|
|
|
|
|
|
|
|
|
|
for (var index = 0; index < blendTimeList.Count + 1; index++)
|
|
|
|
|
{
|
|
|
|
|
float startTime = index == 0 ? -delay : blendTimeList[index - 1];
|
|
|
|
|
float endTime = index >= blendTimeList.Count ? finalTime : blendTimeList[index];
|
|
|
|
|
if(songTime >= startTime && songTime < endTime && currentSkyboxIndex != index)
|
|
|
|
|
{
|
|
|
|
|
currentSkyboxIndex = index;
|
|
|
|
|
if(currentSkyboxIndex != 0) skyboxBlender.blendSpeed = blendSpeedList[currentSkyboxIndex - 1];
|
|
|
|
|
skyboxBlender.Blend(currentSkyboxIndex, false);
|
|
|
|
|
DynamicGI.UpdateEnvironment();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
#endregion
|
2025-07-21 05:42:20 -04:00
|
|
|
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
|
2025-07-21 05:42:20 -04:00
|
|
|
}
|