From b9e876ca92d985babeaac01313bf223d21b44e4b Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 16 Jul 2022 13:51:52 +1000 Subject: [PATCH] The real movement refactor (#9645) * The real movement refactor * ref events * Jetpack cleanup * a * Vehicles partially working * Balance tweaks * Restore some shitcode * AAAAAAAA * Even more prediction * ECS compstate trying to fix this * yml * vehicles kill me * Don't lock keys * a * Fix problem * Fix sounds * shuttle inputs * Shuttle controls * space brakes * Keybinds * Fix merge * Handle shutdown * Fix keys * Bump friction * fix buckle offset * Fix relay and friction * Fix jetpack turning * contexts amirite --- Content.Client/Buckle/BuckleSystem.cs | 17 + Content.Client/Buckle/Strap/StrapComponent.cs | 1 - .../EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs | 9 + Content.Client/Eye/EyeLerpingSystem.cs | 2 +- Content.Client/Input/ContentContexts.cs | 7 +- .../Physics/Controllers/MoverController.cs | 41 ++- .../BUI/ShuttleConsoleBoundUserInterface.cs | 6 - .../Shuttles/Systems/ShuttleConsoleSystem.cs | 31 +- .../Shuttles/UI/ShuttleConsoleWindow.xaml | 4 - .../Shuttles/UI/ShuttleConsoleWindow.xaml.cs | 9 - Content.Client/Vehicle/VehicleSystem.cs | 60 ++- .../Vehicle/VehicleVisualsSystem.cs | 5 +- Content.Server/AI/Commands/AddAiCommand.cs | 6 - .../AI/Steering/AiSteeringSystem.cs | 10 +- Content.Server/Body/Systems/BodySystem.cs | 4 +- Content.Server/Body/Systems/BrainSystem.cs | 3 +- .../Buckle/Components/BuckleComponent.cs | 63 +--- .../Buckle/Components/StrapComponent.cs | 54 +-- Content.Server/Buckle/Systems/BuckleSystem.cs | 30 +- .../Disposal/Tube/DisposalTubeSystem.cs | 4 +- .../Unit/EntitySystems/DisposalUnitSystem.cs | 4 +- Content.Server/Ghost/GhostSystem.cs | 4 +- .../CrewMonitoringConsoleSystem.cs | 2 +- .../Medical/MedicalScannerSystem.cs | 4 +- .../Mind/Commands/MakeSentientCommand.cs | 9 +- .../Physics/Controllers/MoverController.cs | 266 ++++++++++---- .../Resist/EscapeInventorySystem.cs | 4 +- Content.Server/Resist/ResistLockerSystem.cs | 4 +- .../Shuttles/Components/ShuttleComponent.cs | 3 - .../Shuttles/Systems/ShuttleConsoleSystem.cs | 69 +--- .../Storage/EntitySystems/StorageSystem.cs | 4 +- Content.Server/Vehicle/HonkSystem.cs | 57 --- Content.Server/Vehicle/RiderSystem.cs | 57 --- Content.Server/Vehicle/VehicleSystem.Rider.cs | 92 +++++ Content.Server/Vehicle/VehicleSystem.cs | 230 ++++-------- .../Zombies/ZombifyOnDeathSystem.cs | 2 +- .../ActionBlocker/ActionBlockerSystem.cs | 8 +- .../Components/SharedBuckleComponent.cs | 30 ++ .../Buckle/Components/SharedStrapComponent.cs | 53 ++- Content.Shared/Buckle/SharedBuckleSystem.cs | 19 + Content.Shared/CCVar/CCVars.cs | 48 --- .../Containers/ItemSlot/ItemSlotsSystem.cs | 2 +- Content.Shared/Follower/FollowerSystem.cs | 4 +- Content.Shared/Input/ContentKeyFunctions.cs | 7 + .../Movement/Components/IMobMoverComponent.cs | 19 - .../Movement/Components/IMoverComponent.cs | 37 -- .../Components/InputMoverComponent.cs | 51 +++ .../Components/JetpackUserComponent.cs | 3 - .../Movement/Components/MobMoverComponent.cs | 59 +++ .../MovementSpeedModifierComponent.cs | 67 +++- .../Components/RelayInputMoverComponent.cs | 13 + .../SharedDummyInputMoverComponent.cs | 24 -- .../SharedPlayerInputMoverComponent.cs | 257 ------------- .../SharedPlayerMobMoverComponent.cs | 88 ----- .../ContainerRelayMovementEntityEvent.cs | 16 + .../Movement/Events/MoveInputEvent.cs | 17 + .../Movement/Events/RelayMoveInputEvent.cs | 13 - .../Events/RelayMovementEntityEvent.cs | 12 - .../Movement/MobMovementProfileEvent.cs | 35 -- .../Movement/Systems/SharedJetpackSystem.cs | 32 +- .../Systems/SharedMoverController.Input.cs | 345 ++++++++++++++++-- .../Systems/SharedMoverController.Mob.cs | 39 ++ .../Systems/SharedMoverController.Pushing.cs | 4 +- .../Systems/SharedMoverController.Relay.cs | 43 +++ .../Movement/Systems/SharedMoverController.cs | 180 +++------ .../Pulling/Systems/SharedPullableSystem.cs | 13 +- .../ShuttleConsoleBoundInterfaceState.cs | 4 +- .../Shuttles/Components/PilotComponent.cs | 11 + .../Components/SharedShuttleComponent.cs | 8 - .../Events/ShuttleModeRequestMessage.cs | 13 - Content.Shared/Throwing/ThrowingSystem.cs | 2 +- .../Vehicle/Components/InVehicleComponent.cs | 7 +- .../Vehicle/Components/RiderComponent.cs | 6 +- .../Vehicle/Components/VehicleComponent.cs | 95 +++-- .../Vehicle/SharedVehicleSystem.Rider.cs | 20 + Content.Shared/Vehicle/SharedVehicleSystem.cs | 197 +++++++--- .../Locale/en-US/actions/actions/vehicle.ftl | 2 - .../en-US/escape-menu/ui/options-menu.ftl | 9 + .../Prototypes/Body/Mechanisms/human.yml | 5 +- Resources/Prototypes/Body/Parts/human.yml | 5 +- Resources/Prototypes/Body/Parts/reptilian.yml | 5 +- Resources/Prototypes/Body/Parts/slime.yml | 5 +- Resources/Prototypes/Body/Parts/vox.yml | 5 +- .../Prototypes/Entities/Mobs/NPCs/animals.yml | 16 +- .../Prototypes/Entities/Mobs/NPCs/bear.yml | 4 +- .../Prototypes/Entities/Mobs/NPCs/carp.yml | 4 +- .../Entities/Mobs/NPCs/dummy_npcs.yml | 4 +- .../Prototypes/Entities/Mobs/NPCs/human.yml | 8 +- .../Prototypes/Entities/Mobs/NPCs/mimic.yml | 4 +- .../Prototypes/Entities/Mobs/NPCs/pets.yml | 4 +- .../Entities/Mobs/NPCs/regalrat.yml | 8 +- .../Prototypes/Entities/Mobs/NPCs/silicon.yml | 4 +- .../Entities/Mobs/NPCs/simplemob.yml | 8 +- .../Entities/Mobs/NPCs/spacetick.yml | 4 +- .../Prototypes/Entities/Mobs/NPCs/xeno.yml | 8 +- .../Entities/Mobs/Player/admin_ghost.yml | 2 +- .../Entities/Mobs/Player/dragon.yml | 4 +- .../Prototypes/Entities/Mobs/Player/dwarf.yml | 4 +- .../Entities/Mobs/Player/familiars.yml | 4 +- .../Entities/Mobs/Player/guardian.yml | 4 +- .../Prototypes/Entities/Mobs/Player/human.yml | 4 +- .../Entities/Mobs/Player/observer.yml | 2 +- .../Entities/Mobs/Player/reptilian.yml | 4 +- .../Entities/Mobs/Player/skeleton.yml | 4 +- .../Prototypes/Entities/Mobs/Player/slime.yml | 4 +- .../Prototypes/Entities/Mobs/Player/vox.yml | 4 +- .../Entities/Objects/Tools/jetpacks.yml | 6 + .../Entities/Objects/Vehicles/buckleable.yml | 77 ++-- Resources/keybinds.yml | 23 ++ 109 files changed, 1752 insertions(+), 1584 deletions(-) delete mode 100644 Content.Server/Vehicle/HonkSystem.cs delete mode 100644 Content.Server/Vehicle/RiderSystem.cs create mode 100644 Content.Server/Vehicle/VehicleSystem.Rider.cs delete mode 100644 Content.Shared/Movement/Components/IMobMoverComponent.cs delete mode 100644 Content.Shared/Movement/Components/IMoverComponent.cs create mode 100644 Content.Shared/Movement/Components/InputMoverComponent.cs create mode 100644 Content.Shared/Movement/Components/MobMoverComponent.cs create mode 100644 Content.Shared/Movement/Components/RelayInputMoverComponent.cs delete mode 100644 Content.Shared/Movement/Components/SharedDummyInputMoverComponent.cs delete mode 100644 Content.Shared/Movement/Components/SharedPlayerInputMoverComponent.cs delete mode 100644 Content.Shared/Movement/Components/SharedPlayerMobMoverComponent.cs create mode 100644 Content.Shared/Movement/Events/ContainerRelayMovementEntityEvent.cs create mode 100644 Content.Shared/Movement/Events/MoveInputEvent.cs delete mode 100644 Content.Shared/Movement/Events/RelayMoveInputEvent.cs delete mode 100644 Content.Shared/Movement/Events/RelayMovementEntityEvent.cs delete mode 100644 Content.Shared/Movement/MobMovementProfileEvent.cs create mode 100644 Content.Shared/Movement/Systems/SharedMoverController.Mob.cs create mode 100644 Content.Shared/Movement/Systems/SharedMoverController.Relay.cs delete mode 100644 Content.Shared/Shuttles/Components/SharedShuttleComponent.cs delete mode 100644 Content.Shared/Shuttles/Events/ShuttleModeRequestMessage.cs create mode 100644 Content.Shared/Vehicle/SharedVehicleSystem.Rider.cs diff --git a/Content.Client/Buckle/BuckleSystem.cs b/Content.Client/Buckle/BuckleSystem.cs index e558ab70af..90f13f3854 100644 --- a/Content.Client/Buckle/BuckleSystem.cs +++ b/Content.Client/Buckle/BuckleSystem.cs @@ -1,9 +1,26 @@ +using Content.Client.Buckle.Strap; using Content.Shared.Buckle; +using Content.Shared.Buckle.Components; +using Robust.Shared.GameStates; namespace Content.Client.Buckle { internal sealed class BuckleSystem : SharedBuckleSystem { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnStrapHandleState); + } + private void OnStrapHandleState(EntityUid uid, StrapComponent component, ref ComponentHandleState args) + { + if (args.Current is not StrapComponentState state) return; + component.Position = state.Position; + component.BuckleOffsetUnclamped = state.BuckleOffsetClamped; + component.BuckledEntities.Clear(); + component.BuckledEntities.UnionWith(state.BuckledEntities); + component.MaxBuckleDistance = state.MaxBuckleDistance; + } } } diff --git a/Content.Client/Buckle/Strap/StrapComponent.cs b/Content.Client/Buckle/Strap/StrapComponent.cs index 27da0cfe3e..efdc42fe8f 100644 --- a/Content.Client/Buckle/Strap/StrapComponent.cs +++ b/Content.Client/Buckle/Strap/StrapComponent.cs @@ -1,6 +1,5 @@ using Content.Shared.Buckle.Components; using Content.Shared.DragDrop; -using Robust.Shared.GameObjects; namespace Content.Client.Buckle.Strap { diff --git a/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs b/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs index 56b038a7b0..d1045b6cce 100644 --- a/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs +++ b/Content.Client/EscapeMenu/UI/Tabs/KeyRebindTab.xaml.cs @@ -172,6 +172,15 @@ namespace Content.Client.EscapeMenu.UI.Tabs AddButton(ContentKeyFunctions.Loadout8); AddButton(ContentKeyFunctions.Loadout9); + AddHeader("ui-options-header-shuttle"); + AddButton(ContentKeyFunctions.ShuttleStrafeUp); + AddButton(ContentKeyFunctions.ShuttleStrafeRight); + AddButton(ContentKeyFunctions.ShuttleStrafeLeft); + AddButton(ContentKeyFunctions.ShuttleStrafeDown); + AddButton(ContentKeyFunctions.ShuttleRotateLeft); + AddButton(ContentKeyFunctions.ShuttleRotateRight); + AddButton(ContentKeyFunctions.ShuttleBrake); + AddHeader("ui-options-header-map-editor"); AddButton(EngineKeyFunctions.EditorPlaceObject); AddButton(EngineKeyFunctions.EditorCancelPlace); diff --git a/Content.Client/Eye/EyeLerpingSystem.cs b/Content.Client/Eye/EyeLerpingSystem.cs index f687005f46..7befae2fb6 100644 --- a/Content.Client/Eye/EyeLerpingSystem.cs +++ b/Content.Client/Eye/EyeLerpingSystem.cs @@ -94,7 +94,7 @@ public sealed class EyeLerpingSystem : EntitySystem return; // We can't lerp if the mob can't move! - if (!TryComp(mob, out IMoverComponent? mover)) + if (!TryComp(mob, out InputMoverComponent? mover)) return; LerpEye(_eyeManager.CurrentEye, frameTime, mover.LastGridAngle, _playerActiveEye); diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index 2c588a9a29..fe46cf4c26 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -33,6 +33,11 @@ namespace Content.Client.Input common.AddFunction(ContentKeyFunctions.EditorCopyObject); var human = contexts.GetContext("human"); + human.AddFunction(EngineKeyFunctions.MoveUp); + human.AddFunction(EngineKeyFunctions.MoveDown); + human.AddFunction(EngineKeyFunctions.MoveLeft); + human.AddFunction(EngineKeyFunctions.MoveRight); + human.AddFunction(EngineKeyFunctions.Walk); human.AddFunction(ContentKeyFunctions.SwapHands); human.AddFunction(ContentKeyFunctions.Drop); human.AddFunction(ContentKeyFunctions.UseItemInHand); @@ -89,7 +94,7 @@ namespace Content.Client.Input aghost.AddFunction(ContentKeyFunctions.Drop); aghost.AddFunction(ContentKeyFunctions.ThrowItemInHand); - var ghost = contexts.New("ghost", "common"); + var ghost = contexts.New("ghost", "human"); ghost.AddFunction(EngineKeyFunctions.MoveUp); ghost.AddFunction(EngineKeyFunctions.MoveDown); ghost.AddFunction(EngineKeyFunctions.MoveLeft); diff --git a/Content.Client/Physics/Controllers/MoverController.cs b/Content.Client/Physics/Controllers/MoverController.cs index 6db507f00e..6a75df3364 100644 --- a/Content.Client/Physics/Controllers/MoverController.cs +++ b/Content.Client/Physics/Controllers/MoverController.cs @@ -1,10 +1,7 @@ -using Content.Shared.MobState.Components; -using Content.Shared.Movement; using Content.Shared.Movement.Components; using Content.Shared.Movement.Systems; using Content.Shared.Pulling.Components; using Robust.Client.Player; -using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Player; using Robust.Shared.Timing; @@ -20,10 +17,32 @@ namespace Content.Client.Physics.Controllers { base.UpdateBeforeSolve(prediction, frameTime); - if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player || - !TryComp(player, out IMoverComponent? mover) || - !TryComp(player, out PhysicsComponent? body) || - !TryComp(player, out TransformComponent? xform)) + if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player) + return; + + if (TryComp(player, out var relayMover)) + { + if (relayMover.RelayEntity != null) + HandleClientsideMovement(relayMover.RelayEntity.Value, frameTime); + + return; + } + + HandleClientsideMovement(player, frameTime); + } + + private void HandleClientsideMovement(EntityUid player, float frameTime) + { + if (!TryComp(player, out InputMoverComponent? mover) || + !TryComp(player, out TransformComponent? xform)) return; + + PhysicsComponent? body = null; + + if (mover.ToParent && HasComp(xform.ParentUid)) + { + if (!TryComp(xform.ParentUid, out body)) return; + } + else if (!TryComp(player, out body)) { return; } @@ -65,13 +84,7 @@ namespace Content.Client.Physics.Controllers } // Server-side should just be handled on its own so we'll just do this shizznit - if (TryComp(player, out IMobMoverComponent? mobMover)) - { - HandleMobMovement(mover, body, mobMover, xform, frameTime); - return; - } - - HandleKinematicMovement(mover, body); + HandleMobMovement(mover, body, xform, frameTime); } protected override Filter GetSoundPlayers(EntityUid mover) diff --git a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs index 63f71f8dc2..d405658420 100644 --- a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs @@ -18,7 +18,6 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface { base.Open(); _window = new ShuttleConsoleWindow(); - _window.ShuttleModePressed += OnShuttleModePressed; _window.UndockPressed += OnUndockPressed; _window.StartAutodockPressed += OnAutodockPressed; _window.StopAutodockPressed += OnStopAutodockPressed; @@ -65,11 +64,6 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface SendMessage(new UndockRequestMessage() {DockEntity = obj}); } - private void OnShuttleModePressed(ShuttleMode obj) - { - SendMessage(new ShuttleModeRequestMessage() {Mode = obj}); - } - protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); diff --git a/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs b/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs index 7ae419c358..f9e01c09fd 100644 --- a/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs +++ b/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs @@ -1,16 +1,43 @@ +using Content.Shared.Input; using Content.Shared.Shuttles.Components; -using Content.Shared.Shuttles.Events; using Content.Shared.Shuttles.Systems; +using Robust.Client.Input; +using Robust.Client.Player; using Robust.Shared.GameStates; namespace Content.Client.Shuttles.Systems { public sealed class ShuttleConsoleSystem : SharedShuttleConsoleSystem { + [Dependency] private readonly IInputManager _input = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnHandleState); + var shuttle = _input.Contexts.New("shuttle", "common"); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeUp); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeDown); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeLeft); + shuttle.AddFunction(ContentKeyFunctions.ShuttleStrafeRight); + shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateLeft); + shuttle.AddFunction(ContentKeyFunctions.ShuttleRotateRight); + shuttle.AddFunction(ContentKeyFunctions.ShuttleBrake); + } + + public override void Shutdown() + { + base.Shutdown(); + _input.Contexts.Remove("shuttle"); + } + + protected override void HandlePilotShutdown(EntityUid uid, PilotComponent component, ComponentShutdown args) + { + base.HandlePilotShutdown(uid, component, args); + if (_playerManager.LocalPlayer?.ControlledEntity != uid) return; + + _input.Contexts.SetActiveContext("human"); } private void OnHandleState(EntityUid uid, PilotComponent component, ref ComponentHandleState args) @@ -21,6 +48,7 @@ namespace Content.Client.Shuttles.Systems if (!console.IsValid()) { component.Console = null; + _input.Contexts.SetActiveContext("human"); return; } @@ -32,6 +60,7 @@ namespace Content.Client.Shuttles.Systems component.Console = shuttleConsoleComponent; ActionBlockerSystem.UpdateCanMove(uid); + _input.Contexts.SetActiveContext("shuttle"); } } } diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml index 548c136d0a..fe80948aa8 100644 --- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml +++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml @@ -83,10 +83,6 @@ Align="Right"/> -