platformer
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Properties | List of all members
UnityPlatformer.UpdateManager Class Reference

Custom update loop. More...

Inheritance diagram for UnityPlatformer.UpdateManager:
UnityPlatformer.MBSingleton< UpdateManager >

Public Member Functions

delegate void TimeChanged (float timeScale)
 Time change callback More...
 
void OnEnable ()
 LazyInit More...
 
void FixedUpdate ()
 Run update loop More...
 

Static Public Member Functions

static long GetCurrentFrame ()
 Get current frame More...
 
static float GetFixedDeltaTime ()
 Get current delta More...
 
static int GetFrameCount (float time)
 Time to frame conversion More...
 
static bool Push (IUpdateEntity entity, int priority)
 Push a new entity to update loop More...
 
static int IndexOf (IUpdateEntity entity)
 Index of given entity in the frameListeners More...
 
static bool Remove (IUpdateEntity entity)
 Remove given entity from frameListeners More...
 
static float GetCurrentDelta ()
 Helper to get current delta, it's sent to PlatformerUpdate & LatePlatformerUpdate but could be useful if you don't want to foward it's value everywhere More...
 
static void SetTimeout (Action callback, float timeout)
 Call given callback in given timeout if timeout is <= 0, will be called now. More...
 
static void SetInterval (Action callback, float timeout)
 Call given callback in given timeout More...
 
static bool ClearTimeout (Action callback)
 Remove once given callback More...
 
static Delay GetDelay (float time)
 Create a new Delay (or reuse it) More...
 
static void DisposeDelay (Delay d)
 Mark Delay to be reused More...
 
- Static Public Member Functions inherited from UnityPlatformer.MBSingleton< UpdateManager >
static void ClearInstance ()
 This method is for testing purposes only, you should not called it in your application More...
 

Public Attributes

bool debug = false
 Create a debug UI More...
 
float forceFixedDeltaTime = 0.0f
 Ignore Unity Time.fixedDeltaTime use this value
this is meant for testing, because setting Time.fixedDeltaTime may mess your configuration More...
 
float runningTime = 0
 Time the app is running More...
 
long frame = 0
 Current frame More...
 
TimeChanged onTimeScaleChanged
 notify when time is changed More...
 
Delay [] freeDelays
 List of free delays More...
 
int freeDelaysCount = 0
 How many free delays are available More...
 
Delay [] delays
 List of Delays in use More...
 
int delaysCount = 0
 How many Delays are in use More...
 

Protected Attributes

float _timeScale = 1
 Time scale More...
 
float nextFrameTimeScale = 1
 Time Scale in the next frame
This variable is for consistency, when anybody change timeScale the change is queued until next FixedUpdate More...
 

Properties

float timeScale [get, set]
 Time Scale More...
 
- Properties inherited from UnityPlatformer.MBSingleton< UpdateManager >
static T instance [get]
 Singleton instance retrieval More...
 

Additional Inherited Members

- Static Protected Attributes inherited from UnityPlatformer.MBSingleton< UpdateManager >
static T _instance
 Singleton instance More...
 

Detailed Description

Custom update loop.

The purpose behind this class/style is to be precise about the update order of all entities.

Also handle Timeout Actions, do not use corountines.

NOTE Use a sorted array based on the priorities defined at Configuration

NOTE executionOrder should be -50

NOTE Do not call UpdateManager at Awake

Member Function Documentation

◆ ClearTimeout()

static bool UnityPlatformer.UpdateManager.ClearTimeout ( Action  callback)
inlinestatic

Remove once given callback

Returns
true if found, false if not found

◆ DisposeDelay()

static void UnityPlatformer.UpdateManager.DisposeDelay ( Delay  d)
inlinestatic

Mark Delay to be reused

◆ FixedUpdate()

void UnityPlatformer.UpdateManager.FixedUpdate ( )
inline

Run update loop

First call PlatformerUpdate
Then call LatePlatformerUpdate
NOTE FixedUpdate can be called multiple times each frame

