2020-03-20 07:09:57 +00:00
|
|
|
using System;
|
|
|
|
|
2019-11-21 21:53:33 +00:00
|
|
|
namespace Encompass
|
|
|
|
{
|
|
|
|
internal struct TimeDilationData
|
|
|
|
{
|
2020-03-20 07:09:57 +00:00
|
|
|
private readonly double _factor;
|
2019-11-21 21:53:33 +00:00
|
|
|
|
|
|
|
public double Factor
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2020-03-20 07:09:57 +00:00
|
|
|
if (ElapsedTime < EaseInTime)
|
2019-11-21 21:53:33 +00:00
|
|
|
{
|
2020-03-20 07:09:57 +00:00
|
|
|
return EaseInFunction(ElapsedTime, 1, _factor - 1, EaseInTime);
|
2019-11-21 21:53:33 +00:00
|
|
|
}
|
2020-03-20 07:09:57 +00:00
|
|
|
else if (ElapsedTime < EaseInTime + ActiveTime)
|
2019-11-21 21:53:33 +00:00
|
|
|
{
|
2020-03-20 07:09:57 +00:00
|
|
|
return _factor;
|
2019-11-21 21:53:33 +00:00
|
|
|
}
|
2020-03-20 07:09:57 +00:00
|
|
|
else if (ElapsedTime < EaseInTime + ActiveTime + EaseOutTime)
|
2019-11-21 21:53:33 +00:00
|
|
|
{
|
2020-03-20 07:09:57 +00:00
|
|
|
var elapsedOutTime = ElapsedTime - EaseInTime - ActiveTime;
|
|
|
|
return EaseOutFunction(elapsedOutTime, _factor, 1 - _factor, EaseOutTime);
|
2019-11-21 21:53:33 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 06:32:09 +00:00
|
|
|
return 1;
|
2019-11-21 21:53:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-20 07:09:57 +00:00
|
|
|
|
|
|
|
public double ElapsedTime { get; set; }
|
|
|
|
public double EaseInTime { get; }
|
|
|
|
public Func<double, double, double, double, double> EaseInFunction { get; }
|
|
|
|
public double ActiveTime { get; }
|
|
|
|
public double EaseOutTime { get; }
|
|
|
|
public Func<double, double, double, double, double> EaseOutFunction { get; }
|
|
|
|
|
|
|
|
public TimeDilationData(
|
|
|
|
double factor,
|
|
|
|
double easeInTime,
|
|
|
|
Func<double, double, double, double, double> easeInfunction,
|
|
|
|
double activeTime,
|
|
|
|
double easeOutTime,
|
|
|
|
Func<double, double, double, double, double> easeOutFunction
|
|
|
|
)
|
|
|
|
{
|
|
|
|
_factor = factor;
|
|
|
|
EaseInTime = easeInTime;
|
|
|
|
EaseInFunction = easeInfunction;
|
|
|
|
ActiveTime = activeTime;
|
|
|
|
EaseOutTime = easeOutTime;
|
|
|
|
EaseOutFunction = easeOutFunction;
|
|
|
|
ElapsedTime = 0;
|
|
|
|
}
|
2019-11-21 21:53:33 +00:00
|
|
|
}
|
2020-03-20 07:09:57 +00:00
|
|
|
}
|