更新
This commit is contained in:
8
Assets/Scripts/DataCore/Animations.meta
Normal file
8
Assets/Scripts/DataCore/Animations.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b92b5a6a95000b41a36b5884268ea6d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/DataCore/Animations/Custom.meta
Normal file
8
Assets/Scripts/DataCore/Animations/Custom.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8e2a5d8683ebd04bae1c422391a8f03
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ichni.RhythmGame.Beatmap
|
||||
{
|
||||
[System.Serializable]
|
||||
public class PropertyAnimationColor_BM : AnimationBase_BM
|
||||
{
|
||||
public string componentName;
|
||||
public string propertyName;
|
||||
public FlexibleFloat_BM propertyValueR, propertyValueG, propertyValueB, propertyValueA;
|
||||
|
||||
public PropertyAnimationColor_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = PropertyAnimationColor.GenerateElement(elementName, elementGuid, tags, true,
|
||||
GetElement(attachedElementGuid), componentName, propertyName,
|
||||
propertyValueR?.ConvertToGameType(), propertyValueG?.ConvertToGameType(),
|
||||
propertyValueB?.ConvertToGameType(), propertyValueA?.ConvertToGameType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9cac7c753648324a87a52394d111a39
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ichni.RhythmGame.Beatmap
|
||||
{
|
||||
[System.Serializable]
|
||||
public class PropertyAnimationFloat_BM : AnimationBase_BM
|
||||
{
|
||||
public string componentName;
|
||||
public string propertyName;
|
||||
public FlexibleFloat_BM propertyValue;
|
||||
|
||||
public PropertyAnimationFloat_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = PropertyAnimationFloat.GenerateElement(elementName, elementGuid, tags, true,
|
||||
GetElement(attachedElementGuid), componentName, propertyName, propertyValue?.ConvertToGameType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ed5d3d01d95927429a52f2f2c6b1b66
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ichni.RhythmGame.Beatmap
|
||||
{
|
||||
[System.Serializable]
|
||||
public class PropertyAnimationVector3_BM : AnimationBase_BM
|
||||
{
|
||||
public string componentName;
|
||||
public string propertyName;
|
||||
public FlexibleFloat_BM propertyValueX, propertyValueY, propertyValueZ;
|
||||
|
||||
public PropertyAnimationVector3_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = PropertyAnimationVector3.GenerateElement(elementName, elementGuid, tags, true,
|
||||
GetElement(attachedElementGuid), componentName, propertyName,
|
||||
propertyValueX?.ConvertToGameType(), propertyValueY?.ConvertToGameType(), propertyValueZ?.ConvertToGameType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f1e1e70ac758ce47af3a35a4c09e30b
|
||||
8
Assets/Scripts/Game/Animations/Custom.meta
Normal file
8
Assets/Scripts/Game/Animations/Custom.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9da337ed6f8fd2642a980f2876c144a4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
157
Assets/Scripts/Game/Animations/Custom/PropertyAnimationColor.cs
Normal file
157
Assets/Scripts/Game/Animations/Custom/PropertyAnimationColor.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class PropertyAnimationColor : AnimationBase
|
||||
{
|
||||
#region [暴露属性字段与关联] Exposed Fields & References
|
||||
public string componentName;
|
||||
public string propertyName;
|
||||
public FlexibleFloat propertyValueR, propertyValueG, propertyValueB, propertyValueA;
|
||||
|
||||
private Component targetComponent;
|
||||
private FieldInfo targetField;
|
||||
private PropertyInfo targetProperty;
|
||||
|
||||
// 高性能赋值委托
|
||||
private Action<Color> colorSetterDelegate;
|
||||
#endregion
|
||||
|
||||
#region [生命周期与工厂] Lifecycle & Factory
|
||||
public static PropertyAnimationColor GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement animatedObject, string componentName, string propertyName,
|
||||
FlexibleFloat propertyValueR, FlexibleFloat propertyValueG, FlexibleFloat propertyValueB, FlexibleFloat propertyValueA)
|
||||
{
|
||||
PropertyAnimationColor animation = Instantiate(GameManager.Instance.basePrefabs.emptyObject)
|
||||
.AddComponent<PropertyAnimationColor>();
|
||||
|
||||
animation.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
|
||||
|
||||
animation.animatedObject = animatedObject;
|
||||
|
||||
animation.componentName = componentName;
|
||||
animation.propertyName = propertyName;
|
||||
animation.propertyValueR = propertyValueR;
|
||||
animation.propertyValueG = propertyValueG;
|
||||
animation.propertyValueB = propertyValueB;
|
||||
animation.propertyValueA = propertyValueA;
|
||||
|
||||
return animation;
|
||||
}
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
if (animatedObject == null || string.IsNullOrEmpty(componentName)) return;
|
||||
|
||||
Type componentType = GetTypeFromAllAssemblies(componentName);
|
||||
if (componentType != null)
|
||||
{
|
||||
targetComponent = animatedObject.GetComponentInChildren(componentType);
|
||||
}
|
||||
|
||||
if (targetComponent != null)
|
||||
{
|
||||
InitializeReflection();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[PropertyAnimationColor] Cannot find Component '{componentName}' strictly on '{animatedObject.name}'.");
|
||||
}
|
||||
|
||||
base.AfterInitialize();
|
||||
}
|
||||
|
||||
private Type GetTypeFromAllAssemblies(string typeName)
|
||||
{
|
||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
Type type = assembly.GetType(typeName);
|
||||
if (type != null) return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void InitializeReflection()
|
||||
{
|
||||
Type type = targetComponent.GetType();
|
||||
|
||||
targetProperty = type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (targetProperty != null && targetProperty.CanWrite)
|
||||
{
|
||||
MethodInfo setMethod = targetProperty.GetSetMethod(nonPublic: true);
|
||||
if (setMethod != null && targetProperty.PropertyType == typeof(Color))
|
||||
{
|
||||
try
|
||||
{
|
||||
colorSetterDelegate = (Action<Color>)Delegate.CreateDelegate(typeof(Action<Color>), targetComponent, setMethod);
|
||||
return;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
targetField = type.GetField(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (targetField == null && targetProperty == null)
|
||||
{
|
||||
Debug.LogWarning($"[PropertyAnimationColor] Cannot find target Property or Field '{propertyName}' strictly on '{componentName}'.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [核心动画逻辑] Core Animation Logic
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
if (targetComponent == null) return;
|
||||
|
||||
propertyValueR?.UpdateFlexibleFloat(songTime);
|
||||
propertyValueG?.UpdateFlexibleFloat(songTime);
|
||||
propertyValueB?.UpdateFlexibleFloat(songTime);
|
||||
propertyValueA?.UpdateFlexibleFloat(songTime);
|
||||
|
||||
// 获取最新颜色(如果没有对应颜色参数或者为空则默认 1 避免黑屏,但这依赖具体业务传值安全度)
|
||||
float r = propertyValueR != null ? propertyValueR.value : 1f;
|
||||
float g = propertyValueG != null ? propertyValueG.value : 1f;
|
||||
float b = propertyValueB != null ? propertyValueB.value : 1f;
|
||||
float a = propertyValueA != null ? propertyValueA.value : 1f;
|
||||
|
||||
Color targetColor = new Color(r, g, b, a);
|
||||
|
||||
if (colorSetterDelegate != null)
|
||||
{
|
||||
colorSetterDelegate(targetColor);
|
||||
}
|
||||
else if (targetProperty != null)
|
||||
{
|
||||
targetProperty.SetValue(targetComponent, targetColor);
|
||||
}
|
||||
else if (targetField != null)
|
||||
{
|
||||
targetField.SetValue(targetComponent, targetColor);
|
||||
}
|
||||
|
||||
if (animatedObject is IHaveDirtyMarkSubmodule dirtyTarget)
|
||||
{
|
||||
dirtyTarget.dirtyMarkSubmodule.MarkDirty(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyTimeOffset(float offset)
|
||||
{
|
||||
base.ApplyTimeOffset(offset);
|
||||
void ApplyOffset(FlexibleFloat ff)
|
||||
{
|
||||
if (ff == null || ff.animations == null) return;
|
||||
foreach(var a in ff.animations) { a.startTime += offset; a.endTime += offset; }
|
||||
}
|
||||
ApplyOffset(propertyValueR);
|
||||
ApplyOffset(propertyValueG);
|
||||
ApplyOffset(propertyValueB);
|
||||
ApplyOffset(propertyValueA);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7532e5b8b30e2842ba4f4a638277c64
|
||||
145
Assets/Scripts/Game/Animations/Custom/PropertyAnimationFloat.cs
Normal file
145
Assets/Scripts/Game/Animations/Custom/PropertyAnimationFloat.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class PropertyAnimationFloat : AnimationBase
|
||||
{
|
||||
#region [暴露属性字段与关联] Exposed Fields & References
|
||||
public string componentName;
|
||||
public string propertyName;
|
||||
public FlexibleFloat propertyValue;
|
||||
|
||||
private Component targetComponent;
|
||||
private FieldInfo targetField;
|
||||
private PropertyInfo targetProperty;
|
||||
|
||||
// 我们尝试通过原生的 Action 来降低反射 SetValue 带来的性能损耗(装箱与GC)
|
||||
private Action<float> floatSetterDelegate;
|
||||
#endregion
|
||||
|
||||
#region [生命周期与工厂] Lifecycle & Factory
|
||||
public static PropertyAnimationFloat GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement animatedObject, string componentName, string propertyName, FlexibleFloat propertyValue)
|
||||
{
|
||||
PropertyAnimationFloat animation = Instantiate(GameManager.Instance.basePrefabs.emptyObject)
|
||||
.AddComponent<PropertyAnimationFloat>();
|
||||
|
||||
animation.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
|
||||
|
||||
animation.animatedObject = animatedObject;
|
||||
|
||||
animation.componentName = componentName;
|
||||
animation.propertyName = propertyName;
|
||||
animation.propertyValue = propertyValue;
|
||||
|
||||
return animation;
|
||||
}
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
if (animatedObject == null || string.IsNullOrEmpty(componentName)) return;
|
||||
|
||||
Type componentType = GetTypeFromAllAssemblies(componentName);
|
||||
if (componentType != null)
|
||||
{
|
||||
targetComponent = animatedObject.GetComponentInChildren(componentType);
|
||||
}
|
||||
|
||||
if (targetComponent != null)
|
||||
{
|
||||
InitializeReflection();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[PropertyAnimationFloat] Cannot find Component '{componentName}' strictly on '{animatedObject.name}'.");
|
||||
}
|
||||
|
||||
base.AfterInitialize();
|
||||
}
|
||||
|
||||
private Type GetTypeFromAllAssemblies(string typeName)
|
||||
{
|
||||
// 对于跨程序集的搜索
|
||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
Type type = assembly.GetType(typeName);
|
||||
if (type != null) return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void InitializeReflection()
|
||||
{
|
||||
Type type = targetComponent.GetType();
|
||||
|
||||
// 1. 尝试寻找 Property
|
||||
targetProperty = type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (targetProperty != null && targetProperty.CanWrite)
|
||||
{
|
||||
MethodInfo setMethod = targetProperty.GetSetMethod(nonPublic: true);
|
||||
if (setMethod != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
floatSetterDelegate = (Action<float>)Delegate.CreateDelegate(typeof(Action<float>), targetComponent, setMethod);
|
||||
return; // 建立快速委托成功!
|
||||
}
|
||||
catch { /* 回落 */ }
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 尝试寻找 Field (直接包含公有/私有)
|
||||
targetField = type.GetField(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (targetField == null && targetProperty == null)
|
||||
{
|
||||
Debug.LogWarning($"[PropertyAnimationFloat] Cannot find target Property or Field '{propertyName}' strictly on '{componentName}'.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [核心动画逻辑] Core Animation Logic
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
if (targetComponent == null || propertyValue == null || propertyValue.animations.Count == 0) return;
|
||||
|
||||
propertyValue.UpdateFlexibleFloat(songTime);
|
||||
float value = propertyValue.value;
|
||||
|
||||
if (floatSetterDelegate != null)
|
||||
{
|
||||
floatSetterDelegate(value);
|
||||
}
|
||||
else if (targetProperty != null)
|
||||
{
|
||||
targetProperty.SetValue(targetComponent, value);
|
||||
}
|
||||
else if (targetField != null)
|
||||
{
|
||||
targetField.SetValue(targetComponent, value);
|
||||
}
|
||||
|
||||
if (animatedObject is IHaveDirtyMarkSubmodule dirtyTarget)
|
||||
{
|
||||
dirtyTarget.dirtyMarkSubmodule.MarkDirty(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyTimeOffset(float offset)
|
||||
{
|
||||
base.ApplyTimeOffset(offset);
|
||||
if (propertyValue != null && propertyValue.animations != null)
|
||||
{
|
||||
foreach(var a in propertyValue.animations)
|
||||
{
|
||||
a.startTime += offset;
|
||||
a.endTime += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94ee23661f2295c4c96f77067b411969
|
||||
@@ -0,0 +1,152 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class PropertyAnimationVector3 : AnimationBase
|
||||
{
|
||||
#region [暴露属性字段与关联] Exposed Fields & References
|
||||
public string componentName;
|
||||
public string propertyName;
|
||||
public FlexibleFloat propertyValueX, propertyValueY, propertyValueZ;
|
||||
|
||||
private Component targetComponent;
|
||||
private FieldInfo targetField;
|
||||
private PropertyInfo targetProperty;
|
||||
|
||||
// 高性能赋值委托
|
||||
private Action<Vector3> vectorSetterDelegate;
|
||||
#endregion
|
||||
|
||||
#region [生命周期与工厂] Lifecycle & Factory
|
||||
public static PropertyAnimationVector3 GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement animatedObject, string componentName, string propertyName,
|
||||
FlexibleFloat propertyValueX, FlexibleFloat propertyValueY, FlexibleFloat propertyValueZ)
|
||||
{
|
||||
PropertyAnimationVector3 animation = Instantiate(GameManager.Instance.basePrefabs.emptyObject)
|
||||
.AddComponent<PropertyAnimationVector3>();
|
||||
|
||||
animation.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
|
||||
|
||||
animation.animatedObject = animatedObject;
|
||||
|
||||
animation.componentName = componentName;
|
||||
animation.propertyName = propertyName;
|
||||
animation.propertyValueX = propertyValueX;
|
||||
animation.propertyValueY = propertyValueY;
|
||||
animation.propertyValueZ = propertyValueZ;
|
||||
|
||||
return animation;
|
||||
}
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
if (animatedObject == null || string.IsNullOrEmpty(componentName)) return;
|
||||
|
||||
Type componentType = GetTypeFromAllAssemblies(componentName);
|
||||
if (componentType != null)
|
||||
{
|
||||
targetComponent = animatedObject.GetComponentInChildren(componentType);
|
||||
}
|
||||
|
||||
if (targetComponent != null)
|
||||
{
|
||||
InitializeReflection();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[PropertyAnimationVector3] Cannot find Component '{componentName}' strictly on '{animatedObject.name}'.");
|
||||
}
|
||||
|
||||
base.AfterInitialize();
|
||||
}
|
||||
|
||||
private Type GetTypeFromAllAssemblies(string typeName)
|
||||
{
|
||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
Type type = assembly.GetType(typeName);
|
||||
if (type != null) return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void InitializeReflection()
|
||||
{
|
||||
Type type = targetComponent.GetType();
|
||||
|
||||
targetProperty = type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (targetProperty != null && targetProperty.CanWrite)
|
||||
{
|
||||
MethodInfo setMethod = targetProperty.GetSetMethod(nonPublic: true);
|
||||
if (setMethod != null && targetProperty.PropertyType == typeof(Vector3))
|
||||
{
|
||||
try
|
||||
{
|
||||
vectorSetterDelegate = (Action<Vector3>)Delegate.CreateDelegate(typeof(Action<Vector3>), targetComponent, setMethod);
|
||||
return;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
targetField = type.GetField(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (targetField == null && targetProperty == null)
|
||||
{
|
||||
Debug.LogWarning($"[PropertyAnimationVector3] Cannot find target Property or Field '{propertyName}' strictly on '{componentName}'.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [核心动画逻辑] Core Animation Logic
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
if (targetComponent == null) return;
|
||||
|
||||
propertyValueX?.UpdateFlexibleFloat(songTime);
|
||||
propertyValueY?.UpdateFlexibleFloat(songTime);
|
||||
propertyValueZ?.UpdateFlexibleFloat(songTime);
|
||||
|
||||
float x = propertyValueX != null ? propertyValueX.value : 0f;
|
||||
float y = propertyValueY != null ? propertyValueY.value : 0f;
|
||||
float z = propertyValueZ != null ? propertyValueZ.value : 0f;
|
||||
|
||||
Vector3 targetVector = new Vector3(x, y, z);
|
||||
|
||||
if (vectorSetterDelegate != null)
|
||||
{
|
||||
vectorSetterDelegate(targetVector);
|
||||
}
|
||||
else if (targetProperty != null)
|
||||
{
|
||||
targetProperty.SetValue(targetComponent, targetVector);
|
||||
}
|
||||
else if (targetField != null)
|
||||
{
|
||||
targetField.SetValue(targetComponent, targetVector);
|
||||
}
|
||||
|
||||
if (animatedObject is IHaveDirtyMarkSubmodule dirtyTarget)
|
||||
{
|
||||
dirtyTarget.dirtyMarkSubmodule.MarkDirty(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyTimeOffset(float offset)
|
||||
{
|
||||
base.ApplyTimeOffset(offset);
|
||||
void ApplyOffset(FlexibleFloat ff)
|
||||
{
|
||||
if (ff == null || ff.animations == null) return;
|
||||
foreach(var a in ff.animations) { a.startTime += offset; a.endTime += offset; }
|
||||
}
|
||||
ApplyOffset(propertyValueX);
|
||||
ApplyOffset(propertyValueY);
|
||||
ApplyOffset(propertyValueZ);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c2a33e8c63667d47967d086d0a0c2d8
|
||||
@@ -57,8 +57,8 @@ namespace Ichni.RhythmGame
|
||||
else if (positionX.isSwitchingReturnType || positionY.isSwitchingReturnType || positionZ.isSwitchingReturnType)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentPosition = new Vector3(positionX.value, positionY.value, positionZ.value);
|
||||
targetTransformSubmodule.positionOffset += currentPosition;
|
||||
//Vector3 currentPosition = new Vector3(positionX.value, positionY.value, positionZ.value);
|
||||
//targetTransformSubmodule.positionOffset += currentPosition;
|
||||
targetTransformSubmodule.positionDirtyMark = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -60,8 +60,8 @@ namespace Ichni.RhythmGame
|
||||
else if (scaleX.isSwitchingReturnType || scaleY.isSwitchingReturnType || scaleZ.isSwitchingReturnType)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset += currentScale;
|
||||
//Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
//targetTransformSubmodule.scaleOffset += currentScale;
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -55,8 +55,8 @@ namespace Ichni.RhythmGame
|
||||
else if (eulerAngleX.isSwitchingReturnType || eulerAngleY.isSwitchingReturnType || eulerAngleZ.isSwitchingReturnType)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentEulerAngles = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value);
|
||||
targetTransformSubmodule.eulerAnglesOffset += currentEulerAngles;
|
||||
//Vector3 currentEulerAngles = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value);
|
||||
//targetTransformSubmodule.eulerAnglesOffset += currentEulerAngles;
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -114,9 +114,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public void SetColorObserver()
|
||||
{
|
||||
colorSubmodule.observer = Observable.EveryUpdate()
|
||||
.Subscribe(_ => UpdateColor())
|
||||
.AddTo(colorSubmodule.attachedGameElement);
|
||||
// 旧版的 UniRx 各自监听已淘汰,现由 GameManager 中枢在 LateUpdate 统一下发 UpdateColor()
|
||||
}
|
||||
|
||||
public void UpdateColor(bool refreshAll = true)
|
||||
|
||||
63
Assets/Scripts/Game/Components/DirtyMarkSubmodule.cs
Normal file
63
Assets/Scripts/Game/Components/DirtyMarkSubmodule.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class DirtyMarkSubmodule : SubmoduleBase
|
||||
{
|
||||
public bool isAnyDirty { get; private set; }
|
||||
public Dictionary<string, bool> dirtyFlags;
|
||||
|
||||
public DirtyMarkSubmodule(GameElement attachedGameElement) : base(attachedGameElement)
|
||||
{
|
||||
isAnyDirty = false;
|
||||
dirtyFlags = new Dictionary<string, bool>();
|
||||
|
||||
if (!HaveSameSubmodule && attachedGameElement is IHaveDirtyMarkSubmodule host)
|
||||
{
|
||||
host.dirtyMarkSubmodule = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkDirty(string flagKey = "All")
|
||||
{
|
||||
isAnyDirty = true;
|
||||
if (!string.IsNullOrEmpty(flagKey))
|
||||
{
|
||||
dirtyFlags[flagKey] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteDeferredRefresh()
|
||||
{
|
||||
if (isAnyDirty && attachedGameElement is IHaveDirtyMarkSubmodule host)
|
||||
{
|
||||
host.OnDirtyRefresh(dirtyFlags);
|
||||
ClearDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearDirty()
|
||||
{
|
||||
isAnyDirty = false;
|
||||
dirtyFlags.Clear();
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
MarkDirty("All");
|
||||
}
|
||||
|
||||
public override void CheckAndRemoveObservers() { }
|
||||
}
|
||||
|
||||
public interface IHaveDirtyMarkSubmodule
|
||||
{
|
||||
DirtyMarkSubmodule dirtyMarkSubmodule { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当有一帧收到来自于动画或者其它管理器的脏标记篡改时,在此方法中处理推送至具体表现层的工作。
|
||||
/// </summary>
|
||||
void OnDirtyRefresh(Dictionary<string, bool> flags);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5748988e564e7241ba2eaac6f9ad09d
|
||||
@@ -125,10 +125,8 @@ namespace Ichni.RhythmGame
|
||||
/// </summary>
|
||||
public void SetTransformObserver()
|
||||
{
|
||||
transformSubmodule.observer = Observable.EveryUpdate()
|
||||
.Where(_ => GameManager.Instance.songPlayer.isUpdating)
|
||||
.Subscribe(_ => UpdateTransform())
|
||||
.AddTo(transformSubmodule.attachedGameElement);
|
||||
// 旧版的 UniRx 各自监听已淘汰,现由 GameManager 中枢在 LateUpdate 统一下发 UpdateTransform()
|
||||
// 如果有一些特殊物体需要极其特殊时序,可覆盖此方法或手动管理
|
||||
}
|
||||
|
||||
public void UpdateTransform(bool refreshAll = true)
|
||||
|
||||
@@ -7,8 +7,23 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class EnvironmentObject : SubstantialObject
|
||||
public partial class EnvironmentObject : SubstantialObject, IHaveDirtyMarkSubmodule
|
||||
{
|
||||
#region [脏数据标记] Dirty Mark Submodule
|
||||
public DirtyMarkSubmodule dirtyMarkSubmodule { get; set; }
|
||||
|
||||
public virtual void OnDirtyRefresh(Dictionary<string, bool> flags)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SetDefaultSubmodules()
|
||||
{
|
||||
base.SetDefaultSubmodules();
|
||||
dirtyMarkSubmodule = new DirtyMarkSubmodule(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [标记参数] Flags
|
||||
public bool isStatic;
|
||||
#endregion
|
||||
|
||||
@@ -58,6 +58,21 @@ namespace Ichni.RhythmGame
|
||||
SetDefaultSubmodules();
|
||||
}
|
||||
|
||||
if (this is IHaveTransformSubmodule transformSource && !GameManager.Instance.activeTransformSubmodules.Contains(transformSource))
|
||||
{
|
||||
GameManager.Instance.activeTransformSubmodules.Add(transformSource);
|
||||
}
|
||||
|
||||
if (this is IHaveColorSubmodule colorSource && !GameManager.Instance.activeColorSubmodules.Contains(colorSource))
|
||||
{
|
||||
GameManager.Instance.activeColorSubmodules.Add(colorSource);
|
||||
}
|
||||
|
||||
if (this is IHaveDirtyMarkSubmodule dirtySource && !GameManager.Instance.activeDirtyMarkSubmodules.Contains(dirtySource))
|
||||
{
|
||||
GameManager.Instance.activeDirtyMarkSubmodules.Add(dirtySource);
|
||||
}
|
||||
|
||||
SetParent(parentElement);
|
||||
}
|
||||
|
||||
@@ -146,7 +161,18 @@ namespace Ichni.RhythmGame
|
||||
/// </summary>
|
||||
public virtual void OnDelete()
|
||||
{
|
||||
|
||||
if (this is IHaveTransformSubmodule transformSource)
|
||||
{
|
||||
GameManager.Instance.activeTransformSubmodules.Remove(transformSource);
|
||||
}
|
||||
if (this is IHaveColorSubmodule colorSource)
|
||||
{
|
||||
GameManager.Instance.activeColorSubmodules.Remove(colorSource);
|
||||
}
|
||||
if (this is IHaveDirtyMarkSubmodule dirtySource)
|
||||
{
|
||||
GameManager.Instance.activeDirtyMarkSubmodules.Remove(dirtySource);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -82,7 +82,6 @@ namespace Ichni.RhythmGame
|
||||
nowAttachedTrack = trackListFolder.trackList[trackSwitch.value];
|
||||
nowAttachedTrackIndex = trackSwitch.value;
|
||||
trackPositioner.spline = trackListFolder.trackList[trackSwitch.value].trackPathSubmodule.path;
|
||||
trackPositioner.Rebuild();
|
||||
}
|
||||
|
||||
trackPositioner.SetPercent(trackPercent.value);
|
||||
|
||||
@@ -34,15 +34,9 @@ public partial class BasePrefabsCollection : SerializedScriptableObject
|
||||
public GameObject areaHint;
|
||||
public GameObject triggerHint;
|
||||
|
||||
[Title("Effect相关")] public Material defaultParticleMaterial;
|
||||
[Title("Effect相关")]
|
||||
public Material defaultParticleMaterial;
|
||||
public GameObject particleEmitter;
|
||||
public GameObject bloomEffect;
|
||||
public GameObject cameraShakeEffect;
|
||||
public GameObject cameraZoomEffect;
|
||||
public GameObject chromaticAberrationEffect;
|
||||
public GameObject vignetteEffect;
|
||||
public GameObject lowPassFilterEffect;
|
||||
public GameObject highPassFilterEffect;
|
||||
|
||||
[Title("Background相关")] public Sprite defaultBackground;
|
||||
public Material defaultSkyboxMaterial;
|
||||
@@ -69,7 +63,7 @@ public partial class BasePrefabsCollection
|
||||
{
|
||||
foreach (KeyValuePair<string, Event> sound in noteSounds)
|
||||
{
|
||||
AkSoundEngine.PrepareEvent(AkPreparationType.Preparation_Load, new uint[] { sound.Value.PlayingId }, 1);
|
||||
AkUnitySoundEngine.PrepareEvent(AkPreparationType.Preparation_Load, new uint[] { sound.Value.PlayingId }, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,10 @@ namespace Ichni
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
public Dictionary<string, CustomPrefabsCollection> customPrefabs;
|
||||
|
||||
public List<IHaveTransformSubmodule> activeTransformSubmodules = new List<IHaveTransformSubmodule>();
|
||||
public List<IHaveColorSubmodule> activeColorSubmodules = new List<IHaveColorSubmodule>();
|
||||
public List<IHaveDirtyMarkSubmodule> activeDirtyMarkSubmodules = new List<IHaveDirtyMarkSubmodule>();
|
||||
|
||||
[Title("UI")]
|
||||
public Canvas judgeHintCanvas;
|
||||
public GameUICanvas gameUICanvas;
|
||||
@@ -88,6 +92,21 @@ namespace Ichni
|
||||
|
||||
trackManager.ManualLateUpdate(SongTime);
|
||||
noteManager.ManualLateUpdate(SongTime);
|
||||
|
||||
for(int i = 0; i < activeColorSubmodules.Count; i++)
|
||||
{
|
||||
activeColorSubmodules[i].UpdateColor(true);
|
||||
}
|
||||
|
||||
for(int i = 0; i < activeTransformSubmodules.Count; i++)
|
||||
{
|
||||
activeTransformSubmodules[i].UpdateTransform(true);
|
||||
}
|
||||
|
||||
for(int i = 0; i < activeDirtyMarkSubmodules.Count; i++)
|
||||
{
|
||||
activeDirtyMarkSubmodules[i].dirtyMarkSubmodule.ExecuteDeferredRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user