From 676405f08f0bc2e8da177ff1a27f49b33158afa8 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 14 May 2023 21:46:28 +1000 Subject: [PATCH] Auto-orient rotation for arrivals (#16417) --- Content.Server/Shuttles/Systems/ArrivalsSystem.cs | 13 +++++++------ .../Movement/Components/AutoOrientComponent.cs | 12 ++++++++++++ .../Movement/Systems/SharedMoverController.Input.cs | 7 +++++++ 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 Content.Shared/Movement/Components/AutoOrientComponent.cs diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index 7432a82a87..53dccef662 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -1,6 +1,5 @@ using System.Linq; using Content.Server.Administration; -using Content.Server.Chat.Managers; using Content.Server.GameTicking; using Content.Server.GameTicking.Events; using Content.Server.Shuttles.Components; @@ -12,9 +11,9 @@ using Content.Server.Station.Systems; using Content.Shared.Administration; using Content.Shared.CCVar; using Content.Shared.Mobs.Components; +using Content.Shared.Movement.Components; using Content.Shared.Shuttles.Components; using Content.Shared.Spawners.Components; -using Content.Shared.Tag; using Content.Shared.Tiles; using Robust.Server.GameObjects; using Robust.Shared.Configuration; @@ -22,7 +21,6 @@ using Robust.Shared.Console; using Robust.Shared.Map; using Robust.Shared.Random; using Robust.Shared.Timing; -using Robust.Shared.Utility; namespace Content.Server.Shuttles.Systems; @@ -138,6 +136,7 @@ public sealed class ArrivalsSystem : EntitySystem break; } + RemCompDeferred(uid); RemCompDeferred(uid); shell.WriteLine(Loc.GetString("cmd-arrivals-forced", ("uid", ToPrettyString(uid)))); } @@ -154,7 +153,7 @@ public sealed class ArrivalsSystem : EntitySystem _cfgManager.UnsubValueChanged(CCVars.ArrivalsShuttles, SetArrivals); } - private void OnArrivalsFTL(EntityUid uid, ArrivalsShuttleComponent component, ref FTLStartedEvent args) + private void OnArrivalsFTL(EntityUid shuttleUid, ArrivalsShuttleComponent component, ref FTLStartedEvent args) { // Any mob then yeet them off the shuttle. if (!_cfgManager.GetCVar(CCVars.ArrivalsReturns) && args.FromMapUid != null) @@ -163,7 +162,7 @@ public sealed class ArrivalsSystem : EntitySystem var arrivalsBlacklistQuery = GetEntityQuery(); var mobQuery = GetEntityQuery(); var xformQuery = GetEntityQuery(); - DumpChildren(uid, ref args, pendingEntQuery, arrivalsBlacklistQuery, mobQuery, xformQuery); + DumpChildren(shuttleUid, ref args, pendingEntQuery, arrivalsBlacklistQuery, mobQuery, xformQuery); } var pendingQuery = AllEntityQuery(); @@ -172,10 +171,11 @@ public sealed class ArrivalsSystem : EntitySystem while (pendingQuery.MoveNext(out var pUid, out _, out var xform)) { // Cheaper to iterate pending arrivals than all children - if (xform.GridUid != uid) + if (xform.GridUid != shuttleUid) continue; RemCompDeferred(pUid); + RemCompDeferred(pUid); } } @@ -238,6 +238,7 @@ public sealed class ArrivalsSystem : EntitySystem ev.Station); EnsureComp(ev.SpawnResult.Value); + EnsureComp(ev.SpawnResult.Value); return; } } diff --git a/Content.Shared/Movement/Components/AutoOrientComponent.cs b/Content.Shared/Movement/Components/AutoOrientComponent.cs new file mode 100644 index 0000000000..b9ccfa0210 --- /dev/null +++ b/Content.Shared/Movement/Components/AutoOrientComponent.cs @@ -0,0 +1,12 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Movement.Components; + +/// +/// Automatically rotates eye upon grid traversals. +/// +[RegisterComponent, NetworkedComponent] +public sealed class AutoOrientComponent : Component +{ + +} diff --git a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs index 087a3ab5eb..bdc4b6a9f8 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs @@ -52,6 +52,8 @@ namespace Content.Shared.Movement.Systems SubscribeLocalEvent(OnInputHandleState); SubscribeLocalEvent(OnInputParentChange); + SubscribeLocalEvent(OnAutoParentChange); + SubscribeLocalEvent(OnFollowedParentChange); _configManager.OnValueChanged(CCVars.CameraRotationLocked, SetCameraRotationLocked, true); @@ -110,6 +112,11 @@ namespace Content.Shared.Movement.Systems protected virtual void HandleShuttleInput(EntityUid uid, ShuttleButtons button, ushort subTick, bool state) {} + private void OnAutoParentChange(EntityUid uid, AutoOrientComponent component, ref EntParentChangedMessage args) + { + ResetCamera(uid); + } + public void RotateCamera(EntityUid uid, Angle angle) { if (CameraRotationLocked || !TryComp(uid, out var mover))