Content update for ECS physics (#13291)
This commit is contained in:
@@ -77,12 +77,9 @@ namespace Content.Server.Physics.Controllers
|
||||
var shape = new PolygonShape();
|
||||
shape.SetAsBox(0.55f, 0.55f);
|
||||
|
||||
_fixtures.TryCreateFixture(body, new Fixture(body, shape)
|
||||
{
|
||||
ID = ConveyorFixture,
|
||||
CollisionLayer = (int) (CollisionGroup.LowImpassable | CollisionGroup.MidImpassable | CollisionGroup.Impassable),
|
||||
Hard = false,
|
||||
});
|
||||
_fixtures.TryCreateFixture(uid, shape, ConveyorFixture, hard: false,
|
||||
collisionLayer: (int) (CollisionGroup.LowImpassable | CollisionGroup.MidImpassable |
|
||||
CollisionGroup.Impassable), body: body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +157,7 @@ namespace Content.Server.Physics.Controllers
|
||||
continue;
|
||||
|
||||
if (physics.BodyType != BodyType.Static)
|
||||
_physics.WakeBody(physics);
|
||||
_physics.WakeBody(entity, body: physics);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +177,7 @@ namespace Content.Server.Physics.Controllers
|
||||
if (!TryComp<PhysicsComponent>(uid, out var body))
|
||||
return;
|
||||
|
||||
_fixtures.DestroyFixture(body, ConveyorFixture);
|
||||
_fixtures.DestroyFixture(uid, ConveyorFixture, body: body);
|
||||
}
|
||||
|
||||
public override void UpdateBeforeSolve(bool prediction, float frameTime)
|
||||
@@ -237,8 +234,9 @@ namespace Content.Server.Physics.Controllers
|
||||
transform.LocalPosition = localPos;
|
||||
|
||||
// Force it awake for collisionwake reasons.
|
||||
body.Awake = true;
|
||||
body.SleepTime = 0f;
|
||||
// TODO: Just use sleepallowed
|
||||
_physics.SetAwake(entity, body, true);
|
||||
_physics.SetSleepTime(body, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Physics.Controllers
|
||||
@@ -399,7 +400,7 @@ namespace Content.Server.Physics.Controllers
|
||||
impulse.Y = MathF.Max(impulse.Y, -shuttleVelocity.Y);
|
||||
}
|
||||
|
||||
PhysicsSystem.SetLinearVelocity(body, body.LinearVelocity + shuttleNorthAngle.RotateVec(impulse));
|
||||
PhysicsSystem.SetLinearVelocity(shuttle.Owner, body.LinearVelocity + shuttleNorthAngle.RotateVec(impulse), body: body);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -432,7 +433,7 @@ namespace Content.Server.Physics.Controllers
|
||||
else if (body.AngularVelocity > 0f && body.AngularVelocity + accelSpeed < 0f)
|
||||
accelSpeed = -body.AngularVelocity;
|
||||
|
||||
PhysicsSystem.SetAngularVelocity(body, body.AngularVelocity + accelSpeed);
|
||||
PhysicsSystem.SetAngularVelocity(shuttle.Owner, body.AngularVelocity + accelSpeed, body: body);
|
||||
_thruster.SetAngularThrust(shuttle, true);
|
||||
}
|
||||
}
|
||||
@@ -440,19 +441,19 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
if (linearInput.Length.Equals(0f))
|
||||
{
|
||||
body.SleepingAllowed = true;
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, true);
|
||||
|
||||
if (brakeInput.Equals(0f))
|
||||
_thruster.DisableLinearThrusters(shuttle);
|
||||
|
||||
if (body.LinearVelocity.Length < 0.08)
|
||||
{
|
||||
body.LinearVelocity = Vector2.Zero;
|
||||
PhysicsSystem.SetLinearVelocity(shuttle.Owner, Vector2.Zero, body: body);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
body.SleepingAllowed = false;
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, false);
|
||||
var angle = linearInput.ToWorldAngle();
|
||||
var linearDir = angle.GetDir();
|
||||
var dockFlag = linearDir.AsFlag();
|
||||
@@ -519,23 +520,23 @@ namespace Content.Server.Physics.Controllers
|
||||
{
|
||||
var accelSpeed = totalForce.Length * frameTime;
|
||||
accelSpeed = MathF.Min(accelSpeed, addSpeed);
|
||||
body.ApplyLinearImpulse(shuttleNorthAngle.RotateVec(totalForce.Normalized * accelSpeed));
|
||||
PhysicsSystem.ApplyLinearImpulse(shuttle.Owner, shuttleNorthAngle.RotateVec(totalForce.Normalized * accelSpeed), body: body);
|
||||
}
|
||||
}
|
||||
|
||||
if (MathHelper.CloseTo(angularInput, 0f))
|
||||
{
|
||||
_thruster.SetAngularThrust(shuttle, false);
|
||||
body.SleepingAllowed = true;
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, true);
|
||||
|
||||
if (Math.Abs(body.AngularVelocity) < 0.01f)
|
||||
{
|
||||
body.AngularVelocity = 0f;
|
||||
PhysicsSystem.SetAngularVelocity(shuttle.Owner, 0f, body: body);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
body.SleepingAllowed = false;
|
||||
PhysicsSystem.SetSleepingAllowed(shuttle.Owner, body, false);
|
||||
var impulse = shuttle.AngularThrust * -angularInput;
|
||||
var wishSpeed = MathF.PI;
|
||||
|
||||
@@ -554,7 +555,7 @@ namespace Content.Server.Physics.Controllers
|
||||
else
|
||||
accelSpeed = MathF.Min(accelSpeed, addSpeed);
|
||||
|
||||
PhysicsSystem.SetAngularVelocity(body, body.AngularVelocity + accelSpeed);
|
||||
PhysicsSystem.SetAngularVelocity(shuttle.Owner, body.AngularVelocity + accelSpeed, body: body);
|
||||
_thruster.SetAngularThrust(shuttle, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Content.Server.Physics.Controllers
|
||||
return;
|
||||
|
||||
if (TryComp<PhysicsComponent>(pullable.Owner, out var physics))
|
||||
physics.WakeBody();
|
||||
PhysicsSystem.WakeBody(pullable.Owner, body: physics);
|
||||
|
||||
_pullableSystem.StopMoveTo(pullable);
|
||||
}
|
||||
@@ -164,9 +164,9 @@ namespace Content.Server.Physics.Controllers
|
||||
var diff = movingPosition - ownerPosition;
|
||||
var diffLength = diff.Length;
|
||||
|
||||
if ((diffLength < MaximumSettleDistance) && (physics.LinearVelocity.Length < MaximumSettleVelocity))
|
||||
if (diffLength < MaximumSettleDistance && (physics.LinearVelocity.Length < MaximumSettleVelocity))
|
||||
{
|
||||
physics.LinearVelocity = Vector2.Zero;
|
||||
PhysicsSystem.SetLinearVelocity(pullable.Owner, Vector2.Zero, body: physics);
|
||||
_pullableSystem.StopMoveTo(pullable);
|
||||
continue;
|
||||
}
|
||||
@@ -183,9 +183,11 @@ namespace Content.Server.Physics.Controllers
|
||||
var scaling = (SettleShutdownDistance - diffLength) / SettleShutdownDistance;
|
||||
accel -= physics.LinearVelocity * SettleShutdownMultiplier * scaling;
|
||||
}
|
||||
physics.WakeBody();
|
||||
|
||||
PhysicsSystem.WakeBody(pullable.Owner, body: physics);
|
||||
|
||||
var impulse = accel * physics.Mass * frameTime;
|
||||
physics.ApplyLinearImpulse(impulse);
|
||||
PhysicsSystem.ApplyLinearImpulse(pullable.Owner, impulse, body: physics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ internal sealed class RandomWalkController : VirtualController
|
||||
var pushAngle = _random.NextAngle();
|
||||
var pushStrength = _random.NextFloat(randomWalk.MinSpeed, randomWalk.MaxSpeed);
|
||||
|
||||
_physics.SetLinearVelocity(physics, physics.LinearVelocity * randomWalk.AccumulatorRatio);
|
||||
_physics.ApplyLinearImpulse(physics, pushAngle.ToVec() * (pushStrength * physics.Mass));
|
||||
_physics.SetLinearVelocity(uid, physics.LinearVelocity * randomWalk.AccumulatorRatio, body: physics);
|
||||
_physics.ApplyLinearImpulse(uid, pushAngle.ToVec() * (pushStrength * physics.Mass), body: physics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user