namespace Zinnia.Data.Operation.Extraction
{
using System;
using UnityEngine;
using UnityEngine.Events;
using Zinnia.Extension;
///
/// Extracts and emits the elements from .
///
public class TimeComponentExtractor : FloatExtractor
{
///
/// Defines the event with the specified .
///
[Serializable]
public class UnityEvent : UnityEvent { }
///
/// The components of
///
public enum TimeComponent
{
///
/// The time at the beginning of this frame. This is the time in seconds since the start of the game.
///
Time,
///
/// The time the latest has started. This is the time in seconds since the start of the game.
///
FixedTime,
///
/// The if in otherwise the .
///
TimeStepTypeTime,
///
/// The completion time in seconds since the last frame.
///
DeltaTime,
///
/// The interval in seconds at which physics and other fixed frame rate updates are performed.
///
FixedDeltaTime,
///
/// The if in otherwise the .
///
TimeStepTypeDeltaTime,
///
/// The timeScale-independent time for this frame. This is the time in seconds since the start of the game.
///
UnscaledTime,
///
/// The TimeScale-independent time the latest MonoBehaviour.FixedUpdate has started. This is the time in seconds since the start of the game.
///
FixedUnscaledTime,
///
/// The if in otherwise the .
///
TimeStepTypeUnscaledTime,
///
/// The timeScale-independent interval in seconds from the last frame to the current one.
///
UnscaledDeltaTime,
///
/// The timeScale-independent interval in seconds from the last fixed frame to the current one.
///
FixedUnscaledDeltaTime,
///
/// The if in otherwise the .
///
TimeStepTypeUnscaledDeltaTime,
///
/// Slows game playback time to allow screen shots to be saved between frames.
///
CaptureFrameRate,
///
/// The total number of frames that have passed.
///
FrameCount,
///
/// The maximum time a frame can take.
///
MaximumDeltaTime,
///
/// The maximum time a frame can spend on particle updates.
///
MaximumParticleDeltaTime,
///
/// The real time in seconds since the game started.
///
RealTimeSinceStartUp,
///
/// The total number of rendered frames that have passed.
///
RenderedFrameCount,
///
/// A smoothed out Time.deltaTime.
///
SmoothDeltaTime,
///
/// The scale at which the time is passing. This can be used for slow motion effects.
///
TimeScale,
///
/// The time in seconds since the last level has been loaded.
///
TimeSinceLevelLoad
}
///
/// Sets the .
///
/// The index of the .
public virtual void SetSource(int index)
{
Source = EnumExtensions.GetByIndex(index);
}
///
protected override float? ExtractValue()
{
switch (Source)
{
case TimeComponent.Time:
return Time.time;
case TimeComponent.FixedTime:
return Time.fixedTime;
case TimeComponent.TimeStepTypeTime:
return Time.inFixedTimeStep ? Time.fixedTime : Time.time;
case TimeComponent.DeltaTime:
return Time.deltaTime;
case TimeComponent.FixedDeltaTime:
return Time.fixedDeltaTime;
case TimeComponent.TimeStepTypeDeltaTime:
return Time.inFixedTimeStep ? Time.fixedDeltaTime : Time.deltaTime;
case TimeComponent.UnscaledTime:
return Time.unscaledTime;
case TimeComponent.FixedUnscaledTime:
return Time.fixedUnscaledTime;
case TimeComponent.TimeStepTypeUnscaledTime:
return Time.inFixedTimeStep ? Time.fixedUnscaledTime : Time.unscaledTime;
case TimeComponent.UnscaledDeltaTime:
return Time.unscaledDeltaTime;
case TimeComponent.FixedUnscaledDeltaTime:
return Time.fixedUnscaledDeltaTime;
case TimeComponent.TimeStepTypeUnscaledDeltaTime:
return Time.inFixedTimeStep ? Time.fixedUnscaledDeltaTime : Time.unscaledDeltaTime;
case TimeComponent.CaptureFrameRate:
return Time.captureFramerate;
case TimeComponent.FrameCount:
return Time.frameCount;
case TimeComponent.MaximumDeltaTime:
return Time.maximumDeltaTime;
case TimeComponent.MaximumParticleDeltaTime:
return Time.maximumParticleDeltaTime;
case TimeComponent.RealTimeSinceStartUp:
return Time.realtimeSinceStartup;
case TimeComponent.RenderedFrameCount:
return Time.renderedFrameCount;
case TimeComponent.SmoothDeltaTime:
return Time.smoothDeltaTime;
case TimeComponent.TimeScale:
return Time.timeScale;
case TimeComponent.TimeSinceLevelLoad:
return Time.timeSinceLevelLoad;
default:
return null;
}
}
}
}