谱面改进
This commit is contained in:
@@ -11,8 +11,14 @@ namespace Ichni.RhythmGame
|
||||
#region [暴露属性字段与关联] Exposed Fields & References
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat scaleX, scaleY, scaleZ;
|
||||
|
||||
// 静态跟踪全局激活的Scale组件,为了方便同物体的跨动画状态感应
|
||||
public static HashSet<Scale> ActiveScales = new HashSet<Scale>();
|
||||
#endregion
|
||||
|
||||
protected void OnEnable() { ActiveScales.Add(this); }
|
||||
protected void OnDisable() { ActiveScales.Remove(this); }
|
||||
|
||||
#region [生命周期与工厂] Lifecycle & Factory
|
||||
public static Scale GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
|
||||
@@ -49,21 +55,65 @@ namespace Ichni.RhythmGame
|
||||
scaleY.UpdateFlexibleFloat(songTime);
|
||||
scaleZ.UpdateFlexibleFloat(songTime);
|
||||
|
||||
if (forceUpdate || scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
scaleZ.returnType is FlexibleReturnType.MiddleExecuting)
|
||||
bool isMiddleExecuting = scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
scaleZ.returnType is FlexibleReturnType.MiddleExecuting;
|
||||
|
||||
bool isSwitching = scaleX.isSwitchingReturnType || scaleY.isSwitchingReturnType || scaleZ.isSwitchingReturnType;
|
||||
|
||||
if (forceUpdate || isMiddleExecuting)
|
||||
{
|
||||
if(!forceUpdate) animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset += currentScale;
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
|
||||
// 检查是否是刚开始的第一帧,且有其它同类动画正在收尾(避免两帧叠加导致 ScaleX2)
|
||||
bool shouldSkipFirstFrame = false;
|
||||
if (!forceUpdate && isSwitching)
|
||||
{
|
||||
foreach (var s in ActiveScales)
|
||||
{
|
||||
if (s != this && s.targetTransformSubmodule == this.targetTransformSubmodule)
|
||||
{
|
||||
if (s.scaleX.isSwitchingReturnType || s.scaleY.isSwitchingReturnType || s.scaleZ.isSwitchingReturnType)
|
||||
{
|
||||
shouldSkipFirstFrame = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldSkipFirstFrame)
|
||||
{
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset += currentScale;
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
}
|
||||
}
|
||||
else if (scaleX.isSwitchingReturnType || scaleY.isSwitchingReturnType || scaleZ.isSwitchingReturnType)
|
||||
else if (isSwitching)
|
||||
{
|
||||
//animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
//Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
//targetTransformSubmodule.scaleOffset += currentScale;
|
||||
//targetTransformSubmodule.scaleDirtyMark = true;
|
||||
// 【收尾保护】如果这个动画是附着物体的“最后的动画”的结束,额外更新彻底将其设为终定值
|
||||
bool isAnyOtherExecuting = false;
|
||||
foreach (var s in ActiveScales)
|
||||
{
|
||||
if (s != this && s.targetTransformSubmodule == this.targetTransformSubmodule)
|
||||
{
|
||||
if (s.scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
s.scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
s.scaleZ.returnType is FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
isAnyOtherExecuting = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAnyOtherExecuting)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting; // 使系统认为有有效活动
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset += currentScale;
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user