This commit is contained in:
SoulliesOfficial
2026-01-21 00:31:23 -05:00
parent 66a1701087
commit 4fe6ee5f99
70 changed files with 1595 additions and 687 deletions

View File

@@ -0,0 +1,90 @@
using System;
using UnityEngine;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
using System.Collections.Generic;
using Beatmap;
namespace Ichni.RhythmGame
{
// 以EnvironmentObject为基底支持伪阴影shader参数刷新
public class BasicEnvironmentObject : EnvironmentObject
{
[Header("Pseudo Shadow Settings")]
public Renderer shadowRenderer; // 指向带有伪阴影shader的Renderer
[Range(-1, 1)] public float shadowThreshold = 0.2f;
[Range(0, 1)] public float shadowSmoothness = 0.5f;
public bool useWorldLight = false;
public Vector3 fakeLightDir = new Vector3(0.5f, 1, 0.5f);
public override bool haveEmission => true;
public static BasicEnvironmentObject GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
bool isStatic,
float shadowThreshold, float shadowSmoothness, bool useWorldLight, Vector3 fakeLightDir)
{
BasicEnvironmentObject basicEnvObj = EnvironmentObject.GenerateElement(elementName, id, tags,
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<BasicEnvironmentObject>();
basicEnvObj.shadowThreshold = shadowThreshold;
basicEnvObj.shadowSmoothness = shadowSmoothness;
basicEnvObj.useWorldLight = useWorldLight;
basicEnvObj.fakeLightDir = fakeLightDir;
return basicEnvObj;
}
public override void Refresh()
{
base.Refresh();
if (shadowRenderer == null || shadowRenderer.material == null) return;
var mat = shadowRenderer.material;
mat.SetColor("_Color", colorSubmodule.currentBaseColor);
mat.SetColor("_ShadowColor", colorSubmodule.currentEmissionColor);
mat.SetFloat("_ShadowThreshold", shadowThreshold);
mat.SetFloat("_ShadowSmoothness", shadowSmoothness);
mat.SetVector("_FakeLightDir", new Vector4(fakeLightDir.x, fakeLightDir.y, fakeLightDir.z, 0));
mat.SetFloat("_UseWorldLight", useWorldLight ? 1 : 0);
}
public override void SaveBM()
{
base.SaveBM();
matchedBM = new BasicEnvironmentObject_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
themeBundleName, objectName, isStatic,
shadowThreshold, shadowSmoothness, useWorldLight, fakeLightDir);
}
}
}
namespace Beatmap
{
public class BasicEnvironmentObject_BM : EnvironmentObject_BM
{
public float shadowThreshold;
public float shadowSmoothness;
public bool useWorldLight;
public Vector3 fakeLightDir;
public BasicEnvironmentObject_BM() { }
public BasicEnvironmentObject_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM parentElement,
string themeBundleName, string objectName, bool isStatic,
float shadowThreshold, float shadowSmoothness, bool useWorldLight, Vector3 fakeLightDir)
: base(elementName, elementGuid, tags, parentElement, themeBundleName, objectName, isStatic)
{
this.shadowThreshold = shadowThreshold;
this.shadowSmoothness = shadowSmoothness;
this.useWorldLight = useWorldLight;
this.fakeLightDir = fakeLightDir;
}
public override void ExecuteBM()
{
matchedElement = BasicEnvironmentObject.GenerateElement(elementName, elementGuid, tags, false,
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic,
shadowThreshold, shadowSmoothness, useWorldLight, fakeLightDir);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 23b337068935c374fbb29aae9e944d7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: