You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
4.6 KiB
C#
100 lines
4.6 KiB
C#
using System;
|
|
using LanLib.UpdateManager.Jobs.Internal;
|
|
|
|
namespace LanLib.UpdateManager.Jobs
|
|
{
|
|
/// <summary>
|
|
/// Implement this interface and register object with <see cref="UpdateTransformJobManager{}.Register"/> to get job scheduled every frame.
|
|
/// </summary>
|
|
public interface ITransformJobUpdatable<TData> : IInitialTransformJobDataProvider<TData>
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Alias for <see cref="ITransformJobUpdatable{}"/>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Deprecated: use <see cref="ITransformJobUpdatable{}"/> instead and implement
|
|
/// <see cref="IBurstUpdateTransformJob{}"/> in job definition to compile jobs with Burst.
|
|
/// </remarks>
|
|
[Obsolete("Use ITransformJobUpdatable<> and implement IBurstUpdateTransformJob<> in job definition instead.")]
|
|
public interface ITransformJobUpdatable<TData, TJob> : ITransformJobUpdatable<TData>
|
|
where TData : struct, IUpdateTransformJob
|
|
where TJob : struct, IInternalUpdateTransformJob<TData>
|
|
{
|
|
}
|
|
|
|
public static class ITransformJobUpdatableExtensions
|
|
{
|
|
/// <summary>
|
|
/// Shortcut for <c>UpdateTransformJobManager<TData>.Instance.Register(<paramref name="updatable"/>)</c>.
|
|
/// </summary>
|
|
/// <seealso cref="UpdateTransformJobManager{}.Register"/>
|
|
public static void RegisterInManager<TData>(this ITransformJobUpdatable<TData> updatable)
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
UpdateTransformJobManager<TData>.Instance.Register(updatable);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Shortcut for <c>UpdateTransformJobManager<TData>.Instance.Register(<paramref name="updatable"/>, <paramref name="syncEveryFrame"/>)</c>.
|
|
/// </summary>
|
|
/// <seealso cref="UpdateTransformJobManager{}.Register"/>
|
|
public static void RegisterInManager<TData>(this ITransformJobUpdatable<TData> updatable, bool syncEveryFrame)
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
UpdateTransformJobManager<TData>.Instance.Register(updatable, syncEveryFrame);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Shortcut for <c>UpdateTransformJobManager<TData>.Instance.Unregister(<paramref name="updatable"/>)</c>.
|
|
/// </summary>
|
|
/// <seealso cref="UpdateTransformJobManager{}.Unregister"/>
|
|
public static void UnregisterInManager<TData>(this ITransformJobUpdatable<TData> updatable)
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
UpdateTransformJobManager<TData>.Instance.Unregister(updatable);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Shortcut for <c>UpdateTransformJobManager<TData>.Instance.UnregisterSynchronization(<paramref name="updatable"/>)</c>.
|
|
/// </summary>
|
|
/// <seealso cref="UpdateTransformJobManager{}.UnregisterSynchronization"/>
|
|
public static void UnregisterSynchronizationInManager<TData>(this ITransformJobUpdatable<TData> updatable)
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
UpdateTransformJobManager<TData>.Instance.UnregisterSynchronization(updatable);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Shortcut for <c>UpdateTransformJobManager<TData>.Instance.IsRegistered(<paramref name="updatable"/>)</c>.
|
|
/// </summary>
|
|
/// <seealso cref="UpdateTransformJobManager{}.IsRegistered"/>
|
|
public static bool IsRegisteredInManager<TData>(this ITransformJobUpdatable<TData> updatable)
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
return UpdateTransformJobManager<TData>.Instance.IsRegistered(updatable);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Shortcut for <c>UpdateTransformJobManager<TData>.Instance.GetData(<paramref name="updatable"/>)</c>.
|
|
/// </summary>
|
|
/// <seealso cref="UpdateTransformJobManager{}.GetData"/>
|
|
public static TData GetJobData<TData>(this ITransformJobUpdatable<TData> updatable)
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
return UpdateTransformJobManager<TData>.Instance.GetData(updatable);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Shortcut for <c>UpdateTransformJobManager<TData>.Instance.SynchronizeJobDataOnce(<paramref name="updatable"/>)</c>.
|
|
/// </summary>
|
|
/// <seealso cref="UpdateJobManager{}.SynchronizeJobDataOnce"/>
|
|
public static void SynchronizeJobDataOnce<TData>(this ITransformJobUpdatable<TData> updatable)
|
|
where TData : struct, IUpdateTransformJob
|
|
{
|
|
UpdateTransformJobManager<TData>.Instance.SynchronizeJobDataOnce(updatable);
|
|
}
|
|
}
|
|
} |