Files
OldThink/Content.Server/Physics/Controllers/MoverController.cs

572 lines
23 KiB
C#
Raw Normal View History

using System.Numerics;
using System.Runtime.CompilerServices;
2021-11-21 17:09:49 +11:00
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
2021-06-09 22:19:39 +02:00
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
2021-11-21 17:09:49 +11:00
using Content.Shared.Shuttles.Components;
2022-07-15 14:11:41 +10:00
using Content.Shared.Shuttles.Systems;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using DroneConsoleComponent = Content.Server.Shuttles.DroneConsoleComponent;
using DependencyAttribute = Robust.Shared.IoC.DependencyAttribute;
using Robust.Shared.Map.Components;
2019-04-04 16:18:43 +02:00
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
namespace Content.Server.Physics.Controllers
2019-04-04 16:18:43 +02:00
{
public sealed class MoverController : SharedMoverController
2019-04-04 16:18:43 +02:00
{
2022-03-14 02:42:39 +11:00
[Dependency] private readonly ThrusterSystem _thruster = default!;
2023-07-08 09:02:17 -07:00
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
2023-07-08 09:02:17 -07:00
private Dictionary<EntityUid, (ShuttleComponent, List<(EntityUid, PilotComponent, InputMoverComponent, TransformComponent)>)> _shuttlePilots = new();
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RelayInputMoverComponent, PlayerAttachedEvent>(OnRelayPlayerAttached);
SubscribeLocalEvent<RelayInputMoverComponent, PlayerDetachedEvent>(OnRelayPlayerDetached);
SubscribeLocalEvent<InputMoverComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<InputMoverComponent, PlayerDetachedEvent>(OnPlayerDetached);
}
private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, PlayerAttachedEvent args)
{
if (MoverQuery.TryGetComponent(component.RelayEntity, out var inputMover))
SetMoveInput(inputMover, MoveButtons.None);
}
private void OnRelayPlayerDetached(EntityUid uid, RelayInputMoverComponent component, PlayerDetachedEvent args)
{
if (MoverQuery.TryGetComponent(component.RelayEntity, out var inputMover))
SetMoveInput(inputMover, MoveButtons.None);
}
private void OnPlayerAttached(EntityUid uid, InputMoverComponent component, PlayerAttachedEvent args)
{
SetMoveInput(component, MoveButtons.None);
}
private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, PlayerDetachedEvent args)
{
SetMoveInput(component, MoveButtons.None);
}
2022-03-14 02:42:39 +11:00
protected override bool CanSound()
{
return true;
}
Physics (#3452) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-03-01 03:11:29 +11:00
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
public override void UpdateBeforeSolve(bool prediction, float frameTime)
{
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
base.UpdateBeforeSolve(prediction, frameTime);
2023-05-01 18:29:35 +10:00
var inputQueryEnumerator = AllEntityQuery<InputMoverComponent>();
2023-05-01 18:29:35 +10:00
while (inputQueryEnumerator.MoveNext(out var uid, out var mover))
Physics (#3452) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-03-01 03:11:29 +11:00
{
2023-05-01 18:29:35 +10:00
var physicsUid = uid;
2023-03-22 15:58:53 +11:00
if (RelayQuery.HasComponent(uid))
2023-01-16 21:20:22 +13:00
continue;
2022-08-29 15:05:53 +10:00
if (!XformQuery.TryGetComponent(uid, out var xform))
{
continue;
}
2023-01-16 21:20:22 +13:00
PhysicsComponent? body;
var xformMover = xform;
if (mover.ToParent && RelayQuery.HasComponent(xform.ParentUid))
{
if (!PhysicsQuery.TryGetComponent(xform.ParentUid, out body) ||
!XformQuery.TryGetComponent(xform.ParentUid, out xformMover))
{
continue;
}
2023-03-22 15:58:53 +11:00
physicsUid = xform.ParentUid;
}
else if (!PhysicsQuery.TryGetComponent(uid, out body))
{
continue;
}
2023-05-01 18:29:35 +10:00
HandleMobMovement(uid,
mover,
physicsUid,
body,
xformMover,
frameTime);
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
}
HandleShuttleMovement(frameTime);
}
public (Vector2 Strafe, float Rotation, float Brakes) GetPilotVelocityInput(PilotComponent component)
{
if (!Timing.InSimulation)
{
// Outside of simulation we'll be running client predicted movement per-frame.
// So return a full-length vector as if it's a full tick.
// Physics system will have the correct time step anyways.
ResetSubtick(component);
ApplyTick(component, 1f);
return (component.CurTickStrafeMovement, component.CurTickRotationMovement, component.CurTickBraking);
}
float remainingFraction;
if (Timing.CurTick > component.LastInputTick)
{
component.CurTickStrafeMovement = Vector2.Zero;
component.CurTickRotationMovement = 0f;
component.CurTickBraking = 0f;
remainingFraction = 1;
}
else
{
remainingFraction = (ushort.MaxValue - component.LastInputSubTick) / (float) ushort.MaxValue;
}
ApplyTick(component, remainingFraction);
// Logger.Info($"{curDir}{walk}{sprint}");
return (component.CurTickStrafeMovement, component.CurTickRotationMovement, component.CurTickBraking);
}
private void ResetSubtick(PilotComponent component)
{
if (Timing.CurTick <= component.LastInputTick) return;
component.CurTickStrafeMovement = Vector2.Zero;
component.CurTickRotationMovement = 0f;
component.CurTickBraking = 0f;
component.LastInputTick = Timing.CurTick;
component.LastInputSubTick = 0;
}
protected override void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state)
{
2023-07-08 09:02:17 -07:00
if (!TryComp<PilotComponent>(uid, out var pilot) || pilot.Console == null)
return;
ResetSubtick(pilot);
if (subTick >= pilot.LastInputSubTick)
{
var fraction = (subTick - pilot.LastInputSubTick) / (float) ushort.MaxValue;
ApplyTick(pilot, fraction);
pilot.LastInputSubTick = subTick;
}
var buttons = pilot.HeldButtons;
if (state)
{
buttons |= button;
}
else
{
buttons &= ~button;
}
pilot.HeldButtons = buttons;
}
2023-07-08 09:02:17 -07:00
private static void ApplyTick(PilotComponent component, float fraction)
{
var x = 0;
var y = 0;
var rot = 0;
int brake;
if ((component.HeldButtons & ShuttleButtons.StrafeLeft) != 0x0)
{
x -= 1;
}
if ((component.HeldButtons & ShuttleButtons.StrafeRight) != 0x0)
{
x += 1;
}
component.CurTickStrafeMovement.X += x * fraction;
if ((component.HeldButtons & ShuttleButtons.StrafeUp) != 0x0)
{
y += 1;
}
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
if ((component.HeldButtons & ShuttleButtons.StrafeDown) != 0x0)
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
{
y -= 1;
}
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
component.CurTickStrafeMovement.Y += y * fraction;
if ((component.HeldButtons & ShuttleButtons.RotateLeft) != 0x0)
{
rot -= 1;
}
if ((component.HeldButtons & ShuttleButtons.RotateRight) != 0x0)
{
rot += 1;
}
component.CurTickRotationMovement += rot * fraction;
if ((component.HeldButtons & ShuttleButtons.Brake) != 0x0)
{
brake = 1;
}
else
{
brake = 0;
2019-04-04 16:18:43 +02:00
}
component.CurTickBraking += brake * fraction;
2019-04-04 16:18:43 +02:00
}
/// <summary>
/// Helper function to extrapolate max velocity for a given Vector2 (really, its angle) and shuttle.
/// </summary>
private Vector2 ObtainMaxVel(Vector2 vel, ShuttleComponent shuttle)
{
if (vel.Length() == 0f)
return Vector2.Zero;
// this math could PROBABLY be simplified for performance
// probably
// __________________________________
// / / __ __ \2 / __ __ \2
// O = I : _ / |I * | 1/H | | + |I * | 0 | |
// V \ |_ 0 _| / \ |_1/V_| /
var horizIndex = vel.X > 0 ? 1 : 3; // east else west
var vertIndex = vel.Y > 0 ? 2 : 0; // north else south
2024-01-23 23:49:19 +11:00
var horizComp = vel.X != 0 ? MathF.Pow(Vector2.Dot(vel, new (shuttle.LinearThrust[horizIndex] / shuttle.LinearThrust[horizIndex], 0f)), 2) : 0;
var vertComp = vel.Y != 0 ? MathF.Pow(Vector2.Dot(vel, new (0f, shuttle.LinearThrust[vertIndex] / shuttle.LinearThrust[vertIndex])), 2) : 0;
return shuttle.BaseMaxLinearVelocity * vel * MathF.ReciprocalSqrtEstimate(horizComp + vertComp);
}
private void HandleShuttleMovement(float frameTime)
2020-06-24 02:21:20 +02:00
{
2023-07-08 09:02:17 -07:00
var newPilots = new Dictionary<EntityUid, (ShuttleComponent Shuttle, List<(EntityUid PilotUid, PilotComponent Pilot, InputMoverComponent Mover, TransformComponent ConsoleXform)>)>();
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
2021-03-08 04:09:59 +11:00
// We just mark off their movement and the shuttle itself does its own movement
2023-07-08 09:02:17 -07:00
var activePilotQuery = EntityQueryEnumerator<PilotComponent, InputMoverComponent>();
var shuttleQuery = GetEntityQuery<ShuttleComponent>();
while (activePilotQuery.MoveNext(out var uid, out var pilot, out var mover))
{
2023-07-08 09:02:17 -07:00
var consoleEnt = pilot.Console;
2022-06-23 14:36:47 +10:00
// TODO: This is terrible. Just make a new mover and also make it remote piloting + device networks
2023-05-31 11:13:02 +10:00
if (TryComp<DroneConsoleComponent>(consoleEnt, out var cargoConsole))
2022-06-23 14:36:47 +10:00
{
consoleEnt = cargoConsole.Entity;
}
if (!TryComp(consoleEnt, out TransformComponent? xform)) continue;
2022-06-23 14:36:47 +10:00
2022-06-20 12:14:35 +12:00
var gridId = xform.GridUid;
// This tries to see if the grid is a shuttle and if the console should work.
if (!TryComp<MapGridComponent>(gridId, out var _) ||
2023-07-08 09:02:17 -07:00
!shuttleQuery.TryGetComponent(gridId, out var shuttleComponent) ||
!shuttleComponent.Enabled)
continue;
2023-07-08 09:02:17 -07:00
if (!newPilots.TryGetValue(gridId!.Value, out var pilots))
{
2023-07-08 09:02:17 -07:00
pilots = (shuttleComponent, new List<(EntityUid, PilotComponent, InputMoverComponent, TransformComponent)>());
newPilots[gridId.Value] = pilots;
}
2023-07-08 09:02:17 -07:00
pilots.Item2.Add((uid, pilot, mover, xform));
}
// Reset inputs for non-piloted shuttles.
2023-07-08 09:02:17 -07:00
foreach (var (shuttleUid, (shuttle, _)) in _shuttlePilots)
2021-11-21 17:09:49 +11:00
{
2023-07-08 09:02:17 -07:00
if (newPilots.ContainsKey(shuttleUid) || CanPilot(shuttleUid))
continue;
2022-03-14 02:42:39 +11:00
_thruster.DisableLinearThrusters(shuttle);
2021-11-21 17:09:49 +11:00
}
_shuttlePilots = newPilots;
// Collate all of the linear / angular velocites for a shuttle
// then do the movement input once for it.
2023-07-08 09:02:17 -07:00
var xformQuery = GetEntityQuery<TransformComponent>();
foreach (var (shuttleUid, (shuttle, pilots)) in _shuttlePilots)
{
2023-07-08 09:02:17 -07:00
if (Paused(shuttleUid) || CanPilot(shuttleUid) || !TryComp<PhysicsComponent>(shuttleUid, out var body))
continue;
2023-07-08 09:02:17 -07:00
var shuttleNorthAngle = _xformSystem.GetWorldRotation(shuttleUid, xformQuery);
// Collate movement linear and angular inputs together
var linearInput = Vector2.Zero;
var brakeInput = 0f;
var angularInput = 0f;
2023-07-08 09:02:17 -07:00
foreach (var (pilotUid, pilot, _, consoleXform) in pilots)
{
2023-07-08 09:02:17 -07:00
var (strafe, rotation, brakes) = GetPilotVelocityInput(pilot);
2023-07-08 09:02:17 -07:00
if (brakes > 0f)
{
2023-07-08 09:02:17 -07:00
brakeInput += brakes;
}
2023-07-08 09:02:17 -07:00
if (strafe.Length() > 0f)
{
var offsetRotation = consoleXform.LocalRotation;
2023-07-08 09:02:17 -07:00
linearInput += offsetRotation.RotateVec(strafe);
}
2023-07-08 09:02:17 -07:00
if (rotation != 0f)
{
2023-07-08 09:02:17 -07:00
angularInput += rotation;
}
}
var count = pilots.Count;
linearInput /= count;
angularInput /= count;
brakeInput /= count;
// Handle shuttle movement
if (brakeInput > 0f)
{
if (body.LinearVelocity.Length() > 0f)
{
2023-04-29 18:17:31 +10:00
// Minimum brake velocity for a direction to show its thrust appearance.
2023-05-24 23:15:03 +10:00
const float appearanceThreshold = 0.1f;
2023-04-29 18:17:31 +10:00
// Get velocity relative to the shuttle so we know which thrusters to fire
var shuttleVelocity = (-shuttleNorthAngle).RotateVec(body.LinearVelocity);
var force = Vector2.Zero;
if (shuttleVelocity.X < 0f)
{
_thruster.DisableLinearThrustDirection(shuttle, DirectionFlag.West);
2023-04-29 18:17:31 +10:00
if (shuttleVelocity.X < -appearanceThreshold)
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.East);
var index = (int) Math.Log2((int) DirectionFlag.East);
force.X += shuttle.LinearThrust[index];
}
else if (shuttleVelocity.X > 0f)
{
_thruster.DisableLinearThrustDirection(shuttle, DirectionFlag.East);
2023-04-29 18:17:31 +10:00
if (shuttleVelocity.X > appearanceThreshold)
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.West);
var index = (int) Math.Log2((int) DirectionFlag.West);
force.X -= shuttle.LinearThrust[index];
}
if (shuttleVelocity.Y < 0f)
{
_thruster.DisableLinearThrustDirection(shuttle, DirectionFlag.South);
2023-04-29 18:17:31 +10:00
if (shuttleVelocity.Y < -appearanceThreshold)
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.North);
var index = (int) Math.Log2((int) DirectionFlag.North);
force.Y += shuttle.LinearThrust[index];
}
else if (shuttleVelocity.Y > 0f)
{
_thruster.DisableLinearThrustDirection(shuttle, DirectionFlag.North);
2023-04-29 18:17:31 +10:00
if (shuttleVelocity.Y > appearanceThreshold)
_thruster.EnableLinearThrustDirection(shuttle, DirectionFlag.South);
var index = (int) Math.Log2((int) DirectionFlag.South);
force.Y -= shuttle.LinearThrust[index];
}
2023-04-29 18:17:31 +10:00
var impulse = force * brakeInput * ShuttleComponent.BrakeCoefficient;
2023-05-24 23:15:03 +10:00
impulse = shuttleNorthAngle.RotateVec(impulse);
var forceMul = frameTime * body.InvMass;
var maxVelocity = (-body.LinearVelocity).Length() / forceMul;
2023-05-24 23:15:03 +10:00
// Don't overshoot
if (impulse.Length() > maxVelocity)
impulse = impulse.Normalized() * maxVelocity;
2023-04-29 18:17:31 +10:00
2023-07-08 09:02:17 -07:00
PhysicsSystem.ApplyForce(shuttleUid, impulse, body: body);
}
else
{
_thruster.DisableLinearThrusters(shuttle);
}
if (body.AngularVelocity != 0f)
{
2023-05-24 23:15:03 +10:00
var torque = shuttle.AngularThrust * brakeInput * (body.AngularVelocity > 0f ? -1f : 1f) * ShuttleComponent.BrakeCoefficient;
var torqueMul = body.InvI * frameTime;
2023-05-24 23:15:03 +10:00
if (body.AngularVelocity > 0f)
{
2023-05-24 23:15:03 +10:00
torque = MathF.Max(-body.AngularVelocity / torqueMul, torque);
}
else
{
2023-07-27 11:38:03 +04:00
torque = MathF.Min(-body.AngularVelocity / torqueMul, torque);
}
2023-04-29 18:17:31 +10:00
2023-05-24 23:15:03 +10:00
if (!torque.Equals(0f))
{
2023-07-08 09:02:17 -07:00
PhysicsSystem.ApplyTorque(shuttleUid, torque, body: body);
2023-05-24 23:15:03 +10:00
_thruster.SetAngularThrust(shuttle, true);
}
2023-04-29 18:17:31 +10:00
}
else
{
_thruster.SetAngularThrust(shuttle, false);
}
}
if (linearInput.Length().Equals(0f))
{
2023-07-08 09:02:17 -07:00
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, true);
if (brakeInput.Equals(0f))
_thruster.DisableLinearThrusters(shuttle);
}
else
{
2023-07-08 09:02:17 -07:00
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, false);
var angle = linearInput.ToWorldAngle();
var linearDir = angle.GetDir();
var dockFlag = linearDir.AsFlag();
2023-04-29 18:17:31 +10:00
var totalForce = Vector2.Zero;
2021-11-21 17:09:49 +11:00
// Won't just do cardinal directions.
foreach (DirectionFlag dir in Enum.GetValues(typeof(DirectionFlag)))
{
2021-11-21 17:09:49 +11:00
// Brain no worky but I just want cardinals
switch (dir)
{
case DirectionFlag.South:
case DirectionFlag.East:
case DirectionFlag.North:
case DirectionFlag.West:
break;
default:
continue;
}
if ((dir & dockFlag) == 0x0)
{
2022-03-14 02:42:39 +11:00
_thruster.DisableLinearThrustDirection(shuttle, dir);
continue;
}
2023-04-29 18:17:31 +10:00
var force = Vector2.Zero;
var index = (int) Math.Log2((int) dir);
var thrust = shuttle.LinearThrust[index];
2021-11-21 17:09:49 +11:00
switch (dir)
2021-11-21 17:09:49 +11:00
{
case DirectionFlag.North:
2023-04-29 18:17:31 +10:00
force.Y += thrust;
2021-11-21 17:09:49 +11:00
break;
case DirectionFlag.South:
2023-04-29 18:17:31 +10:00
force.Y -= thrust;
break;
case DirectionFlag.East:
2023-04-29 18:17:31 +10:00
force.X += thrust;
break;
case DirectionFlag.West:
2023-04-29 18:17:31 +10:00
force.X -= thrust;
2021-11-21 17:09:49 +11:00
break;
default:
2023-07-08 09:02:17 -07:00
throw new ArgumentOutOfRangeException($"Attempted to apply thrust to shuttle {shuttleUid} along invalid dir {dir}.");
2021-11-21 17:09:49 +11:00
}
2022-03-14 02:42:39 +11:00
_thruster.EnableLinearThrustDirection(shuttle, dir);
var impulse = force * linearInput.Length();
2023-04-29 18:17:31 +10:00
totalForce += impulse;
}
2021-11-21 17:09:49 +11:00
2023-05-24 23:15:03 +10:00
var forceMul = frameTime * body.InvMass;
var localVel = (-shuttleNorthAngle).RotateVec(body.LinearVelocity);
var maxVelocity = ObtainMaxVel(localVel, shuttle); // max for current travel dir
var maxWishVelocity = ObtainMaxVel(totalForce, shuttle);
var properAccel = (maxWishVelocity - localVel) / forceMul;
2023-05-24 23:15:03 +10:00
var finalForce = Vector2Dot(totalForce, properAccel.Normalized()) * properAccel.Normalized();
if (localVel.Length() >= maxVelocity.Length() && Vector2.Dot(totalForce, localVel) > 0f)
finalForce = Vector2.Zero; // burn would be faster if used as such
if (finalForce.Length() > properAccel.Length())
finalForce = properAccel; // don't overshoot
//Log.Info($"shuttle: maxVelocity {maxVelocity} totalForce {totalForce} finalForce {finalForce} forceMul {forceMul} properAccel {properAccel}");
finalForce = shuttleNorthAngle.RotateVec(finalForce);
if (finalForce.Length() > 0f)
PhysicsSystem.ApplyForce(shuttleUid, finalForce, body: body);
}
if (MathHelper.CloseTo(angularInput, 0f))
{
2023-07-08 09:02:17 -07:00
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, true);
2023-04-29 18:17:31 +10:00
if (brakeInput <= 0f)
_thruster.SetAngularThrust(shuttle, false);
}
else
{
2023-07-08 09:02:17 -07:00
PhysicsSystem.SetSleepingAllowed(shuttleUid, body, false);
2023-05-24 23:15:03 +10:00
var torque = shuttle.AngularThrust * -angularInput;
// Need to cap the velocity if 1 tick of input brings us over cap so we don't continuously
// edge onto the cap over and over.
var torqueMul = body.InvI * frameTime;
2023-05-24 23:15:03 +10:00
torque = Math.Clamp(torque,
(-ShuttleComponent.MaxAngularVelocity - body.AngularVelocity) / torqueMul,
(ShuttleComponent.MaxAngularVelocity - body.AngularVelocity) / torqueMul);
if (!torque.Equals(0f))
{
2023-07-08 09:02:17 -07:00
PhysicsSystem.ApplyTorque(shuttleUid, torque, body: body);
2023-05-24 23:15:03 +10:00
_thruster.SetAngularThrust(shuttle, true);
}
}
2019-04-04 16:18:43 +02:00
}
}
2022-07-15 14:11:41 +10:00
// .NET 8 seem to miscompile usage of Vector2.Dot above. This manual outline fixes it pending an upstream fix.
// See PR #24008
[MethodImpl(MethodImplOptions.NoInlining)]
public static float Vector2Dot(Vector2 value1, Vector2 value2)
{
return Vector2.Dot(value1, value2);
}
2023-07-08 09:02:17 -07:00
private bool CanPilot(EntityUid shuttleUid)
2022-07-15 14:11:41 +10:00
{
2023-07-08 09:02:17 -07:00
return TryComp<FTLComponent>(shuttleUid, out var ftl)
&& (ftl.State & (FTLState.Starting | FTLState.Travelling | FTLState.Arriving)) != 0x0
|| HasComp<PreventPilotComponent>(shuttleUid);
2022-07-15 14:11:41 +10:00
}
2019-04-04 16:18:43 +02:00
}
}