// Animancer // https://kybernetik.com.au/animancer // Copyright 2022 Kybernetik //
namespace Animancer
{
/// Interface for objects that can be copied.
/// https://kybernetik.com.au/animancer/api/Animancer/ICopyable_1
///
public interface ICopyable
{
/************************************************************************************************************************/
/// Copies the contents of `copyFrom` into this object, replacing its previous contents.
/// uses this method internally.
void CopyFrom(T copyFrom);
/************************************************************************************************************************/
}
/// https://kybernetik.com.au/animancer/api/Animancer/AnimancerUtilities
public static partial class AnimancerUtilities
{
/************************************************************************************************************************/
/// Creates a new and calls on it.
public static T Clone(this T original) where T : class, ICopyable, new()
{
if (original == null)
return null;
var clone = new T();
clone.CopyFrom(original);
return clone;
}
/************************************************************************************************************************/
}
}