@@ -38,34 +38,35 @@ namespace Ichni.RhythmGame.Beatmap
|
||||
e.SaveBM();
|
||||
e.submoduleList.RemoveAll(s => s == null);
|
||||
e.submoduleList.ForEach(s => s.SaveBM());
|
||||
if (forExport && e is IBeChangeInExport changeInExport)
|
||||
{
|
||||
changeInExport.SaveExportBM();
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var gameElement in gameElementList)
|
||||
{
|
||||
if (gameElement.matchedBM == null) continue;
|
||||
|
||||
if (forExport && gameElement is IBeChangeInExport changeInExport)
|
||||
BaseElement_BM elementToAdd = gameElement.matchedBM;
|
||||
|
||||
// 检查是否有导出替换元素,有则使用替代元素
|
||||
if (forExport && gameElement is IExportOverride exportOverride)
|
||||
{
|
||||
if (changeInExport.MatchingExportElement != null)
|
||||
BaseElement_BM exportElement = exportOverride.GetExportElement();
|
||||
if (exportElement != null)
|
||||
{
|
||||
elementList.Add(changeInExport.MatchingExportElement);
|
||||
List<BaseElement_BM> submodules = gameElement.submoduleList.ConvertAll(s => s.matchedBM);
|
||||
submodules.RemoveAll(s => s == null);
|
||||
submodules.ForEach(e => { e.attachedElementGuid = ((GameElement_BM)changeInExport.MatchingExportElement).elementGuid; });
|
||||
elementList.AddRange(submodules);
|
||||
elementToAdd = exportElement;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
elementList.Add(elementToAdd);
|
||||
List<BaseElement_BM> submodules = gameElement.submoduleList.ConvertAll(s => s.matchedBM);
|
||||
submodules.RemoveAll(s => s == null);
|
||||
|
||||
// 当使用了替代元素时,将其 Guid 附给子模块
|
||||
if (elementToAdd != gameElement.matchedBM)
|
||||
{
|
||||
elementList.Add(gameElement.matchedBM);
|
||||
List<BaseElement_BM> submodules = gameElement.submoduleList.ConvertAll(s => s.matchedBM);
|
||||
submodules.RemoveAll(s => s == null);
|
||||
elementList.AddRange(submodules);
|
||||
submodules.ForEach(s => { s.attachedElementGuid = ((GameElement_BM)elementToAdd).elementGuid; });
|
||||
}
|
||||
|
||||
elementList.AddRange(submodules);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -13,27 +13,22 @@ namespace Ichni.RhythmGame
|
||||
Override
|
||||
}
|
||||
|
||||
public abstract class InterferometerBase : GameElement, IHaveTimeDurationSubmodule, IBeChangeInExport
|
||||
public abstract class InterferometerBase : GameElement, IHaveTimeDurationSubmodule
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
public AnimationBase parentAnimationElement;
|
||||
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
||||
public BaseElement_BM MatchingExportElement { get; set; }
|
||||
public InterferomType InterferomType;
|
||||
#endregion
|
||||
|
||||
#region [导出接口] Export Interface
|
||||
public virtual void SaveExportBM()
|
||||
{
|
||||
MatchingExportElement = null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public interface IBeChangeInExport
|
||||
/// <summary>
|
||||
/// 提供导出时替换当前元素的替代 BM 元素。返回 null 表示不需要替换,使用默认逻辑。
|
||||
/// 实现方在 GetExportElement() 中完成准备工作(SaveBM、干涉仪、烘焙),然后返回替代元素。
|
||||
/// </summary>
|
||||
public interface IExportOverride
|
||||
{
|
||||
public BaseElement_BM MatchingExportElement { get; set; }
|
||||
void SaveExportBM();
|
||||
BaseElement_BM GetExportElement();
|
||||
}
|
||||
|
||||
public interface IHaveInterferometer
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class DisplacementTracker : AnimationBase, IBeChangeInExport, IHaveVector3Interferometer, IHaveTimeDurationSubmodule, ICanBeTrackedDisplacement
|
||||
public partial class DisplacementTracker : AnimationBase, IExportOverride, IHaveVector3Interferometer, IHaveTimeDurationSubmodule, ICanBeTrackedDisplacement
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
private TransformSubmodule targetTransformSubmodule;
|
||||
@@ -14,7 +14,7 @@ namespace Ichni.RhythmGame
|
||||
private FlexibleFloat positionX, positionY, positionZ;
|
||||
public Vector3 PreviewValue = Vector3.zero;
|
||||
public float TimeOffset;
|
||||
public BaseElement_BM MatchingExportElement { get; set; } = null;
|
||||
public bool MaybeDeadLoop = true;
|
||||
public List<InterferometerBase> Interferometers { get; set; } = new();
|
||||
#endregion
|
||||
|
||||
@@ -159,9 +159,9 @@ namespace Ichni.RhythmGame
|
||||
public override Vector3 getValue(float time)
|
||||
{
|
||||
Vector3 currentPosition = new Vector3(
|
||||
positionX.GetValue(time + TimeOffset),
|
||||
positionY.GetValue(time + TimeOffset),
|
||||
positionZ.GetValue(time + TimeOffset)
|
||||
positionX.GetValue(time),
|
||||
positionY.GetValue(time),
|
||||
positionZ.GetValue(time)
|
||||
);
|
||||
((IHaveVector3Interferometer)this).ApplyVector3Interferometers(ref currentPosition);
|
||||
return currentPosition;
|
||||
@@ -169,12 +169,15 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public Displacement GetOriginDisplacementWithOffset(ref float timeOffset)
|
||||
{
|
||||
return null;
|
||||
timeOffset += TimeOffset;
|
||||
if (targetDisplacement is Displacement disp) return disp;
|
||||
else if (targetDisplacement is DisplacementTracker dispTracker) return dispTracker.GetOriginDisplacementWithOffset(ref timeOffset);
|
||||
else throw new Exception("WTF type of tracked displacement.");
|
||||
}
|
||||
|
||||
public (FlexibleReturnType, bool)[] GetCurrentReturnTypes(float time)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return targetDisplacement.GetCurrentReturnTypes(time + TimeOffset);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -185,15 +188,13 @@ namespace Ichni.RhythmGame
|
||||
((GameElement)targetDisplacement).elementGuid, TimeOffset);
|
||||
}
|
||||
|
||||
public void SaveExportBM()
|
||||
public BaseElement_BM GetExportElement()
|
||||
{
|
||||
Refresh();
|
||||
SaveBM();
|
||||
MatchingExportElement = matchedBM;
|
||||
parentElement.SaveBM();
|
||||
var a = new Displacement_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
return new Displacement_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
positionX.ConvertToBM(), positionY.ConvertToBM(), positionZ.ConvertToBM());
|
||||
MatchingExportElement = a;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class ScaleTracker : AnimationBase, IBeChangeInExport, IHaveVector3Interferometer, IHaveTimeDurationSubmodule, ICanBeTrackedScale
|
||||
public partial class ScaleTracker : AnimationBase, IExportOverride, IHaveVector3Interferometer, IHaveTimeDurationSubmodule, ICanBeTrackedScale
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
private TransformSubmodule targetTransformSubmodule;
|
||||
@@ -14,7 +14,6 @@ namespace Ichni.RhythmGame
|
||||
public Vector3 PreviewValue = Vector3.zero;
|
||||
public float TimeOffset;
|
||||
public bool MaybeDeadLoop = true;
|
||||
public BaseElement_BM MatchingExportElement { get; set; } = null;
|
||||
public List<InterferometerBase> Interferometers { get; set; } = new();
|
||||
private FlexibleFloat scaleX, scaleY, scaleZ;
|
||||
#endregion
|
||||
@@ -147,15 +146,18 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public (FlexibleReturnType, bool)[] GetCurrentReturnTypes(float time)
|
||||
{
|
||||
return targetScale.GetCurrentReturnTypes(time + TimeOffset);
|
||||
(FlexibleReturnType, bool) x = scaleX.getReturnType(time);
|
||||
(FlexibleReturnType, bool) y = scaleY.getReturnType(time);
|
||||
(FlexibleReturnType, bool) z = scaleZ.getReturnType(time);
|
||||
return new (FlexibleReturnType, bool)[] { x, y, z };
|
||||
}
|
||||
|
||||
public override Vector3 getValue(float time)
|
||||
{
|
||||
Vector3 currentScale = new Vector3(
|
||||
scaleX.GetValue(time + TimeOffset),
|
||||
scaleY.GetValue(time + TimeOffset),
|
||||
scaleZ.GetValue(time + TimeOffset)
|
||||
scaleX.GetValue(time),
|
||||
scaleY.GetValue(time),
|
||||
scaleZ.GetValue(time)
|
||||
);
|
||||
((IHaveVector3Interferometer)this).ApplyVector3Interferometers(ref currentScale);
|
||||
return currentScale;
|
||||
@@ -177,15 +179,13 @@ namespace Ichni.RhythmGame
|
||||
((GameElement)targetScale).elementGuid, TimeOffset);
|
||||
}
|
||||
|
||||
public void SaveExportBM()
|
||||
public BaseElement_BM GetExportElement()
|
||||
{
|
||||
Refresh();
|
||||
SaveBM();
|
||||
MatchingExportElement = matchedBM;
|
||||
parentElement.SaveBM();
|
||||
var a = new Scale_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
return new Scale_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
scaleX.ConvertToBM(), scaleY.ConvertToBM(), scaleZ.ConvertToBM());
|
||||
MatchingExportElement = a;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class SwirlTracker : AnimationBase, IBeChangeInExport, IHaveVector3Interferometer, IHaveTimeDurationSubmodule, ICanBeTrackedSwirl
|
||||
public partial class SwirlTracker : AnimationBase, IExportOverride, IHaveVector3Interferometer, IHaveTimeDurationSubmodule, ICanBeTrackedSwirl
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
private TransformSubmodule targetTransformSubmodule;
|
||||
@@ -14,7 +14,6 @@ namespace Ichni.RhythmGame
|
||||
public Vector3 PreviewValue = Vector3.zero;
|
||||
public float TimeOffset;
|
||||
public bool MaybeDeadLoop = true;
|
||||
public BaseElement_BM MatchingExportElement { get; set; } = null;
|
||||
public List<InterferometerBase> Interferometers { get; set; } = new();
|
||||
private FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
|
||||
#endregion
|
||||
@@ -147,15 +146,18 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public (FlexibleReturnType, bool)[] GetCurrentReturnTypes(float time)
|
||||
{
|
||||
return targetSwirl.GetCurrentReturnTypes(time + TimeOffset);
|
||||
(FlexibleReturnType, bool) x = eulerAngleX.getReturnType(time);
|
||||
(FlexibleReturnType, bool) y = eulerAngleY.getReturnType(time);
|
||||
(FlexibleReturnType, bool) z = eulerAngleZ.getReturnType(time);
|
||||
return new (FlexibleReturnType, bool)[] { x, y, z };
|
||||
}
|
||||
|
||||
public override Vector3 getValue(float time)
|
||||
{
|
||||
Vector3 currentEulerAngles = new Vector3(
|
||||
eulerAngleX.GetValue(time + TimeOffset),
|
||||
eulerAngleY.GetValue(time + TimeOffset),
|
||||
eulerAngleZ.GetValue(time + TimeOffset)
|
||||
eulerAngleX.GetValue(time),
|
||||
eulerAngleY.GetValue(time),
|
||||
eulerAngleZ.GetValue(time)
|
||||
);
|
||||
((IHaveVector3Interferometer)this).ApplyVector3Interferometers(ref currentEulerAngles);
|
||||
return currentEulerAngles;
|
||||
@@ -177,15 +179,13 @@ namespace Ichni.RhythmGame
|
||||
((GameElement)targetSwirl).elementGuid, TimeOffset);
|
||||
}
|
||||
|
||||
public void SaveExportBM()
|
||||
public BaseElement_BM GetExportElement()
|
||||
{
|
||||
Refresh();
|
||||
SaveBM();
|
||||
MatchingExportElement = matchedBM;
|
||||
parentElement.SaveBM();
|
||||
var a = new Swirl_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
return new Swirl_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
eulerAngleX.ConvertToBM(), eulerAngleY.ConvertToBM(), eulerAngleZ.ConvertToBM());
|
||||
MatchingExportElement = a;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -7,14 +7,13 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class Displacement : AnimationBase, IHaveVector3Interferometer, ICanBeTrackedDisplacement
|
||||
public partial class Displacement : AnimationBase, IHaveVector3Interferometer, IExportOverride, ICanBeTrackedDisplacement
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
private TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat positionX, positionY, positionZ;
|
||||
public List<InterferometerBase> Interferometers { get; set; } = new List<InterferometerBase>();
|
||||
public Vector3 PreviewValue = Vector3.zero;
|
||||
public BaseElement_BM MatchingExportElement { get; set; }
|
||||
#endregion
|
||||
|
||||
#region [生成与初始化] Generation & Initialization
|
||||
@@ -113,14 +112,14 @@ namespace Ichni.RhythmGame
|
||||
positionX.ConvertToBM(), positionY.ConvertToBM(), positionZ.ConvertToBM());
|
||||
}
|
||||
|
||||
public void SaveExportBM()
|
||||
public BaseElement_BM GetExportElement()
|
||||
{
|
||||
SaveBM();
|
||||
MatchingExportElement = matchedBM;
|
||||
((IHaveVector3Interferometer)this).ApplyVector3InterferometersBM(
|
||||
(MatchingExportElement as Displacement_BM).positionX,
|
||||
(MatchingExportElement as Displacement_BM).positionY,
|
||||
(MatchingExportElement as Displacement_BM).positionZ);
|
||||
(matchedBM as Displacement_BM).positionX,
|
||||
(matchedBM as Displacement_BM).positionY,
|
||||
(matchedBM as Displacement_BM).positionZ);
|
||||
return matchedBM;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class Scale : AnimationBase, IHaveVector3Interferometer, IBeChangeInExport, ICanBeTrackedScale
|
||||
public partial class Scale : AnimationBase, IHaveVector3Interferometer, IExportOverride, ICanBeTrackedScale
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat scaleX, scaleY, scaleZ;
|
||||
public List<InterferometerBase> Interferometers { get; set; } = new List<InterferometerBase>();
|
||||
public BaseElement_BM MatchingExportElement { get; set; }
|
||||
public Vector3 PreviewValue = Vector3.zero;
|
||||
#endregion
|
||||
|
||||
@@ -134,14 +133,14 @@ namespace Ichni.RhythmGame
|
||||
scaleX.ConvertToBM(), scaleY.ConvertToBM(), scaleZ.ConvertToBM());
|
||||
}
|
||||
|
||||
public void SaveExportBM()
|
||||
public BaseElement_BM GetExportElement()
|
||||
{
|
||||
SaveBM();
|
||||
MatchingExportElement = matchedBM;
|
||||
((IHaveVector3Interferometer)this).ApplyVector3InterferometersBM(
|
||||
(MatchingExportElement as Scale_BM).scaleX,
|
||||
(MatchingExportElement as Scale_BM).scaleY,
|
||||
(MatchingExportElement as Scale_BM).scaleZ);
|
||||
(matchedBM as Scale_BM).scaleX,
|
||||
(matchedBM as Scale_BM).scaleY,
|
||||
(matchedBM as Scale_BM).scaleZ);
|
||||
return matchedBM;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -6,14 +6,13 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class Swirl : AnimationBase, IHaveVector3Interferometer, IBeChangeInExport, ICanBeTrackedSwirl
|
||||
public partial class Swirl : AnimationBase, IHaveVector3Interferometer, IExportOverride, ICanBeTrackedSwirl
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
private TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
|
||||
public List<InterferometerBase> Interferometers { get; set; } = new List<InterferometerBase>();
|
||||
public Vector3 PreviewValue = Vector3.zero;
|
||||
public BaseElement_BM MatchingExportElement { get; set; }
|
||||
#endregion
|
||||
|
||||
#region [生成与初始化] Generation & Initialization
|
||||
@@ -129,14 +128,14 @@ namespace Ichni.RhythmGame
|
||||
eulerAngleX.ConvertToBM(), eulerAngleY.ConvertToBM(), eulerAngleZ.ConvertToBM());
|
||||
}
|
||||
|
||||
public void SaveExportBM()
|
||||
public BaseElement_BM GetExportElement()
|
||||
{
|
||||
SaveBM();
|
||||
MatchingExportElement = matchedBM;
|
||||
((IHaveVector3Interferometer)this).ApplyVector3InterferometersBM(
|
||||
(MatchingExportElement as Swirl_BM).eulerAngleX,
|
||||
(MatchingExportElement as Swirl_BM).eulerAngleY,
|
||||
(MatchingExportElement as Swirl_BM).eulerAngleZ);
|
||||
(matchedBM as Swirl_BM).eulerAngleX,
|
||||
(matchedBM as Swirl_BM).eulerAngleY,
|
||||
(matchedBM as Swirl_BM).eulerAngleZ);
|
||||
return matchedBM;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using UnityEngine.Events;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class BeatmapContainer : IBaseElement, IBeChangeInExport
|
||||
public class BeatmapContainer : IBaseElement, IExportOverride
|
||||
{
|
||||
#region [运行时缓存数据] Property Caches
|
||||
public List<GameElement> gameElementList;
|
||||
@@ -18,7 +18,6 @@ namespace Ichni.RhythmGame
|
||||
public List<UnityAction> lowPriorityActions;
|
||||
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
public BaseElement_BM MatchingExportElement { get; set; }
|
||||
#endregion
|
||||
|
||||
#region [生成与初始化] Generation & Initialization
|
||||
@@ -76,13 +75,14 @@ namespace Ichni.RhythmGame
|
||||
matchedBM = new BeatmapContainer_BM(gameElementList);
|
||||
}
|
||||
|
||||
public void SaveExportBM()
|
||||
public BaseElement_BM GetExportElement()
|
||||
{
|
||||
MatchingExportElement = new BeatmapContainer_BM(gameElementList, true);
|
||||
if (((BeatmapContainer_BM)MatchingExportElement).elementList.Any(i => i is ICanNotInExport))
|
||||
var export = new BeatmapContainer_BM(gameElementList, true);
|
||||
if (export.elementList.Any(i => i is ICanNotInExport))
|
||||
{
|
||||
Debug.LogError("Export Error!");
|
||||
}
|
||||
return export;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user