Files
wwdpublic/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.Drone.cs
metalgearsloth f102e8ff75 Shuttle console + FTL rework (#24430)
* Add shuttle interior drawing back

Just do it per-tile she'll be right, at least it's done with 1 draw call.

* Revamp shuttle console

* Bunch of cleanup work

* Lables sortito

* dok

* Pixel alignment and colours

* Fix a bunch of drawing bugs

* Shuttle map drawing

* Drawing fixes

* Map parallax working finally

* weh

* Commit all my stuff

* mic

* deez

* Update everything

* Xamlify everything

* uh

* Rudimentary blocker range

* My enemies have succeeded

* Bunch of changes to FTL

* Heaps of cleanup

* Fix FTL bugs

* FTL

* weewoo

* FTL fallback

* wew

* weh

* Basic FTL working

* FTL working

* FTL destination fixes

* a

* Exclusion zones

* Fix drawing / FTL

* Beacons working

* Coordinates drawing

* Fix unknown map names

* Dorks beginning

* State + docking cleanup start

* Basic dock drawing

* Bunch of drawing fixes

* Batching / color fixes

* Cleanup and beacons support

* weh

* weh

* Begin pings

* First draft at map objects

* Map fixup

* Faster drawing

* Fix perf + FTL

* Cached drawing

* Fix drawing

* Best I got

* strips

* Back to lists but with caching

* Final optimisation

* Fix dock bounds

* Docking work

* stinker

* kobolds

* Btns

* Docking vis working

* Fix docking pre-vis

* canasses

* Helldivers 2

* a

* Array life

* Fix

* Fix TODOs

* liltenhead feature club

* dorking

* Merge artifacts

* Last-minute touchup

(cherry picked from commit c5486873db0d6826122eb1f30007e392fc101082)
2024-03-08 12:54:53 +01:00

91 lines
2.7 KiB
C#

using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Station.Components;
using Content.Shared.UserInterface;
namespace Content.Server.Shuttles.Systems;
public sealed partial class ShuttleConsoleSystem
{
/// <summary>
/// Gets the drone console target if applicable otherwise returns itself.
/// </summary>
private EntityUid? GetDroneConsole(EntityUid consoleUid)
{
var getShuttleEv = new ConsoleShuttleEvent
{
Console = consoleUid,
};
RaiseLocalEvent(consoleUid, ref getShuttleEv);
return getShuttleEv.Console;
}
/// <summary>
/// Refreshes all drone console entities.
/// </summary>
public void RefreshDroneConsoles()
{
var query = AllEntityQuery<DroneConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
comp.Entity = GetShuttleConsole(uid, comp);
}
}
private void OnDronePilotConsoleOpen(EntityUid uid, DroneConsoleComponent component, AfterActivatableUIOpenEvent args)
{
component.Entity = GetShuttleConsole(uid);
}
private void OnDronePilotConsoleClose(EntityUid uid, DroneConsoleComponent component, BoundUIClosedEvent args)
{
// Only if last person closed UI.
if (!_ui.IsUiOpen(uid, args.UiKey))
component.Entity = null;
}
private void OnCargoGetConsole(EntityUid uid, DroneConsoleComponent component, ref ConsoleShuttleEvent args)
{
args.Console = GetShuttleConsole(uid, component);
}
/// <summary>
/// Gets the relevant shuttle console to proxy from the drone console.
/// </summary>
private EntityUid? GetShuttleConsole(EntityUid uid, DroneConsoleComponent? component = null)
{
if (!Resolve(uid, ref component))
return null;
var stationUid = _station.GetOwningStation(uid);
if (stationUid == null)
return null;
// I know this sucks but needs device linking or something idunno
var query = AllEntityQuery<ShuttleConsoleComponent, TransformComponent>();
while (query.MoveNext(out var cUid, out _, out var xform))
{
if (xform.GridUid == null ||
!TryComp<StationMemberComponent>(xform.GridUid, out var member) ||
member.Station != stationUid)
{
continue;
}
foreach (var compType in component.Components.Values)
{
if (!HasComp(xform.GridUid, compType.Component.GetType()))
continue;
return cUid;
}
}
return null;
}
}