This commit is contained in:
SoulliesOfficial
2026-03-31 07:51:40 -04:00
parent e7d717aad5
commit 25b6da25ae
2054 changed files with 6065 additions and 32945 deletions

View File

@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame.ThemeBundles.Basic
{
/// <summary>
/// 自定义 2D 形状环境物体,支持从 AssetBundle 动态加载 Sprite
/// 并通过 ColorSubmodule 同步颜色。接入了 DirtyMark 集中刷新机制。
/// </summary>
public class Custom2DShape : EnvironmentObject
{
#region [] Exposed Fields
public string spriteName = "None";
public SpriteRenderer spriteRenderer;
#endregion
#region [] Lifecycle & Factory
public static Custom2DShape GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
bool isStatic, string spriteName)
{
// 通过 EnvironmentObject.GenerateElement 创建 GameObject 并获取组件
Custom2DShape obj = EnvironmentObject.GenerateElement(elementName, id, tags,
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<Custom2DShape>();
obj.spriteName = spriteName;
return obj;
}
public override void FirstSetUpObject(bool isFirstGenerated)
{
if (spriteRenderer == null)
spriteRenderer = GetComponentInChildren<SpriteRenderer>();
UpdateSprite();
Refresh();
}
// 响应由 PropertyAnimation 触发的延迟刷新
public override void OnDirtyRefresh(Dictionary<string, bool> flags)
{
Refresh();
}
#endregion
#region [] Core Effect Logic
/// <summary>
/// 从当前 ThemeBundle 获取 Sprite 资源
/// </summary>
public void UpdateSprite()
{
if (spriteRenderer != null && !string.IsNullOrEmpty(spriteName) && spriteName != "None")
{
// 通过 ThemeBundleManager 获取 Sprite
Sprite sp = ThemeBundleManager.instance.GetObject<Sprite>(themeBundleName, spriteName);
if (sp != null)
{
spriteRenderer.sprite = sp;
}
else
{
Debug.LogWarning($"[Custom2DShape] 无法在包 '{themeBundleName}' 中找到 Sprite: {spriteName}");
}
}
}
public override void Refresh()
{
// 同步 ColorSubmodule 的颜色状态
base.Refresh();
if (spriteRenderer != null)
{
spriteRenderer.color = colorSubmodule.currentBaseColor;
}
}
#endregion
#region [] Inherited Logic overrides
// 如果有特定的子物体需要刷新逻辑,可在此重载
#endregion
}
namespace Beatmap
{
[System.Serializable]
public class Custom2DShape_BM : EnvironmentObject_BM
{
public string spriteName = "None";
public Custom2DShape_BM() { }
public Custom2DShape_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM parentElement,
string themeBundleName, string objectName, bool isStatic, string spriteName)
: base(elementName, elementGuid, tags, parentElement, themeBundleName, objectName, isStatic)
{
this.spriteName = spriteName;
}
public override void ExecuteBM()
{
matchedElement = Custom2DShape.GenerateElement(elementName, elementGuid, tags, false,
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic, spriteName);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: da3b1e646ff0d1f4f9fe88d5fd6b244f