Moved TotalElapsedTime from GameMain to the Timing class
This commit is contained in:
@@ -101,16 +101,7 @@ namespace Barotrauma
|
|||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Total seconds elapsed after startup
|
|
||||||
/// </summary>
|
|
||||||
public double TotalElapsedTime
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameMain()
|
public GameMain()
|
||||||
{
|
{
|
||||||
GraphicsDeviceManager = new GraphicsDeviceManager(this);
|
GraphicsDeviceManager = new GraphicsDeviceManager(this);
|
||||||
@@ -300,6 +291,7 @@ namespace Barotrauma
|
|||||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||||
protected override void Update(GameTime gameTime)
|
protected override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
Timing.TotalTime = gameTime.TotalGameTime.TotalSeconds;
|
||||||
Timing.Accumulator += gameTime.ElapsedGameTime.TotalSeconds;
|
Timing.Accumulator += gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
bool paused = true;
|
bool paused = true;
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace Barotrauma.Items.Components
|
|||||||
prevPingRadius = pingRadius;
|
prevPingRadius = pingRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
float passivePingRadius = (float)Math.Sin(GameMain.Instance.TotalElapsedTime*10);
|
float passivePingRadius = (float)Math.Sin(Timing.TotalTime * 10);
|
||||||
if (passivePingRadius > 0.0f)
|
if (passivePingRadius > 0.0f)
|
||||||
{
|
{
|
||||||
foreach (AITarget t in AITarget.List)
|
foreach (AITarget t in AITarget.List)
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ namespace Barotrauma.Lights
|
|||||||
{
|
{
|
||||||
if (enabled == value) return;
|
if (enabled == value) return;
|
||||||
enabled = value;
|
enabled = value;
|
||||||
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
|
LastVertexChangeTime = (float)Timing.TotalTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ namespace Barotrauma.Lights
|
|||||||
segments[i].End.Pos += amount;
|
segments[i].End.Pos += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
|
LastVertexChangeTime = (float)Timing.TotalTime;
|
||||||
|
|
||||||
CalculateDimensions();
|
CalculateDimensions();
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ namespace Barotrauma.Lights
|
|||||||
{
|
{
|
||||||
Debug.Assert(points.Length == 4, "Only rectangular convex hulls are supported");
|
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++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -549,7 +549,7 @@ namespace Barotrauma.Lights
|
|||||||
var verts = FindRaycastHits();
|
var verts = FindRaycastHits();
|
||||||
CalculateLightVertices(verts);
|
CalculateLightVertices(verts);
|
||||||
|
|
||||||
lastRecalculationTime = (float)GameMain.Instance.TotalElapsedTime;
|
lastRecalculationTime = (float)Timing.TotalTime;
|
||||||
NeedsRecalculation = false;
|
NeedsRecalculation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
private static double alpha;
|
private static double alpha;
|
||||||
|
|
||||||
|
public static double TotalTime;
|
||||||
|
|
||||||
public static double Accumulator;
|
public static double Accumulator;
|
||||||
public static double Step = 1.0 / 60.0;
|
public static double Step = 1.0 / 60.0;
|
||||||
|
|
||||||
@@ -30,6 +32,13 @@ namespace Barotrauma
|
|||||||
return current * (float)alpha + previous * (1.0f - (float)alpha);
|
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)
|
public static Vector2 Interpolate(Vector2 previous, Vector2 current)
|
||||||
{
|
{
|
||||||
return new Vector2(
|
return new Vector2(
|
||||||
|
|||||||
Reference in New Issue
Block a user