use modular initing system rather than calling Init() method.

This commit is contained in:
Youmu Liu
2025-11-11 18:22:28 +08:00
parent 678a846e54
commit 44bf78b937
65 changed files with 1328 additions and 1814 deletions
+17 -12
View File
@@ -27,6 +27,7 @@
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Timing
@@ -53,24 +54,31 @@ namespace StgSharp.Timing
public virtual bool IsComplete
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider.CurrentSecond > _ending;
}
public Func<float, float> TimeRelatedCalculation
{
get { return _timeRelatedCalculation; }
set { _timeRelatedCalculation = value; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeRelatedCalculation;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => _timeRelatedCalculation = value;
}
public static TimeFunction One
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => new TimeFunctionOne();
}
public TimeSpanProvider TimeSpanProvider
{
get { return _timeProvider; }
set { _timeProvider = value; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => _timeProvider = value;
}
public virtual float Calculate()
@@ -96,7 +104,7 @@ namespace StgSharp.Timing
return new TimeFunction(_timeProvider, func, range);
}
public void Reset()
public virtual void Reset()
{
float range = _ending - _beginning;
_beginning = _timeProvider.CurrentSecond;
@@ -117,10 +125,7 @@ namespace StgSharp.Timing
internal TimeFunctionOne() : base() { }
public override bool IsComplete
{
get => true;
}
public override bool IsComplete => true;
public override float Calculate()
{
@@ -138,9 +143,9 @@ namespace StgSharp.Timing
}
#pragma warning disable CA1822
public new void Reset()
public override void Reset()
{
}
#pragma warning restore CA1822
{ }
}
}