From b888b1fd9c401da2646a753c488b5cf683b411f7 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 9 Oct 2021 10:55:10 +1100 Subject: [PATCH] Enable shuttle rotation (#4798) * Enable shuttle rotation * Tweaks --- .../Physics/Controllers/MoverController.cs | 23 +++++++++++-------- Content.Server/Shuttles/ShuttleSystem.cs | 3 ++- .../Shuttles/SharedShuttleComponent.cs | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index 373dccb288..5c06695e26 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -99,20 +99,19 @@ namespace Content.Server.Physics.Controllers // inputs will do different things. // TODO: Do that float speedCap; - // This is comically fast for debugging - var angularSpeed = 20000f; + var angularSpeed = 0.75f; // ShuttleSystem has already worked out the ratio so we'll just multiply it back by the mass. var movement = (mover.VelocityDir.walking + mover.VelocityDir.sprinting); - if (physicsComponent.LinearVelocity.LengthSquared == 0f) - { - movement *= 5f; - } - switch (shuttleComponent.Mode) { case ShuttleMode.Docking: + if (physicsComponent.LinearVelocity.LengthSquared == 0f) + { + movement *= 5f; + } + if (movement.Length != 0f) physicsComponent.ApplyLinearImpulse(physicsComponent.Owner.Transform.WorldRotation.RotateVec(movement) * shuttleComponent.SpeedMultipler * physicsComponent.Mass); @@ -121,13 +120,19 @@ namespace Content.Server.Physics.Controllers case ShuttleMode.Cruise: if (movement.Length != 0.0f) { + if (physicsComponent.LinearVelocity.LengthSquared == 0f) + { + movement.Y *= 5f; + } + // Currently this is slow BUT we'd have a separate multiplier for docking and cruising or whatever. physicsComponent.ApplyLinearImpulse((physicsComponent.Owner.Transform.WorldRotation + new Angle(MathF.PI / 2)).ToVec() * shuttleComponent.SpeedMultipler * physicsComponent.Mass * movement.Y * - 10); - physicsComponent.ApplyAngularImpulse(-movement.X * angularSpeed); + 2.5f); + + physicsComponent.ApplyAngularImpulse(-movement.X * angularSpeed * physicsComponent.Mass); } // TODO WHEN THIS ACTUALLY WORKS diff --git a/Content.Server/Shuttles/ShuttleSystem.cs b/Content.Server/Shuttles/ShuttleSystem.cs index 50b67996fa..e8cb2977f6 100644 --- a/Content.Server/Shuttles/ShuttleSystem.cs +++ b/Content.Server/Shuttles/ShuttleSystem.cs @@ -34,6 +34,7 @@ namespace Content.Server.Shuttles foreach (var fixture in args.NewFixtures) { fixture.Mass = fixture.Area * TileMassMultiplier; + fixture.Restitution = 0.1f; } if (body.Owner.TryGetComponent(out ShuttleComponent? shuttleComponent)) @@ -123,7 +124,7 @@ namespace Content.Server.Shuttles component.BodyType = BodyType.Dynamic; component.BodyStatus = BodyStatus.InAir; //component.FixedRotation = false; TODO WHEN ROTATING SHUTTLES FIXED. - component.FixedRotation = true; + component.FixedRotation = false; component.LinearDamping = 0.2f; component.AngularDamping = 0.1f; } diff --git a/Content.Shared/Shuttles/SharedShuttleComponent.cs b/Content.Shared/Shuttles/SharedShuttleComponent.cs index cc7ba7fe65..3e3a7765b6 100644 --- a/Content.Shared/Shuttles/SharedShuttleComponent.cs +++ b/Content.Shared/Shuttles/SharedShuttleComponent.cs @@ -17,7 +17,7 @@ namespace Content.Shared.Shuttles public float SpeedMultipler { get; set; } = 200.0f; [ViewVariables] - public ShuttleMode Mode { get; set; } = ShuttleMode.Docking; + public ShuttleMode Mode { get; set; } = ShuttleMode.Cruise; } public enum ShuttleMode : byte