using System;
using LanLib.UpdateManager.Jobs.Internal;
namespace LanLib.UpdateManager.Jobs
{
///
/// Implement this interface and register object with to get job scheduled every frame.
///
public interface IJobUpdatable : IInitialJobDataProvider
where TData : struct, IUpdateJob
{
}
///
/// Alias for .
///
///
/// Deprecated: use instead and implement
/// in job definition to compile jobs with Burst.
///
[Obsolete("Use IJobUpdatable<> and implement IBurstUpdateJob<> in job definition instead.")]
public interface IJobUpdatable : IJobUpdatable
where TData : struct, IUpdateJob
where TJob : struct, IInternalUpdateJob
{
}
public static class IJobUpdatableExtensions
{
///
/// Shortcut for UpdateJobManager<TData>.Instance.Register().
///
///
public static void RegisterInManager(this IJobUpdatable updatable)
where TData : struct, IUpdateJob
{
UpdateJobManager.Instance.Register(updatable);
}
///
/// Shortcut for UpdateJobManager<TData>.Instance.Register(, ).
///
///
public static void RegisterInManager(this IJobUpdatable updatable, bool syncEveryFrame)
where TData : struct, IUpdateJob
{
UpdateJobManager.Instance.Register(updatable, syncEveryFrame);
}
///
/// Shortcut for UpdateJobManager<TData>.Instance.Unregister().
///
///
public static void UnregisterInManager(this IJobUpdatable updatable)
where TData : struct, IUpdateJob
{
UpdateJobManager.Instance.Unregister(updatable);
}
///
/// Shortcut for UpdateJobManager<TData>.Instance.UnregisterSynchronization().
///
///
public static void UnregisterSynchronizationInManager(this IJobUpdatable updatable)
where TData : struct, IUpdateJob
{
UpdateJobManager.Instance.UnregisterSynchronization(updatable);
}
///
/// Shortcut for UpdateJobManager<TData>.Instance.IsRegistered().
///
///
public static bool IsRegisteredInManager(this IJobUpdatable updatable)
where TData : struct, IUpdateJob
{
return UpdateJobManager.Instance.IsRegistered(updatable);
}
///
/// Shortcut for UpdateJobManager<TData>.Instance.GetData().
///
///
public static TData GetJobData(this IJobUpdatable updatable)
where TData : struct, IUpdateJob
{
return UpdateJobManager.Instance.GetData(updatable);
}
///
/// Shortcut for UpdateJobManager<TData>.Instance.SynchronizeJobDataOnce().
///
///
public static void SynchronizeJobDataOnce(this IJobUpdatable updatable)
where TData : struct, IUpdateJob
{
UpdateJobManager.Instance.SynchronizeJobDataOnce(updatable);
}
}
}