// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2023 Kybernetik //
using UnityEngine;
namespace Animancer
{
/// An object with an and .
/// https://kybernetik.com.au/animancer/api/Animancer/IMotion
///
public interface IMotion
{
/************************************************************************************************************************/
/// The initial that the created state will have.
/// The actual average can vary in states like .
float AverageAngularSpeed { get; }
/// The initial that the created state will have.
/// The actual average can vary in states like .
Vector3 AverageVelocity { get; }
/************************************************************************************************************************/
}
/// https://kybernetik.com.au/animancer/api/Animancer/AnimancerUtilities
public static partial class AnimancerUtilities
{
/************************************************************************************************************************/
/// Outputs the or .
/// Returns false if the `motion` is null or an unsupported type.
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;
}
}
/************************************************************************************************************************/
/// Outputs the or .
/// Returns false if the `motion` is null or an unsupported type.
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;
}
}
/************************************************************************************************************************/
}
}