改,加,TrackGlobalColorChange

Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2025-10-01 20:41:06 +08:00
parent 25a458dd8c
commit b29654e423
37 changed files with 630986 additions and 21442 deletions

View File

@@ -0,0 +1,179 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class TrackGlobalColorChange : AnimationBase
{
public FlexibleFloat colorR, colorG, colorB, colorA;
public static TrackGlobalColorChange GenerateElement(string elementName, System.Guid id,
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
FlexibleFloat colorR, FlexibleFloat colorG, FlexibleFloat colorB, FlexibleFloat colorA)
{
if (animatedObject is not Track)
{
Debug.LogError("Animated Object is Not Track");
throw new System.ArgumentException("Animated Object is Not Track");
}
TrackGlobalColorChange trackGlobalColorChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
.AddComponent<TrackGlobalColorChange>();
trackGlobalColorChange.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
trackGlobalColorChange.animatedObject = animatedObject;
trackGlobalColorChange.colorR = colorR;
trackGlobalColorChange.colorG = colorG;
trackGlobalColorChange.colorB = colorB;
trackGlobalColorChange.colorA = colorA;
trackGlobalColorChange.animationReturnType = FlexibleReturnType.Before;
//trackGlobalColorChange.timeDurationSubmodule.SetDuration(colorR, colorG, colorB, colorA);
return trackGlobalColorChange;
}
public override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
}
protected override void UpdateAnimation(float songTime)
{
colorR.UpdateFlexibleFloat(songTime);
colorG.UpdateFlexibleFloat(songTime);
colorB.UpdateFlexibleFloat(songTime);
colorA.UpdateFlexibleFloat(songTime);
if (colorR.returnType is FlexibleReturnType.MiddleExecuting ||
colorG.returnType is FlexibleReturnType.MiddleExecuting ||
colorB.returnType is FlexibleReturnType.MiddleExecuting ||
colorA.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Color color = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = color;
}
else if (colorR.isSwitchingReturnType || colorG.isSwitchingReturnType || colorB.isSwitchingReturnType || colorA.isSwitchingReturnType)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Color color = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = color;
}
else
{
if (!EditorManager.instance.musicPlayer.isPlaying && animationReturnType != FlexibleReturnType.MiddleInterval)
{
Color color = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = color;
animationReturnType = FlexibleReturnType.After;
}
else
{
animationReturnType = FlexibleReturnType.Before;
}
}
}
public override void ApplyTimeOffset(float offset)
{
base.ApplyTimeOffset(offset);
foreach (var item in colorR.animations) item.ApplyTimeOffset(offset);
foreach (var item in colorG.animations) item.ApplyTimeOffset(offset);
foreach (var item in colorB.animations) item.ApplyTimeOffset(offset);
foreach (var item in colorA.animations) item.ApplyTimeOffset(offset);
}
public override Vector3 getValue(float time)
{
float r = colorR.GetValue(time);
float g = colorG.GetValue(time);
float b = colorB.GetValue(time);
float a = colorA.GetValue(time);
return new Vector3(r, g, b);
}
public override void Refresh()
{
base.Refresh();
if (colorR.animations.Count == 0 && colorG.animations.Count == 0 && colorB.animations.Count == 0 && colorA.animations.Count == 0)
{
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = Color.white;
}
else
{
UpdateAnimation(EditorManager.instance.songInformation.songTime);
}
}
public override void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
base.SetUpInspector();
var container = inspector.GenerateContainer("Track Global Color Change");
var subcontainer = container.GenerateSubcontainer(3);
var colorRButton = inspector.GenerateButton(this, subcontainer, "Color R", () =>
{
inspector.GenerateCompositeParameterWindow(this, "Color R", nameof(colorR)).SetAsFlexibleFloat();
});
var colorGButton = inspector.GenerateButton(this, subcontainer, "Color G", () =>
{
inspector.GenerateCompositeParameterWindow(this, "Color G", nameof(colorG)).SetAsFlexibleFloat();
});
var colorBButton = inspector.GenerateButton(this, subcontainer, "Color B", () =>
{
inspector.GenerateCompositeParameterWindow(this, "Color B", nameof(colorB)).SetAsFlexibleFloat();
});
var colorAButton = inspector.GenerateButton(this, subcontainer, "Color A", () =>
{
inspector.GenerateCompositeParameterWindow(this, "Color A", nameof(colorA)).SetAsFlexibleFloat();
});
var graphicEditor = inspector.GenerateButton(this, subcontainer, "GraphicEditor", () =>
{
inspector.GenerateGraphicalFlexibleFloatWindow(this, "Track Global Color Change",
new FlexibleFloat[] { colorR, colorG, colorB, colorA }, new string[] { "ColorR", "ColorG", "ColorB", "ColorA" });
});
}
public override void SaveBM()
{
matchedBM = new Beatmap.TrackGlobalColorChange_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
colorR.ConvertToBM(), colorG.ConvertToBM(), colorB.ConvertToBM(), colorA.ConvertToBM());
}
}
}
namespace Ichni.RhythmGame.Beatmap
{
public class TrackGlobalColorChange_BM : AnimationBase_BM
{
public FlexibleFloat_BM colorR, colorG, colorB, colorA;
public TrackGlobalColorChange_BM()
{
}
public TrackGlobalColorChange_BM(string elementName, Guid elementGuid, List<string> tags,
GameElement_BM attachedElement, FlexibleFloat_BM colorR, FlexibleFloat_BM colorG, FlexibleFloat_BM colorB, FlexibleFloat_BM colorA)
: base(elementName, elementGuid, tags, attachedElement)
{
this.colorR = colorR;
this.colorG = colorG;
this.colorB = colorB;
this.colorA = colorA;
}
public override GameElement DuplicateBM(GameElement attached)
{
return TrackGlobalColorChange.GenerateElement(elementName, Guid.NewGuid(), tags, true, attached,
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(), colorA.ConvertToGameType());
}
public override void ExecuteBM()
{
matchedElement = TrackGlobalColorChange.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(), colorA.ConvertToGameType());
}
}
}

View File

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

View File

@@ -188,6 +188,9 @@ namespace Ichni.RhythmGame
}); //Particle Tracker
StandardInspectionElement.GenerateForTransform(this, generateContainer); //关于有Transform的元素
inspector.GenerateButton(this, particleSubcontainer, "Track Global Color Change",
() => { TrackGlobalColorChange.GenerateElement("New Track Global Color Change", Guid.NewGuid(), new List<string>(), true, this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()); }); //变量容器
// var animationSubcontainer = generateContainer.GenerateSubcontainer(3);
// var displacementButton = inspector.GenerateButton(this, animationSubcontainer, "Displacement", () =>
// {