Fixes warnings

This commit is contained in:
wrexbe
2022-01-17 13:27:35 -08:00
parent 14d52a9da9
commit 0538e89948
8 changed files with 29 additions and 18 deletions

View File

@@ -207,7 +207,7 @@ namespace Robust.Client.Debugging
const float AlphaModifier = 0.2f;
foreach (var fixture in physBody.Fixtures)
foreach (var fixture in _entityManager.GetComponent<FixturesComponent>(physBody.Owner).Fixtures.Values)
{
// Invalid shape - Box2D doesn't check for IsSensor
if (physBody.BodyType == BodyType.Dynamic && fixture.Mass == 0f)
@@ -274,7 +274,7 @@ namespace Robust.Client.Debugging
const float AlphaModifier = 0.2f;
Box2? aabb = null;
foreach (var fixture in physBody.Fixtures)
foreach (var fixture in _entityManager.GetComponent<FixturesComponent>(physBody.Owner).Fixtures.Values)
{
for (var i = 0; i < fixture.Shape.ChildCount; i++)
{

View File

@@ -319,24 +319,19 @@ namespace Robust.Server.Console.Commands
// TODO: Box2D just derefs, bleh shape structs someday
var shape1 = new PolygonShape();
shape1.SetAsBox(0.5f, 10.0f, new Vector2(10.0f, 0.0f), 0.0f);
broadphaseSystem.CreateFixture(body, shape1, 20.0f);
broadphaseSystem.CreateFixture(body, shape1, 20.0f, 2, 0);
var shape2 = new PolygonShape();
shape2.SetAsBox(0.5f, 10.0f, new Vector2(-10.0f, 0.0f), 0f);
broadphaseSystem.CreateFixture(body, shape2, 20.0f);
broadphaseSystem.CreateFixture(body, shape2, 20.0f, 2, 0);
var shape3 = new PolygonShape();
shape3.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, 10.0f), 0f);
broadphaseSystem.CreateFixture(body, shape3, 20.0f);
broadphaseSystem.CreateFixture(body, shape3, 20.0f, 2, 0);
var shape4 = new PolygonShape();
shape4.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, -10.0f), 0f);
broadphaseSystem.CreateFixture(body, shape4, 20.0f);
foreach (var fixture in body.Fixtures)
{
fixture.CollisionLayer = 2;
}
broadphaseSystem.CreateFixture(body, shape4, 20.0f, 2, 0);
var revolute = EntitySystem.Get<SharedJointSystem>().CreateRevoluteJoint(groundUid, bodyUid);
revolute.LocalAnchorA = new Vector2(0f, 10f);
@@ -363,9 +358,7 @@ namespace Robust.Server.Console.Commands
box.FixedRotation = false;
var shape = new PolygonShape();
shape.SetAsBox(0.125f, 0.125f);
broadphaseSystem.CreateFixture(box, shape, 0.0625f);
box.Fixtures[0].CollisionMask = 2;
box.Fixtures[0].CollisionLayer = 2;
broadphaseSystem.CreateFixture(box, shape, 0.0625f, 2, 2);
});
}
}

View File

@@ -79,10 +79,13 @@ namespace Robust.Server.ServerStatus
public event Action<JsonNode>? OnInfoRequest;
// TODO: Remove at some point in the future
#pragma warning disable CS0618 // Uses the obsolete StatusHostHandler. Exists for backwards compatibility
public void AddHandler(StatusHostHandler handler)
{
_handlers.Add((ctx) => Task.FromResult(handler(ctx)));
}
#pragma warning restore CS0618
public void AddHandler(StatusHostHandlerAsync handler)
{

View File

@@ -306,7 +306,7 @@ namespace Robust.Shared.GameObjects
var bounds = new Box2(transform.Position, transform.Position);
foreach (var fixture in Fixtures)
foreach (var fixture in _entMan.GetComponent<FixturesComponent>(Owner).Fixtures.Values)
{
for (var i = 0; i < fixture.Shape.ChildCount; i++)
{

View File

@@ -293,7 +293,7 @@ namespace Robust.Shared.GameObjects
{
if (component == null) throw new ArgumentNullException(nameof(component));
if (component.Owner == null || component.Owner != uid)
if (component.Owner != uid)
throw new InvalidOperationException("Component is not owned by entity.");
RemoveComponentImmediate((Component)component, uid, false);

View File

@@ -146,6 +146,20 @@ namespace Robust.Shared.Physics
CreateFixture(body, fixture);
}
/// <summary>
/// Creates a <see cref="Fixture"/> from this shape and adds it to the specified <see cref="PhysicsComponent"/> with mass.
/// </summary>
public void CreateFixture(PhysicsComponent body, IPhysShape shape, float mass, int collisionLayer, int collisionMask)
{
// TODO: Make it take in density instead?
var fixture = new Fixture(body, shape) {
Mass = mass,
CollisionLayer = collisionLayer,
CollisionMask = collisionMask
};
CreateFixture(body, fixture);
}
/// <summary>
/// Attempts to get the <see cref="Fixture"/> with the specified ID for this body.
/// </summary>

View File

@@ -485,7 +485,7 @@ namespace Robust.Shared.Physics
{
var mapId = EntityManager.GetComponent<TransformComponent>(body.Owner).MapID;
foreach (var fixture in body.Fixtures)
foreach (var fixture in EntityManager.GetComponent<FixturesComponent>(body.Owner).Fixtures.Values)
{
TouchProxies(mapId, broadphase, fixture);
}

View File

@@ -51,7 +51,8 @@ namespace Robust.UnitTesting
{
// Only used for ILVerify, not necessary.
}
#pragma warning disable CS0067 // Needed by interface
public event ExtraModuleLoad? ExtraModuleLoaders;
#pragma warning restore CS0067
}
}