◆ GetCurrentDelta()

static float UnityPlatformer.UpdateManager.GetCurrentDelta ( )
inlinestatic

Helper to get current delta, it's sent to PlatformerUpdate & LatePlatformerUpdate but could be useful if you don't want to foward it's value everywhere

◆ GetCurrentFrame()

static long UnityPlatformer.UpdateManager.GetCurrentFrame ( )
inlinestatic

Get current frame

◆ GetDelay()

static Delay UnityPlatformer.UpdateManager.GetDelay ( float  time)
inlinestatic

Create a new Delay (or reuse it)

◆ GetFixedDeltaTime()

static float UnityPlatformer.UpdateManager.GetFixedDeltaTime ( )
inlinestatic

Get current delta

◆ GetFrameCount()

static int UnityPlatformer.UpdateManager.GetFrameCount ( float  time)
inlinestatic

Time to frame conversion

NOTE you should listen to timeScale changes...

◆ IndexOf()

static int UnityPlatformer.UpdateManager.IndexOf ( IUpdateEntity  entity)
inlinestatic

Index of given entity in the frameListeners

>= 0 if found (index). -1 if not found

◆ OnEnable()

void UnityPlatformer.UpdateManager.OnEnable ( )
inline

LazyInit

◆ Push()

static bool UnityPlatformer.UpdateManager.Push ( IUpdateEntity  entity,
int  priority 
)
inlinestatic

Push a new entity to update loop

◆ Remove()

static bool UnityPlatformer.UpdateManager.Remove ( IUpdateEntity  entity)
inlinestatic

Remove given entity from frameListeners

If it was removed

◆ SetInterval()

static void UnityPlatformer.UpdateManager.SetInterval ( Action  callback,
float  timeout 
)
inlinestatic

Call given callback in given timeout

NOTE Do not use corountines because the can't hotswap Also corountines don't know if you modify timeScale this do.

◆ SetTimeout()

static void UnityPlatformer.UpdateManager.SetTimeout ( Action  callback,
float  timeout 
)
inlinestatic

Call given callback in given timeout if timeout is <= 0, will be called now.

NOTE Do not use corountines because the can't hotswap Also corountines don't know if you modify timeScale this do.

◆ TimeChanged()

delegate void UnityPlatformer.UpdateManager.TimeChanged ( float  timeScale)

Time change callback

Member Data Documentation

◆ _timeScale

float UnityPlatformer.UpdateManager._timeScale = 1
protected

Time scale

◆ debug

bool UnityPlatformer.UpdateManager.debug = false

Create a debug UI

◆ delays

Delay [] UnityPlatformer.UpdateManager.delays

List of Delays in use

◆ delaysCount

int UnityPlatformer.UpdateManager.delaysCount = 0

How many Delays are in use

◆ forceFixedDeltaTime

float UnityPlatformer.UpdateManager.forceFixedDeltaTime = 0.0f

Ignore Unity Time.fixedDeltaTime use this value
this is meant for testing, because setting Time.fixedDeltaTime may mess your configuration

◆ frame

long UnityPlatformer.UpdateManager.frame = 0

Current frame

◆ freeDelays

Delay [] UnityPlatformer.UpdateManager.freeDelays

List of free delays

◆ freeDelaysCount

int UnityPlatformer.UpdateManager.freeDelaysCount = 0

How many free delays are available

◆ nextFrameTimeScale

float UnityPlatformer.UpdateManager.nextFrameTimeScale = 1
protected

Time Scale in the next frame
This variable is for consistency, when anybody change timeScale the change is queued until next FixedUpdate

◆ onTimeScaleChanged

TimeChanged UnityPlatformer.UpdateManager.onTimeScaleChanged

notify when time is changed

◆ runningTime

float UnityPlatformer.UpdateManager.runningTime = 0

Time the app is running

Property Documentation

◆ timeScale

float UnityPlatformer.UpdateManager.timeScale
getset

Time Scale

1 fast motion

< 1 slow motion


The documentation for this class was generated from the following file: