mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Code was changed so that time starts at tick zero, and all entities are initialized in the space between tick 0 to 1. This was a solution to the fact fromSequence was including entities with lastStateUpdate tick one less than the actual sequence number. This is purely an issue about when exactly the game does its logic relative to the tick signals, ie positive or negative edge of the tick. Right now the game is set up to run the game logic on the positive edge of a Tick (enforced by GameLoop). The second big part is that an empty collection takes 5ish bytes more than a null collection in the NetSerializer, even though they are conceptually the same thing in a game state. This PR puts null checks around everything and allows GameStates to have whole sections of itself null. This reduced the payload size of an empty game state from 49B to 15B. This PR also fixes the bug where the physics system marks every movable entity as dirty every tick.
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using NUnit.Framework.Constraints;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.UnitTesting
|
|
{
|
|
public class ApproxEqualityConstraint : Constraint
|
|
{
|
|
public object Expected { get; }
|
|
public double? Tolerance { get; }
|
|
|
|
public ApproxEqualityConstraint(object expected, double? tolerance = null)
|
|
{
|
|
Expected = expected;
|
|
Tolerance = tolerance;
|
|
}
|
|
|
|
public override ConstraintResult ApplyTo<TActual>(TActual actual)
|
|
{
|
|
if (!(Expected is IApproxEquatable<TActual> equatable))
|
|
{
|
|
if (Expected is float f1 && actual is float f2)
|
|
{
|
|
if (Tolerance != null)
|
|
{
|
|
return new ConstraintResult(this, actual, FloatMath.CloseTo(f1, f2, Tolerance.Value));
|
|
}
|
|
|
|
return new ConstraintResult(this, actual, FloatMath.CloseTo(f1, f2));
|
|
}
|
|
|
|
if (Expected is double d1 && actual is float d2)
|
|
{
|
|
if (Tolerance != null)
|
|
{
|
|
return new ConstraintResult(this, actual, FloatMath.CloseTo(d1, d2, Tolerance.Value));
|
|
}
|
|
|
|
return new ConstraintResult(this, actual, FloatMath.CloseTo(d1, d2));
|
|
}
|
|
|
|
return new ConstraintResult(this, actual, false);
|
|
}
|
|
|
|
if (Tolerance != null)
|
|
{
|
|
return new ConstraintResult(this, actual, equatable.EqualsApprox(actual, Tolerance.Value));
|
|
}
|
|
else
|
|
{
|
|
return new ConstraintResult(this, actual, equatable.EqualsApprox(actual));
|
|
}
|
|
}
|
|
|
|
public override string Description => $"approximately {Expected}";
|
|
}
|
|
}
|