encompass-cs/encompass-cs/TimeDilationData.cs

35 lines
1.1 KiB
C#

namespace Encompass
{
internal struct TimeDilationData
{
public double elapsedTime;
public double easeInTime;
public System.Func<double, double, double, double, double> easeInFunction;
public double activeTime;
public double easeOutTime;
public System.Func<double, double, double, double, double> easeOutFunction;
public double factor;
public double Factor
{
get
{
if (elapsedTime < easeInTime)
{
return easeInFunction(elapsedTime, 1, factor - 1, easeInTime);
}
else if (elapsedTime < easeInTime + activeTime)
{
return factor;
}
else if (elapsedTime < easeInTime + activeTime + easeOutTime)
{
var elapsedOutTime = elapsedTime - easeInTime - activeTime;
return easeOutFunction(elapsedOutTime, factor, 1 - factor, easeOutTime);
}
return 1;
}
}
}
}