1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using UnityEngine;
- namespace Animancer
- {
-
-
-
- public interface IMotion
- {
-
-
-
- float AverageAngularSpeed { get; }
-
-
- Vector3 AverageVelocity { get; }
-
- }
-
- public static partial class AnimancerUtilities
- {
-
-
-
- public static bool TryGetAverageAngularSpeed(object motion, out float averageAngularSpeed)
- {
- if (motion is Motion unityMotion)
- {
- averageAngularSpeed = unityMotion.averageAngularSpeed;
- return true;
- }
- else if (TryGetWrappedObject(motion, out IMotion iMotion))
- {
- averageAngularSpeed = iMotion.AverageAngularSpeed;
- return true;
- }
- else
- {
- averageAngularSpeed = default;
- return false;
- }
- }
-
-
-
- public static bool TryGetAverageVelocity(object motion, out Vector3 averageVelocity)
- {
- if (motion is Motion unityMotion)
- {
- averageVelocity = unityMotion.averageSpeed;
- return true;
- }
- else if (TryGetWrappedObject(motion, out IMotion iMotion))
- {
- averageVelocity = iMotion.AverageVelocity;
- return true;
- }
- else
- {
- averageVelocity = default;
- return false;
- }
- }
-
- }
- }
|