Signed-off-by: TRAfoer <lhf190@outlook.com>

This commit is contained in:
2025-07-10 11:22:04 +08:00
parent 5eb85505e4
commit 66b1b30929
9 changed files with 192 additions and 145 deletions

View File

@@ -16,35 +16,40 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
public GameObject headPoint, headCircle;
public GameObject trailBody;
public bool isHeadEnabled;
public List<Renderer> renderers;
public ParticleSystem headCircleParticle;
public TrailRenderer trailRenderer { get; set; }
public FlexibleFloat visibleTimeLength;
public FlexibleBool enableTimes;
public float enableProcessTime = 0.5f;
public float headSize = 1f;
public FlexibleFloat headRotateSpeed;
float IHaveTrail.visibleTimeLength
{
get => visibleTimeLength.animations.Count > 0 ? visibleTimeLength.value : 5f;
set => visibleTimeLength.value = value;
}
public override bool haveEmissionColor => true;
public static DTMTrail GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
bool isStatic, FlexibleFloat visibleTimeLength, FlexibleBool enableTimes, FlexibleFloat headRotateSpeed, float enableProcessTime,
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
bool isStatic, FlexibleFloat visibleTimeLength, FlexibleBool enableTimes, FlexibleFloat headRotateSpeed, float enableProcessTime,
float headSize)
{
DTMTrail dtmTrail = EnvironmentObject.GenerateElement(elementName, id, tags,
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<DTMTrail>();
dtmTrail.isHeadEnabled = false;
dtmTrail.visibleTimeLength = visibleTimeLength;
dtmTrail.enableTimes = enableTimes;
dtmTrail.headRotateSpeed = headRotateSpeed;
dtmTrail.enableProcessTime = enableProcessTime;
dtmTrail.headSize = headSize;
return dtmTrail;
}
@@ -64,7 +69,7 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
if (parentElement is TrackHeadPoint trackHeadPoint)
{
enableTimes.Add( new AnimatedBool(0f, false));
enableTimes.Add(new AnimatedBool(0f, false));
enableTimes.Add(new AnimatedBool(trackHeadPoint.trackTimeSubmoduleMovable.trackStartTime, true));
enableTimes.Add(new AnimatedBool(trackHeadPoint.trackTimeSubmoduleMovable.trackEndTime, false));
}
@@ -81,14 +86,14 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
rotationBySpeedModule.z = 0;
headPoint.transform.localScale = Vector3.zero;
headCircle.transform.localScale = Vector3.zero;
renderers.ForEach(rend => rend.InitializeShader());
}
public override void Refresh()
{
base.Refresh();
renderers.ForEach(rend =>
{
if (colorSubmodule.emissionEnabled)
@@ -100,13 +105,13 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
{
rend.material.DisableKeyword("_EMISSION_ON");
}
rend.material.EnableKeyword("_USEREDASALPHA_ON");
Debug.Log(rend.material.IsKeywordEnabled("_EMISSION_ON") + " " + rend.material.IsKeywordEnabled("_USEREDASALPHA_ON"));
rend.material.SetColor("_BaseColor", colorSubmodule.currentBaseColor);
rend.material.SetColor("_EmissionColor", colorSubmodule.GetCurrentEmissionColor());
rend.material.SetColor("_EmissionColor", colorSubmodule.GetCurrentEmissionColor());
});
}
@@ -114,24 +119,25 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
{
float songTime = EditorManager.instance.songInformation.songTime;
enableTimes.UpdateFlexibleBool(songTime);
if(enableTimes.value && !isHeadEnabled)
if (enableTimes.value && !isHeadEnabled)
{
EnableHead();
isHeadEnabled = true;
}
else if(!enableTimes.value && isHeadEnabled)
else if (!enableTimes.value && isHeadEnabled)
{
DisableHead();
isHeadEnabled = false;
}
visibleTimeLength.UpdateFlexibleFloat(songTime);
if (visibleTimeLength.animations.Count > 0)
if (visibleTimeLength.animations.Count > 0 && EditorManager.instance.musicPlayer.isPlaying)//为的是接口里头那个用来set的
{
Debug.Log(trailRenderer == null);
// Debug.Log(trailRenderer == null);
print($"TrailRenderer time set to {visibleTimeLength.value}");
trailRenderer.time = visibleTimeLength.value;
}
if (isHeadEnabled && headRotateSpeed.animations.Count > 0)
{
headRotateSpeed.UpdateFlexibleFloat(songTime);
@@ -154,27 +160,27 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
{
enableHeadSequence.PlayBackwards();
}
private Sequence enableHeadSequence;
private Sequence disableHeadSequence;
private Sequence headBounceSequence;
public void SetUpTweeners()
{
enableHeadSequence?.Kill(true);
disableHeadSequence?.Kill(true);
headBounceSequence?.Kill(true);
enableHeadSequence = DOTween.Sequence();
enableHeadSequence.Append(headPoint.transform.DOScale(headSize, enableProcessTime).SetEase(Ease.OutQuad));
enableHeadSequence.Join(headCircle.transform.DOScale(headSize, enableProcessTime).SetEase(Ease.OutQuad));
enableHeadSequence.SetAutoKill(false);
disableHeadSequence = DOTween.Sequence();
disableHeadSequence.Append(headPoint.transform.DOScale(0, enableProcessTime).SetEase(Ease.OutQuad));
disableHeadSequence.Join(headCircle.transform.DOScale(0, enableProcessTime).SetEase(Ease.OutQuad));
disableHeadSequence.SetAutoKill(false);
headBounceSequence = DOTween.Sequence();
headBounceSequence.Append(headPoint.transform.DOBlendableScaleBy(Vector3.one * 0.2f, 0.2f).SetEase(Ease.OutBack));
headBounceSequence.Join(headCircle.transform.DOBlendableScaleBy(Vector3.one * 0.2f, 0.2f).SetEase(Ease.OutBack));
@@ -188,7 +194,7 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
headBounceSequence.Restart();
}
}
public partial class DTMTrail
{
public override void SaveBM()
@@ -204,21 +210,21 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("DTMTrail");
var subcontainer = container.GenerateSubcontainer(3);
var visibleTimeLengthButton = inspector.GenerateButton(this, subcontainer, "Visible Time Length", () =>
{
var ew = inspector.GenerateCompositeParameterWindow(
this, "Visible Time Length", nameof(visibleTimeLength));
ew.SetAsFlexibleFloat();
});
var enableTimeListButton = inspector.GenerateButton(this, subcontainer, "Enable Head Time List", () =>
{
var ew = inspector.GenerateCompositeParameterWindow(
this, "Enable Head Time List", nameof(enableTimes));
ew.SetAsFlexibleBool();
});
var headRotateSpeedButton = inspector.GenerateButton(this, subcontainer, "Head Rotate Speed", () =>
{
var ew = inspector.GenerateCompositeParameterWindow(
@@ -229,14 +235,14 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
var enableProcessTimeInputField =
inspector.GenerateInputField(this, subcontainer, "Enable Process Time", nameof(enableProcessTime))
.AddListenerFunction(SetUpTweeners);
var headSizeInputField =
var headSizeInputField =
inspector.GenerateInputField(this, subcontainer, "Head Size", nameof(headSize))
.AddListenerFunction(SetUpTweeners);
}
}
namespace Beatmap
{
public partial class DTMTrail_BM : EnvironmentObject_BM
@@ -245,17 +251,17 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
public FlexibleBool_BM enableTimes;
public float enableProcessTime = 0.5f;
public float headSize = 1f;
public FlexibleFloat_BM headRotateSpeed;
public DTMTrail_BM()
{
}
public DTMTrail_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM parentElement,
string themeBundleName, string objectName, bool isStatic, FlexibleFloat visibleTimeLength,
FlexibleBool enableTimes, FlexibleFloat headRotateSpeed, float enableProcessTime, float headSize):
FlexibleBool enableTimes, FlexibleFloat headRotateSpeed, float enableProcessTime, float headSize) :
base(elementName, elementGuid, tags, parentElement, themeBundleName, objectName, isStatic)
{
this.visibleTimeLength = visibleTimeLength.ConvertToBM();
@@ -268,14 +274,14 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
public override void ExecuteBM()
{
matchedElement = DTMTrail.GenerateElement(elementName, elementGuid, tags, false,
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic, visibleTimeLength?.ConvertToGameType(),
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic, visibleTimeLength?.ConvertToGameType(),
enableTimes.ConvertToGameType(), headRotateSpeed?.ConvertToGameType(), enableProcessTime, headSize);
}
public override GameElement DuplicateBM(GameElement parent)
{
return DTMTrail.GenerateElement(elementName, Guid.NewGuid(), tags, false,
themeBundleName, objectName, parent, isStatic, visibleTimeLength?.ConvertToGameType(), enableTimes.ConvertToGameType(),
themeBundleName, objectName, parent, isStatic, visibleTimeLength?.ConvertToGameType(), enableTimes.ConvertToGameType(),
headRotateSpeed?.ConvertToGameType(), enableProcessTime, headSize);
}
}