diff --git a/X10D.Unity/src/BetterBehavior.cs b/X10D.Unity/src/BetterBehavior.cs deleted file mode 100644 index 6069676..0000000 --- a/X10D.Unity/src/BetterBehavior.cs +++ /dev/null @@ -1,107 +0,0 @@ -namespace X10D.Unity -{ - using System.Diagnostics.CodeAnalysis; - using System.Threading.Tasks; - using UnityEngine; - - /// - /// Represents a class which inherits to offer wider functionality. - /// - [SuppressMessage("ReSharper", "MemberCanBePrivate.Global", Justification = "Unity property")] - [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global", Justification = "Unity property")] - [SuppressMessage("ReSharper", "SA1300", Justification = "Unity API-compliant property")] - [SuppressMessage("ReSharper", "CA2007", Justification = "Unnecessary")] - [SuppressMessage("ReSharper", "RCS1090", Justification = "Unnecessary")] - [SuppressMessage("ReSharper", "RCS1213", Justification = "Unity method")] - [SuppressMessage("ReSharper", "UnusedParameter.Global", Justification = "Override method")] - public abstract class BetterBehavior : MonoBehaviour - { - /// - /// Gets the component attached to this object. - /// - public new Transform transform { get; private set; } - - /// - /// Awake is called when the script instance is being loaded. - /// - protected virtual void Awake() - { - this.transform = this.GetComponent(); - } - - /// - /// Frame-rate independent messaging for physics calculations. - /// - /// A snapshot of timing values. - protected virtual void OnFixedUpdate(in GameTime gameTime) - { - } - - /// - /// Frame-rate independent messaging for physics calculations. - /// - /// A snapshot of timing values. - /// Returns a task representing the result of the operation. - protected virtual Task OnFixedUpdateAsync(GameTime gameTime) - { - return Task.CompletedTask; - } - - /// - /// Called once per frame, after all Update calls. - /// - /// A snapshot of timing values. - protected virtual void OnLateUpdate(in GameTime gameTime) - { - } - - /// - /// Called once per frame, after all Update calls. - /// - /// A snapshot of timing values. - /// Returns a task representing the result of the operation. - protected virtual Task OnLateUpdateAsync(GameTime gameTime) - { - return Task.CompletedTask; - } - - /// - /// Called once per frame. - /// - /// A snapshot of timing values. - protected virtual void OnUpdate(in GameTime gameTime) - { - } - - /// - /// Called once per frame. - /// - /// A snapshot of timing values. - /// Returns a task representing the result of the operation. - protected virtual Task OnUpdateAsync(GameTime gameTime) - { - return Task.CompletedTask; - } - - private async void FixedUpdate() - { - var time = GameTime.CreateFromCurrentTimes(); - this.OnFixedUpdate(time); - await this.OnFixedUpdateAsync(time); - } - - private async void LateUpdate() - { - var time = GameTime.CreateFromCurrentTimes(); - this.OnLateUpdate(time); - await this.OnLateUpdateAsync(time); - } - - private async void Update() - { - var time = GameTime.CreateFromCurrentTimes(); - this.OnUpdate(time); - await this.OnUpdateAsync(time); - } - } -} diff --git a/X10D.Unity/src/GameTime.cs b/X10D.Unity/src/GameTime.cs deleted file mode 100644 index f59a6df..0000000 --- a/X10D.Unity/src/GameTime.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace X10D.Unity -{ - using System; - using UnityEngine; - - /// - /// Represents a struct which contains game timing information. - /// - public readonly struct GameTime - { - private GameTime(float totalTime, float deltaTime, float fixedDeltaTime, int frameCount, float timeScale) - { - this.TotalTime = TimeSpan.FromSeconds(totalTime); - this.DeltaTime = TimeSpan.FromSeconds(deltaTime); - this.FixedDeltaTime = TimeSpan.FromSeconds(fixedDeltaTime); - this.FrameCount = frameCount; - this.TimeScale = timeScale; - } - - /// - /// Gets the time since the last frame was rendered. - /// - public TimeSpan DeltaTime { get; } - - /// - /// Gets the time since the last physics time step. - /// - public TimeSpan FixedDeltaTime { get; } - - /// - /// Gets the total number of frames which have been rendered. - /// - public int FrameCount { get; } - - /// - /// Gets the total time for which the game has been running. - /// - public TimeSpan TotalTime { get; } - - /// - /// Gets the time scale. - /// - public float TimeScale { get; } - - /// - /// Creates a new instance of the struct by creating a snapshot of values offered by . - /// - /// An instance of . - public static GameTime CreateFromCurrentTimes() - { - return new GameTime(Time.time, Time.deltaTime, Time.fixedDeltaTime, Time.frameCount, Time.timeScale); - } - } -}