Add station anchors (#18697)

This commit is contained in:
Kevin Zheng
2023-08-05 02:24:24 -07:00
committed by GitHub
parent 011fa393ac
commit ba589dbf65
3 changed files with 25 additions and 15 deletions

View File

@@ -44,5 +44,14 @@ namespace Content.Server.Shuttles.Components
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public DirectionFlag ThrustDirections = DirectionFlag.None; public DirectionFlag ThrustDirections = DirectionFlag.None;
/// <summary>
/// Damping applied to the shuttle's physics component when not in FTL.
/// </summary>
[DataField("linearDamping"), ViewVariables(VVAccess.ReadWrite)]
public float LinearDamping = 0.05f;
[DataField("angularDamping"), ViewVariables(VVAccess.ReadWrite)]
public float AngularDamping = 0.05f;
} }
} }

View File

@@ -236,6 +236,7 @@ public sealed partial class ShuttleSystem
var xform = Transform(uid); var xform = Transform(uid);
PhysicsComponent? body; PhysicsComponent? body;
ShuttleComponent? shuttle; ShuttleComponent? shuttle;
TryComp(uid, out shuttle);
switch (comp.State) switch (comp.State)
{ {
@@ -256,7 +257,8 @@ public sealed partial class ShuttleSystem
if (TryComp(uid, out body)) if (TryComp(uid, out body))
{ {
Enable(uid, body); if (shuttle != null)
Enable(uid, body, shuttle);
_physics.SetLinearVelocity(uid, new Vector2(0f, 20f), body: body); _physics.SetLinearVelocity(uid, new Vector2(0f, 20f), body: body);
_physics.SetAngularVelocity(uid, 0f, body: body); _physics.SetAngularVelocity(uid, 0f, body: body);
_physics.SetLinearDamping(body, 0f); _physics.SetLinearDamping(body, 0f);
@@ -283,7 +285,7 @@ public sealed partial class ShuttleSystem
// TODO: Arrival effects // TODO: Arrival effects
// For now we'll just use the ss13 bubbles but we can do fancier. // For now we'll just use the ss13 bubbles but we can do fancier.
if (TryComp(uid, out shuttle)) if (shuttle != null)
{ {
_thruster.DisableLinearThrusters(shuttle); _thruster.DisableLinearThrusters(shuttle);
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.South); _thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.South);
@@ -301,11 +303,13 @@ public sealed partial class ShuttleSystem
{ {
_physics.SetLinearVelocity(uid, Vector2.Zero, body: body); _physics.SetLinearVelocity(uid, Vector2.Zero, body: body);
_physics.SetAngularVelocity(uid, 0f, body: body); _physics.SetAngularVelocity(uid, 0f, body: body);
_physics.SetLinearDamping(body, ShuttleLinearDamping); if (shuttle != null)
_physics.SetAngularDamping(body, ShuttleAngularDamping); {
_physics.SetLinearDamping(body, shuttle.LinearDamping);
_physics.SetAngularDamping(body, shuttle.AngularDamping);
}
} }
TryComp(uid, out shuttle);
MapId mapId; MapId mapId;
if (comp.TargetUid != null && shuttle != null) if (comp.TargetUid != null && shuttle != null)
@@ -347,9 +351,9 @@ public sealed partial class ShuttleSystem
{ {
Disable(uid, body); Disable(uid, body);
} }
else else if (shuttle != null)
{ {
Enable(uid, body); Enable(uid, body, shuttle);
} }
} }

View File

@@ -44,9 +44,6 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
public const float TileMassMultiplier = 0.5f; public const float TileMassMultiplier = 0.5f;
public const float ShuttleLinearDamping = 0.05f;
public const float ShuttleAngularDamping = 0.05f;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -125,7 +122,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
if (component.Enabled) if (component.Enabled)
{ {
Enable(uid, physicsComponent); Enable(uid, physicsComponent, component);
} }
} }
@@ -138,7 +135,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
if (component.Enabled) if (component.Enabled)
{ {
Enable(uid, physicsComponent); Enable(uid, physicsComponent, component);
} }
else else
{ {
@@ -146,15 +143,15 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
} }
} }
private void Enable(EntityUid uid, PhysicsComponent component) private void Enable(EntityUid uid, PhysicsComponent component, ShuttleComponent shuttle)
{ {
FixturesComponent? manager = null; FixturesComponent? manager = null;
_physics.SetBodyType(uid, BodyType.Dynamic, manager: manager, body: component); _physics.SetBodyType(uid, BodyType.Dynamic, manager: manager, body: component);
_physics.SetBodyStatus(component, BodyStatus.InAir); _physics.SetBodyStatus(component, BodyStatus.InAir);
_physics.SetFixedRotation(uid, false, manager: manager, body: component); _physics.SetFixedRotation(uid, false, manager: manager, body: component);
_physics.SetLinearDamping(component, ShuttleLinearDamping); _physics.SetLinearDamping(component, shuttle.LinearDamping);
_physics.SetAngularDamping(component, ShuttleAngularDamping); _physics.SetAngularDamping(component, shuttle.AngularDamping);
} }
private void Disable(EntityUid uid, PhysicsComponent component) private void Disable(EntityUid uid, PhysicsComponent component)