refactor: timer methods names cleaned up

This commit is contained in:
Syntriax 2025-04-06 17:26:57 +03:00
parent 98c9dde98a
commit 6f425776cc
6 changed files with 27 additions and 27 deletions

View File

@ -2,9 +2,9 @@ namespace Syntriax.Engine.Systems.Time;
public interface IStopwatch : IReadOnlyStopwatch public interface IStopwatch : IReadOnlyStopwatch
{ {
void StopwatchStart(); void Start();
void StopwatchStop(); void Stop();
void StopwatchPause(); void Pause();
void StopwatchResume(); void Resume();
} }

View File

@ -5,7 +5,7 @@ public interface ITicker : IStopwatch
event TickerTickEventHandler? OnTick; event TickerTickEventHandler? OnTick;
int TickCounter { get; } int TickCounter { get; }
double TickPeriod { get; set; } double Period { get; set; }
delegate void TickerTickEventHandler(ITicker sender); delegate void TickerTickEventHandler(ITicker sender);
} }

View File

@ -2,9 +2,9 @@ namespace Syntriax.Engine.Systems.Time;
public interface ITimer : IReadOnlyTimer public interface ITimer : IReadOnlyTimer
{ {
void TimerStart(double time); void Start(double time);
void TimerStop(); void Stop();
void TimerPause(); void Pause();
void TimerResume(); void Resume();
} }

View File

@ -17,7 +17,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
private bool shouldBeTicking = false; private bool shouldBeTicking = false;
private bool hasStartedTickingBefore = false; private bool hasStartedTickingBefore = false;
public virtual void StopwatchStart() public virtual void Start()
{ {
Time = 0f; Time = 0f;
@ -28,7 +28,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
StartStopwatch(); StartStopwatch();
} }
public virtual void StopwatchStop() public virtual void Stop()
{ {
if (!shouldBeTicking) if (!shouldBeTicking)
return; return;
@ -56,7 +56,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
return; return;
if (hasStartedTickingBefore) if (hasStartedTickingBefore)
StopwatchResume(); Resume();
else else
StartStopwatch(); StartStopwatch();
} }
@ -66,16 +66,16 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
if (!shouldBeTicking || State is not TimerState.Ticking) if (!shouldBeTicking || State is not TimerState.Ticking)
return; return;
StopwatchPause(); Pause();
} }
public virtual void StopwatchPause() public virtual void Pause()
{ {
State = TimerState.Paused; State = TimerState.Paused;
OnPaused?.Invoke(this); OnPaused?.Invoke(this);
} }
public virtual void StopwatchResume() public virtual void Resume()
{ {
State = TimerState.Ticking; State = TimerState.Ticking;
OnResumed?.Invoke(this); OnResumed?.Invoke(this);

View File

@ -4,16 +4,16 @@ public class TickerBehaviour : StopwatchBehaviour, ITicker
{ {
public event ITicker.TickerTickEventHandler? OnTick = null; 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; public int TickCounter { get; private set; } = 0;
private double nextTick = 0f; private double nextTick = 0f;
public override void StopwatchStart() public override void Start()
{ {
TickCounter = 0; TickCounter = 0;
base.StopwatchStart(); base.Start();
nextTick = Time + TickPeriod; nextTick = Time + Period;
} }
protected override void OnUpdate() protected override void OnUpdate()
@ -23,7 +23,7 @@ public class TickerBehaviour : StopwatchBehaviour, ITicker
if (Time < nextTick) if (Time < nextTick)
return; return;
nextTick += TickPeriod; nextTick += Period;
TickCounter++; TickCounter++;
OnTick?.Invoke(this); OnTick?.Invoke(this);
} }

View File

@ -31,7 +31,7 @@ public class TimerBehaviour : Behaviour, ITimer
private bool shouldBeTicking = false; private bool shouldBeTicking = false;
private bool hasStartedTickingBefore = false; private bool hasStartedTickingBefore = false;
public virtual void TimerStart(double time) public virtual void Start(double time)
{ {
StartTime = time; StartTime = time;
Remaining = time; Remaining = time;
@ -43,7 +43,7 @@ public class TimerBehaviour : Behaviour, ITimer
StartTimer(); StartTimer();
} }
public virtual void TimerStop() public virtual void Stop()
{ {
if (!shouldBeTicking) if (!shouldBeTicking)
return; return;
@ -65,7 +65,7 @@ public class TimerBehaviour : Behaviour, ITimer
OnDelta?.Invoke(this, delta); OnDelta?.Invoke(this, delta);
if (Remaining <= .0f) if (Remaining <= .0f)
TimerStop(); Stop();
} }
protected override void OnEnteredHierarchy(IGameManager gameManager) protected override void OnEnteredHierarchy(IGameManager gameManager)
@ -74,7 +74,7 @@ public class TimerBehaviour : Behaviour, ITimer
return; return;
if (hasStartedTickingBefore) if (hasStartedTickingBefore)
TimerResume(); Resume();
else else
StartTimer(); StartTimer();
} }
@ -84,16 +84,16 @@ public class TimerBehaviour : Behaviour, ITimer
if (!shouldBeTicking || State is not TimerState.Ticking) if (!shouldBeTicking || State is not TimerState.Ticking)
return; return;
TimerPause(); Pause();
} }
public virtual void TimerPause() public virtual void Pause()
{ {
State = TimerState.Paused; State = TimerState.Paused;
OnPaused?.Invoke(this); OnPaused?.Invoke(this);
} }
public virtual void TimerResume() public virtual void Resume()
{ {
State = TimerState.Ticking; State = TimerState.Ticking;
OnResumed?.Invoke(this); OnResumed?.Invoke(this);