]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Auto-orient rotation for arrivals (#16417)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 14 May 2023 11:46:28 +0000 (21:46 +1000)
committerGitHub <noreply@github.com>
Sun, 14 May 2023 11:46:28 +0000 (07:46 -0400)
Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Content.Shared/Movement/Components/AutoOrientComponent.cs [new file with mode: 0644]
Content.Shared/Movement/Systems/SharedMoverController.Input.cs

index 7432a82a87a5d8e527c28273470a8719e3d5dc65..53dccef662230a9072bce4f71104413e531f81cf 100644 (file)
@@ -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<AutoOrientComponent>(uid);
                     RemCompDeferred<PendingClockInComponent>(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<ArrivalsBlacklistComponent>();
             var mobQuery = GetEntityQuery<MobStateComponent>();
             var xformQuery = GetEntityQuery<TransformComponent>();
-            DumpChildren(uid, ref args, pendingEntQuery, arrivalsBlacklistQuery, mobQuery, xformQuery);
+            DumpChildren(shuttleUid, ref args, pendingEntQuery, arrivalsBlacklistQuery, mobQuery, xformQuery);
         }
 
         var pendingQuery = AllEntityQuery<PendingClockInComponent, TransformComponent>();
@@ -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<PendingClockInComponent>(pUid);
+            RemCompDeferred<AutoOrientComponent>(pUid);
         }
     }
 
@@ -238,6 +238,7 @@ public sealed class ArrivalsSystem : EntitySystem
                     ev.Station);
 
                 EnsureComp<PendingClockInComponent>(ev.SpawnResult.Value);
+                EnsureComp<AutoOrientComponent>(ev.SpawnResult.Value);
                 return;
             }
         }
diff --git a/Content.Shared/Movement/Components/AutoOrientComponent.cs b/Content.Shared/Movement/Components/AutoOrientComponent.cs
new file mode 100644 (file)
index 0000000..b9ccfa0
--- /dev/null
@@ -0,0 +1,12 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Movement.Components;
+
+/// <summary>
+/// Automatically rotates eye upon grid traversals.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed class AutoOrientComponent : Component
+{
+
+}
index 087a3ab5ebcf6c745461bfb865e3e00100f18e3f..bdc4b6a9f8475c6ab020f45bf3852d3e905b56ee 100644 (file)
@@ -52,6 +52,8 @@ namespace Content.Shared.Movement.Systems
             SubscribeLocalEvent<InputMoverComponent, ComponentHandleState>(OnInputHandleState);
             SubscribeLocalEvent<InputMoverComponent, EntParentChangedMessage>(OnInputParentChange);
 
+            SubscribeLocalEvent<AutoOrientComponent, EntParentChangedMessage>(OnAutoParentChange);
+
             SubscribeLocalEvent<FollowedComponent, EntParentChangedMessage>(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<InputMoverComponent>(uid, out var mover))