Files
Cielonos/Assets/Scripts/MainGame/Base/FunctionalAnimation/Payloads/SetRootMotionMultipliers.cs
SoulliesOfficial 649b7a5ddc 更新
2026-05-23 08:27:50 -04:00

57 lines
2.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using Cielonos.MainGame.Characters;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Serialization;
namespace Cielonos.MainGame.FunctionalAnimation
{
[Serializable]
public class SetRootMotionMultipliers : FuncAnimPayloadBase
{
[InfoBox("注意此Payload参与对RootMotion的修改和其它修改来源混用时需注意。")]
[Tooltip("是否设定倍数如果不设定则恢复为默认值1")]
public bool isSet;
[ShowIf("isSet")]
[Tooltip("是否从行为树参数获取突破类型")]
public bool getFromBehaviorTree;
[FormerlySerializedAs("getMultiplierFromVariableCollection")]
[ShowIf("isSet")]
[Tooltip("是否从VariableCollection里获取倍数")]
public bool getFromVariableCollection;
[HideIf("@isSet == false || getFromBehaviorTree == true || getFromVariableCollection == true")]
[Tooltip("自定义倍数")]
public Vector3 customMultiplier = Vector3.one;
public override void Invoke()
{
Vector3 multiplier = Vector3.one;
if (isSet)
{
if (getFromVariableCollection)
{
float mx = runtimeFuncAnim.runtimeVariables.GetVariable<float>("RootMotionMoveXMultiplier", 1);
float my = runtimeFuncAnim.runtimeVariables.GetVariable<float>("RootMotionMoveZMultiplier", 1);
float mz = runtimeFuncAnim.runtimeVariables.GetVariable<float>("RootMotionMoveYMultiplier", 1);
multiplier = new Vector3(mx, my, mz);
}
else if (getFromBehaviorTree)
{
BehaviorSubcontroller behaviorSc = (character as Automata)!.behaviorSc;
Vector3 btMultiplier = behaviorSc.mainBehaviorTree.GetVariable<Vector3>("RootMotionMultiplier").Value;
multiplier = btMultiplier;
}
else
{
multiplier = customMultiplier;
}
}
character.movementSc.rootMotionMultiplier = multiplier;
}
}
}