Auto-orient rotation for arrivals (#16417)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
using Content.Server.Chat.Managers;
|
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.GameTicking.Events;
|
using Content.Server.GameTicking.Events;
|
||||||
using Content.Server.Shuttles.Components;
|
using Content.Server.Shuttles.Components;
|
||||||
@@ -12,9 +11,9 @@ using Content.Server.Station.Systems;
|
|||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Mobs.Components;
|
using Content.Shared.Mobs.Components;
|
||||||
|
using Content.Shared.Movement.Components;
|
||||||
using Content.Shared.Shuttles.Components;
|
using Content.Shared.Shuttles.Components;
|
||||||
using Content.Shared.Spawners.Components;
|
using Content.Shared.Spawners.Components;
|
||||||
using Content.Shared.Tag;
|
|
||||||
using Content.Shared.Tiles;
|
using Content.Shared.Tiles;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
@@ -22,7 +21,6 @@ using Robust.Shared.Console;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Utility;
|
|
||||||
|
|
||||||
namespace Content.Server.Shuttles.Systems;
|
namespace Content.Server.Shuttles.Systems;
|
||||||
|
|
||||||
@@ -138,6 +136,7 @@ public sealed class ArrivalsSystem : EntitySystem
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemCompDeferred<AutoOrientComponent>(uid);
|
||||||
RemCompDeferred<PendingClockInComponent>(uid);
|
RemCompDeferred<PendingClockInComponent>(uid);
|
||||||
shell.WriteLine(Loc.GetString("cmd-arrivals-forced", ("uid", ToPrettyString(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);
|
_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.
|
// Any mob then yeet them off the shuttle.
|
||||||
if (!_cfgManager.GetCVar(CCVars.ArrivalsReturns) && args.FromMapUid != null)
|
if (!_cfgManager.GetCVar(CCVars.ArrivalsReturns) && args.FromMapUid != null)
|
||||||
@@ -163,7 +162,7 @@ public sealed class ArrivalsSystem : EntitySystem
|
|||||||
var arrivalsBlacklistQuery = GetEntityQuery<ArrivalsBlacklistComponent>();
|
var arrivalsBlacklistQuery = GetEntityQuery<ArrivalsBlacklistComponent>();
|
||||||
var mobQuery = GetEntityQuery<MobStateComponent>();
|
var mobQuery = GetEntityQuery<MobStateComponent>();
|
||||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
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>();
|
var pendingQuery = AllEntityQuery<PendingClockInComponent, TransformComponent>();
|
||||||
@@ -172,10 +171,11 @@ public sealed class ArrivalsSystem : EntitySystem
|
|||||||
while (pendingQuery.MoveNext(out var pUid, out _, out var xform))
|
while (pendingQuery.MoveNext(out var pUid, out _, out var xform))
|
||||||
{
|
{
|
||||||
// Cheaper to iterate pending arrivals than all children
|
// Cheaper to iterate pending arrivals than all children
|
||||||
if (xform.GridUid != uid)
|
if (xform.GridUid != shuttleUid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RemCompDeferred<PendingClockInComponent>(pUid);
|
RemCompDeferred<PendingClockInComponent>(pUid);
|
||||||
|
RemCompDeferred<AutoOrientComponent>(pUid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +238,7 @@ public sealed class ArrivalsSystem : EntitySystem
|
|||||||
ev.Station);
|
ev.Station);
|
||||||
|
|
||||||
EnsureComp<PendingClockInComponent>(ev.SpawnResult.Value);
|
EnsureComp<PendingClockInComponent>(ev.SpawnResult.Value);
|
||||||
|
EnsureComp<AutoOrientComponent>(ev.SpawnResult.Value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
Content.Shared/Movement/Components/AutoOrientComponent.cs
Normal file
12
Content.Shared/Movement/Components/AutoOrientComponent.cs
Normal 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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -52,6 +52,8 @@ namespace Content.Shared.Movement.Systems
|
|||||||
SubscribeLocalEvent<InputMoverComponent, ComponentHandleState>(OnInputHandleState);
|
SubscribeLocalEvent<InputMoverComponent, ComponentHandleState>(OnInputHandleState);
|
||||||
SubscribeLocalEvent<InputMoverComponent, EntParentChangedMessage>(OnInputParentChange);
|
SubscribeLocalEvent<InputMoverComponent, EntParentChangedMessage>(OnInputParentChange);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<AutoOrientComponent, EntParentChangedMessage>(OnAutoParentChange);
|
||||||
|
|
||||||
SubscribeLocalEvent<FollowedComponent, EntParentChangedMessage>(OnFollowedParentChange);
|
SubscribeLocalEvent<FollowedComponent, EntParentChangedMessage>(OnFollowedParentChange);
|
||||||
|
|
||||||
_configManager.OnValueChanged(CCVars.CameraRotationLocked, SetCameraRotationLocked, true);
|
_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) {}
|
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)
|
public void RotateCamera(EntityUid uid, Angle angle)
|
||||||
{
|
{
|
||||||
if (CameraRotationLocked || !TryComp<InputMoverComponent>(uid, out var mover))
|
if (CameraRotationLocked || !TryComp<InputMoverComponent>(uid, out var mover))
|
||||||
|
|||||||
Reference in New Issue
Block a user