整合SLSUtilities
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using Cielonos.MainGame.Characters;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.FunctionalAnimation
|
||||
{
|
||||
public class FuncAnimPayloadBase : SLSUtilities.FunctionalAnimation.FuncAnimPayloadBase
|
||||
{
|
||||
public CharacterBase character => runtimeFuncAnim.executor as CharacterBase;
|
||||
}
|
||||
|
||||
public class FuncAnimPayloadBase<T> : SLSUtilities.FunctionalAnimation.FuncAnimPayloadBase<T>
|
||||
{
|
||||
public CharacterBase character => runtimeFuncAnim.executor as CharacterBase;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4923c4069c9142e45b39fba1e1cccff5
|
||||
@@ -11,7 +11,7 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
runtimeFuncAnim.executor.animationSc.registeredFunctions[functionKey].Invoke(runtimeFuncAnim);
|
||||
character.animationSc.registeredFunctions[functionKey].Invoke(runtimeFuncAnim);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.FunctionalAnimation
|
||||
{
|
||||
public partial class InvokePreloadFunction : FuncAnimPayloadBase
|
||||
{
|
||||
private bool HasCollection => parentData != null && parentData.parentCollection != null;
|
||||
|
||||
[InfoBox("此 Data 未连接到 FuncAnimDataCollection,无法获取函数列表。\n请在 FuncAnimData 的顶部进行连接。", InfoMessageType.Error, "@!this.HasCollection")]
|
||||
[PropertyOrder(-1)]
|
||||
[EnableIf("HasCollection")] // 只有连接了才能选
|
||||
[OnInspectorInit("RefreshParameterReference")] // 初始化时刷新参数引用
|
||||
[ValueDropdown("GetFunctionKeys")]
|
||||
[OnValueChanged("OnFunctionKeyChanged")]
|
||||
public string functionKey;
|
||||
|
||||
[HideLabel] // 隐藏字段名,让参数看起来像直接嵌入的
|
||||
[SerializeReference]
|
||||
[HideReferenceObjectPicker] // 隐藏类型选择器,强制由 Key 决定
|
||||
[InfoBox("请先选择一个函数。", InfoMessageType.Warning, "@this.parameters == null && !string.IsNullOrEmpty(this.functionKey)")]
|
||||
public CustomFunction.ParameterCollectionBase parameters;
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
if (runtimeFuncAnim == null) return;
|
||||
|
||||
runtimeFuncAnim.currentActionParams = this.parameters;
|
||||
|
||||
if (!string.IsNullOrEmpty(functionKey) &&
|
||||
character.animationSc.registeredFunctions.TryGetValue(functionKey, out var func))
|
||||
{
|
||||
func.Invoke(runtimeFuncAnim);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[InvokePreRegisteredFunction] 试图调用 '{functionKey}',但该函数未在 AnimationSc 中注册。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class InvokePreloadFunction
|
||||
{
|
||||
private void RefreshParameterReference()
|
||||
{
|
||||
if (parentData == null || parameters == null || string.IsNullOrEmpty(functionKey)) return;
|
||||
|
||||
if (!HasCollection) return;
|
||||
|
||||
List<CustomFunction> functions = parentData.parentCollection.preloadFunctions;
|
||||
CustomFunction selectedFunc = functions.Find(func => func.functionName == functionKey);
|
||||
if (selectedFunc != null)
|
||||
{
|
||||
parameters.function = selectedFunc;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable GetFunctionKeys()
|
||||
{
|
||||
if (!HasCollection) return null;
|
||||
|
||||
List<CustomFunction> functions = parentData.parentCollection.preloadFunctions;
|
||||
if (functions == null || functions.Count == 0) return null;
|
||||
|
||||
return functions.ConvertAll(func => func.functionName);
|
||||
}
|
||||
|
||||
private void OnFunctionKeyChanged()
|
||||
{
|
||||
if (!HasCollection) return;
|
||||
|
||||
CustomFunction selectedFunc = parentData.parentCollection.preloadFunctions.Find(func => func.functionName == functionKey);
|
||||
if (selectedFunc != null)
|
||||
{
|
||||
parameters = Activator.CreateInstance(selectedFunc.paramCollectionType) as CustomFunction.ParameterCollectionBase;
|
||||
if (parameters != null)
|
||||
{
|
||||
parameters.function = selectedFunc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b219618cfa3c91438df5e8927b27299
|
||||
@@ -11,7 +11,7 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
runtimeFuncAnim.executor.audioSc.audioContainer.PlaySoundFX(soundKey);
|
||||
character.audioSc.audioContainer.PlaySoundFX(soundKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,27 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
[Serializable]
|
||||
public class SetGravity : FuncAnimPayloadBase
|
||||
{
|
||||
[LabelText("@this.enableGravity ? \"Enable Gravity\" : \"Disable Gravity\"")]
|
||||
public bool controlGravity;
|
||||
[ShowIf("controlGravity")]
|
||||
[Tooltip("控制是否启用重力")]
|
||||
public bool enableGravity;
|
||||
|
||||
public bool controlGravityMultiplier;
|
||||
[ShowIf("controlGravityMultiplier")]
|
||||
[Tooltip("控制重力倍数")]
|
||||
public float gravityMultiplier;
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
character.movementSc.isApplyingGravity = enableGravity;
|
||||
if (controlGravity)
|
||||
{
|
||||
character.movementSc.isApplyingGravity = enableGravity;
|
||||
}
|
||||
|
||||
if (controlGravityMultiplier)
|
||||
{
|
||||
character.movementSc.gravityMultiplier = gravityMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
public class SetRootAdsorptionAdjustment : FuncAnimPayloadBase<bool>
|
||||
{
|
||||
[InfoBox("这个payload只能在运行时由代码调用,不能直接放在动画事件里使用")]
|
||||
private CharacterBase executor => runtimeFuncAnim.executor;
|
||||
private CharacterBase target;
|
||||
private float enableMinDistance;
|
||||
|
||||
@@ -28,12 +27,12 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
|
||||
bool Adsorption()
|
||||
{
|
||||
if (target == null || executor == null)
|
||||
if (target == null || character == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 centerPointPosition = executor.flexibleCenterPoint.position;
|
||||
Vector3 centerPointPosition = character.flexibleCenterPoint.position;
|
||||
Vector3 adsorptionVector;
|
||||
|
||||
/*if (target.collisionController.mainCollider.enabled)
|
||||
@@ -54,7 +53,7 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
|
||||
if (adsorptionVector.magnitude <= enableMinDistance)
|
||||
{
|
||||
executor.animationSc.isDisablingMoveXZ = true;
|
||||
character.animationSc.isDisablingMoveXZ = true;
|
||||
return true; //已经在攻击范围内
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
|
||||
public override void Invoke()
|
||||
{
|
||||
VFXObject vfxObject = runtimeFuncAnim.executor.vfxData.SpawnVFX(vfxKey).GetComponent<VFXObject>();
|
||||
VFXObject vfxObject = character.vfxData.SpawnVFX(vfxKey).GetComponent<VFXObject>();
|
||||
if (vfxObject != null)
|
||||
{
|
||||
vfxObject.SetCreator(runtimeFuncAnim.executor);
|
||||
vfxObject.SetCreator(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
{
|
||||
if (!advancedSettings)
|
||||
{
|
||||
runtimeFuncAnim.executor.animationSc.fullBodyFuncAnimSm.Play(animationName);
|
||||
character.animationSc.fullBodyFuncAnimSm.Play(animationName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -36,14 +36,14 @@ namespace Cielonos.MainGame.FunctionalAnimation
|
||||
{
|
||||
if (character.movementSc.groundDetector.DetectGround())
|
||||
{
|
||||
runtimeFuncAnim.executor.animationSc.fullBodyFuncAnimSm.Play(animationName);
|
||||
character.animationSc.fullBodyFuncAnimSm.Play(animationName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (character.movementSc.groundDetector.DetectGround(overrideGroundDetectionLength))
|
||||
{
|
||||
runtimeFuncAnim.executor.animationSc.fullBodyFuncAnimSm.Play(animationName);
|
||||
character.animationSc.fullBodyFuncAnimSm.Play(animationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user