Moved TotalElapsedTime from GameMain to the Timing class

This commit is contained in:
Regalis
2017-05-03 19:15:43 +03:00
parent ba49f59204
commit 043c2fbc5e
5 changed files with 16 additions and 15 deletions

View File

@@ -101,16 +101,7 @@ namespace Barotrauma
get;
private set;
}
/// <summary>
/// Total seconds elapsed after startup
/// </summary>
public double TotalElapsedTime
{
get;
private set;
}
public GameMain()
{
GraphicsDeviceManager = new GraphicsDeviceManager(this);
@@ -300,6 +291,7 @@ namespace Barotrauma
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
Timing.TotalTime = gameTime.TotalGameTime.TotalSeconds;
Timing.Accumulator += gameTime.ElapsedGameTime.TotalSeconds;
bool paused = true;

View File

@@ -140,7 +140,7 @@ namespace Barotrauma.Items.Components
prevPingRadius = pingRadius;
}
float passivePingRadius = (float)Math.Sin(GameMain.Instance.TotalElapsedTime*10);
float passivePingRadius = (float)Math.Sin(Timing.TotalTime * 10);
if (passivePingRadius > 0.0f)
{
foreach (AITarget t in AITarget.List)

View File

@@ -151,7 +151,7 @@ namespace Barotrauma.Lights
{
if (enabled == value) return;
enabled = value;
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
LastVertexChangeTime = (float)Timing.TotalTime;
}
}
@@ -264,7 +264,7 @@ namespace Barotrauma.Lights
segments[i].End.Pos += amount;
}
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
LastVertexChangeTime = (float)Timing.TotalTime;
CalculateDimensions();
}
@@ -273,7 +273,7 @@ namespace Barotrauma.Lights
{
Debug.Assert(points.Length == 4, "Only rectangular convex hulls are supported");
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
LastVertexChangeTime = (float)Timing.TotalTime;
for (int i = 0; i < 4; i++)
{

View File

@@ -549,7 +549,7 @@ namespace Barotrauma.Lights
var verts = FindRaycastHits();
CalculateLightVertices(verts);
lastRecalculationTime = (float)GameMain.Instance.TotalElapsedTime;
lastRecalculationTime = (float)Timing.TotalTime;
NeedsRecalculation = false;
}

View File

@@ -11,6 +11,8 @@ namespace Barotrauma
{
private static double alpha;
public static double TotalTime;
public static double Accumulator;
public static double Step = 1.0 / 60.0;
@@ -30,6 +32,13 @@ namespace Barotrauma
return current * (float)alpha + previous * (1.0f - (float)alpha);
}
public static float InterpolateRotation(float previous, float current)
{
float angleDiff = MathUtils.GetShortestAngle(previous, current);
return previous + angleDiff * (float)alpha;
}
public static Vector2 Interpolate(Vector2 previous, Vector2 current)
{
return new Vector2(