refactor: timer methods names cleaned up
This commit is contained in:
parent
98c9dde98a
commit
6f425776cc
@ -2,9 +2,9 @@ namespace Syntriax.Engine.Systems.Time;
|
||||
|
||||
public interface IStopwatch : IReadOnlyStopwatch
|
||||
{
|
||||
void StopwatchStart();
|
||||
void StopwatchStop();
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
void StopwatchPause();
|
||||
void StopwatchResume();
|
||||
void Pause();
|
||||
void Resume();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ public interface ITicker : IStopwatch
|
||||
event TickerTickEventHandler? OnTick;
|
||||
|
||||
int TickCounter { get; }
|
||||
double TickPeriod { get; set; }
|
||||
double Period { get; set; }
|
||||
|
||||
delegate void TickerTickEventHandler(ITicker sender);
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ namespace Syntriax.Engine.Systems.Time;
|
||||
|
||||
public interface ITimer : IReadOnlyTimer
|
||||
{
|
||||
void TimerStart(double time);
|
||||
void TimerStop();
|
||||
void Start(double time);
|
||||
void Stop();
|
||||
|
||||
void TimerPause();
|
||||
void TimerResume();
|
||||
void Pause();
|
||||
void Resume();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
private bool shouldBeTicking = false;
|
||||
private bool hasStartedTickingBefore = false;
|
||||
|
||||
public virtual void StopwatchStart()
|
||||
public virtual void Start()
|
||||
{
|
||||
Time = 0f;
|
||||
|
||||
@ -28,7 +28,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
StartStopwatch();
|
||||
}
|
||||
|
||||
public virtual void StopwatchStop()
|
||||
public virtual void Stop()
|
||||
{
|
||||
if (!shouldBeTicking)
|
||||
return;
|
||||
@ -56,7 +56,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
return;
|
||||
|
||||
if (hasStartedTickingBefore)
|
||||
StopwatchResume();
|
||||
Resume();
|
||||
else
|
||||
StartStopwatch();
|
||||
}
|
||||
@ -66,16 +66,16 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
if (!shouldBeTicking || State is not TimerState.Ticking)
|
||||
return;
|
||||
|
||||
StopwatchPause();
|
||||
Pause();
|
||||
}
|
||||
|
||||
public virtual void StopwatchPause()
|
||||
public virtual void Pause()
|
||||
{
|
||||
State = TimerState.Paused;
|
||||
OnPaused?.Invoke(this);
|
||||
}
|
||||
|
||||
public virtual void StopwatchResume()
|
||||
public virtual void Resume()
|
||||
{
|
||||
State = TimerState.Ticking;
|
||||
OnResumed?.Invoke(this);
|
||||
|
@ -4,16 +4,16 @@ public class TickerBehaviour : StopwatchBehaviour, ITicker
|
||||
{
|
||||
public event ITicker.TickerTickEventHandler? OnTick = null;
|
||||
|
||||
public double TickPeriod { get; set; } = 1f;
|
||||
public double Period { get; set; } = 1f;
|
||||
public int TickCounter { get; private set; } = 0;
|
||||
|
||||
private double nextTick = 0f;
|
||||
|
||||
public override void StopwatchStart()
|
||||
public override void Start()
|
||||
{
|
||||
TickCounter = 0;
|
||||
base.StopwatchStart();
|
||||
nextTick = Time + TickPeriod;
|
||||
base.Start();
|
||||
nextTick = Time + Period;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
@ -23,7 +23,7 @@ public class TickerBehaviour : StopwatchBehaviour, ITicker
|
||||
if (Time < nextTick)
|
||||
return;
|
||||
|
||||
nextTick += TickPeriod;
|
||||
nextTick += Period;
|
||||
TickCounter++;
|
||||
OnTick?.Invoke(this);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
private bool shouldBeTicking = false;
|
||||
private bool hasStartedTickingBefore = false;
|
||||
|
||||
public virtual void TimerStart(double time)
|
||||
public virtual void Start(double time)
|
||||
{
|
||||
StartTime = time;
|
||||
Remaining = time;
|
||||
@ -43,7 +43,7 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
public virtual void TimerStop()
|
||||
public virtual void Stop()
|
||||
{
|
||||
if (!shouldBeTicking)
|
||||
return;
|
||||
@ -65,7 +65,7 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
OnDelta?.Invoke(this, delta);
|
||||
|
||||
if (Remaining <= .0f)
|
||||
TimerStop();
|
||||
Stop();
|
||||
}
|
||||
|
||||
protected override void OnEnteredHierarchy(IGameManager gameManager)
|
||||
@ -74,7 +74,7 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
return;
|
||||
|
||||
if (hasStartedTickingBefore)
|
||||
TimerResume();
|
||||
Resume();
|
||||
else
|
||||
StartTimer();
|
||||
}
|
||||
@ -84,16 +84,16 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
if (!shouldBeTicking || State is not TimerState.Ticking)
|
||||
return;
|
||||
|
||||
TimerPause();
|
||||
Pause();
|
||||
}
|
||||
|
||||
public virtual void TimerPause()
|
||||
public virtual void Pause()
|
||||
{
|
||||
State = TimerState.Paused;
|
||||
OnPaused?.Invoke(this);
|
||||
}
|
||||
|
||||
public virtual void TimerResume()
|
||||
public virtual void Resume()
|
||||
{
|
||||
State = TimerState.Ticking;
|
||||
OnResumed?.Invoke(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user