Content update for ECS physics (#13291)
This commit is contained in:
@@ -243,12 +243,12 @@ public sealed partial class GunSystem : SharedGunSystem
|
||||
public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid? user = null, float speed = 20f)
|
||||
{
|
||||
var physics = EnsureComp<PhysicsComponent>(uid);
|
||||
physics.BodyStatus = BodyStatus.InAir;
|
||||
Physics.SetBodyStatus(physics, BodyStatus.InAir);
|
||||
|
||||
var targetMapVelocity = gunVelocity + direction.Normalized * speed;
|
||||
var currentMapVelocity = Physics.GetMapLinearVelocity(uid, physics);
|
||||
var finalLinear = physics.LinearVelocity + targetMapVelocity - currentMapVelocity;
|
||||
Physics.SetLinearVelocity(physics, finalLinear);
|
||||
Physics.SetLinearVelocity(uid, finalLinear, body: physics);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
|
||||
@@ -111,12 +111,12 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
|
||||
|
||||
if (TryComp<PhysicsComponent>(msg.Entity, out var body))
|
||||
{
|
||||
body.BodyStatus = BodyStatus.InAir;
|
||||
_physics.SetBodyStatus(body, BodyStatus.InAir);
|
||||
}
|
||||
|
||||
_physics.WakeBody(bodyA);
|
||||
_physics.WakeBody(bodyB);
|
||||
var joint = _joints.CreateMouseJoint(bodyA.Owner, bodyB.Owner, id: JointId);
|
||||
_physics.WakeBody(tether, body: bodyA);
|
||||
_physics.WakeBody(msg.Entity, body: bodyB);
|
||||
var joint = _joints.CreateMouseJoint(tether, msg.Entity, id: JointId);
|
||||
|
||||
SharedJointSystem.LinearStiffness(5f, 0.7f, bodyA.Mass, bodyB.Mass, out var stiffness, out var damping);
|
||||
joint.Stiffness = stiffness;
|
||||
@@ -147,8 +147,9 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
|
||||
{
|
||||
Timer.Spawn(1000, () =>
|
||||
{
|
||||
if (Deleted(body.Owner)) return;
|
||||
body.BodyStatus = BodyStatus.OnGround;
|
||||
if (Deleted(weh.Entity)) return;
|
||||
|
||||
_physics.SetBodyStatus(body, BodyStatus.OnGround);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -186,7 +187,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
|
||||
// Force it awake, always
|
||||
if (bodyQuery.TryGetComponent(entity.Entity, out var body))
|
||||
{
|
||||
_physics.WakeBody(body);
|
||||
_physics.WakeBody(entity.Entity, body: body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user