105 lines
3.8 KiB
C#
105 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Ichni.RhythmGame.Beatmap;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
|
{
|
|
public class DTMFramesFloor : EnvironmentObject
|
|
{
|
|
#region [暴露属性字段] Exposed Fields
|
|
public float patternSizeX;
|
|
public float patternSizeY;
|
|
public float gridDensity;
|
|
public float timeAngle;
|
|
public float stepA;
|
|
public float stepB;
|
|
|
|
public bool enableOuterBorder;
|
|
public Color outerBorderColor;
|
|
public float outerBorderWidth;
|
|
|
|
public Renderer meshRenderer;
|
|
#endregion
|
|
|
|
#region [生命周期与工厂] Lifecycle & Factory
|
|
public static DTMFramesFloor GenerateElement(string elementName, Guid id, List<string> tags,
|
|
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
|
|
bool isStatic,
|
|
float patternSizeX, float patternSizeY, float gridDensity,
|
|
float timeAngle, float stepA, float stepB,
|
|
bool enableOuterBorder,
|
|
Color outerBorderColor,
|
|
float outerBorderWidth)
|
|
{
|
|
DTMFramesFloor framesFloor = EnvironmentObject.GenerateElement(elementName, id, tags,
|
|
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<DTMFramesFloor>();
|
|
|
|
framesFloor.patternSizeX = patternSizeX;
|
|
framesFloor.patternSizeY = patternSizeY;
|
|
framesFloor.gridDensity = gridDensity;
|
|
framesFloor.timeAngle = timeAngle;
|
|
framesFloor.stepA = stepA;
|
|
framesFloor.stepB = stepB;
|
|
|
|
framesFloor.enableOuterBorder = enableOuterBorder;
|
|
framesFloor.outerBorderColor = outerBorderColor;
|
|
framesFloor.outerBorderWidth = outerBorderWidth;
|
|
|
|
return framesFloor;
|
|
}
|
|
|
|
public override void FirstSetUpObject(bool isFirstGenerated)
|
|
{
|
|
if (meshRenderer == null)
|
|
meshRenderer = GetComponentInChildren<Renderer>();
|
|
|
|
meshRenderer.InitializeShader(); // 实例化材质 / Instantiate material
|
|
UpdateMaterialProperties();
|
|
}
|
|
#endregion
|
|
|
|
#region [效果核心逻辑] Core Effect Logic
|
|
public void UpdateMaterialProperties()
|
|
{
|
|
if (meshRenderer != null && meshRenderer.material != null)
|
|
{
|
|
Material mat = meshRenderer.material;
|
|
|
|
mat.SetVector("_PatternSize", new Vector4(patternSizeX, patternSizeY, 0, 0));
|
|
mat.SetFloat("_GridDensity", gridDensity);
|
|
mat.SetFloat("_TimeAngle", timeAngle);
|
|
mat.SetFloat("_StepA", stepA);
|
|
mat.SetFloat("_StepB", stepB);
|
|
|
|
float borderOn = enableOuterBorder ? 1f : 0f;
|
|
mat.SetFloat("_EnableOuterBorder", borderOn);
|
|
if (enableOuterBorder)
|
|
{
|
|
mat.EnableKeyword("_OUTER_BORDER_ON");
|
|
}
|
|
else
|
|
{
|
|
mat.DisableKeyword("_OUTER_BORDER_ON");
|
|
}
|
|
|
|
mat.SetColor("_OuterBorderColor", outerBorderColor);
|
|
mat.SetFloat("_OuterBorderWidth", outerBorderWidth);
|
|
|
|
// Base Color and Alpha Sync (Unity Color -> HDR)
|
|
mat.SetColor("_Color0", colorSubmodule.currentBaseColor);
|
|
}
|
|
}
|
|
|
|
public override void Refresh()
|
|
{
|
|
base.Refresh();
|
|
// Sync environment color changes
|
|
if (meshRenderer != null)
|
|
{
|
|
meshRenderer.material.SetColor("_Color0", colorSubmodule.currentBaseColor);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |