Auto-orient rotation for arrivals (#16417)

This commit is contained in:
metalgearsloth
2023-05-14 21:46:28 +10:00
committed by GitHub
parent c9a27f9f96
commit 676405f08f
3 changed files with 26 additions and 6 deletions

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

View File

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

View 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))