Enable shuttle rotation (#4798)

* Enable shuttle rotation

* Tweaks
This commit is contained in:
metalgearsloth
2021-10-09 10:55:10 +11:00
committed by GitHub
parent d5cc7fce8a
commit b888b1fd9c
3 changed files with 17 additions and 11 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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