-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 2024-09-17-vox-loadouts
- Loading branch information
Showing
16 changed files
with
1,745 additions
and
1,669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Content.Server.Shuttles.Components; | ||
|
||
/// <summary> | ||
/// Lets you remotely control a shuttle. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class NFDroneConsoleComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public string Id = default!; | ||
|
||
/// <summary> | ||
/// <see cref="ShuttleConsoleComponent"/> that we're proxied into. | ||
/// </summary> | ||
[DataField] | ||
public EntityUid? Entity; | ||
} |
11 changes: 11 additions & 0 deletions
11
Content.Server/_NF/Shuttles/NFDroneConsoleTargetComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Content.Server.Shuttles; | ||
|
||
/// <summary> | ||
/// Lets you remotely control a shuttle. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class NFDroneConsoleTargetComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public string Id = default!; | ||
} |
69 changes: 69 additions & 0 deletions
69
Content.Server/_NF/Shuttles/Systems/ShuttleConsoleSystem.NFDrone.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using Content.Server.Shuttles.Components; | ||
using Content.Server.Shuttles.Events; | ||
using Content.Shared.UserInterface; | ||
using Content.Shared.Shuttles.Components; | ||
|
||
namespace Content.Server.Shuttles.Systems; | ||
|
||
public sealed partial class ShuttleConsoleSystem | ||
{ | ||
public void InitializeNFDrone() | ||
{ | ||
SubscribeLocalEvent<NFDroneConsoleComponent, ConsoleShuttleEvent>(OnNFCargoGetConsole); | ||
SubscribeLocalEvent<NFDroneConsoleComponent, AfterActivatableUIOpenEvent>(OnNFDronePilotConsoleOpen); | ||
Subs.BuiEvents<NFDroneConsoleComponent>(ShuttleConsoleUiKey.Key, subs => | ||
{ | ||
subs.Event<BoundUIClosedEvent>(OnNFDronePilotConsoleClose); | ||
}); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the drone console target if applicable otherwise returns itself. | ||
/// </summary> | ||
public EntityUid? GetNFDroneConsole(EntityUid consoleUid) | ||
{ | ||
var getShuttleEv = new ConsoleShuttleEvent | ||
{ | ||
Console = consoleUid, | ||
}; | ||
|
||
RaiseLocalEvent(consoleUid, ref getShuttleEv); | ||
return getShuttleEv.Console; | ||
} | ||
|
||
private void OnNFDronePilotConsoleOpen(EntityUid uid, NFDroneConsoleComponent component, AfterActivatableUIOpenEvent args) | ||
{ | ||
component.Entity = GetNFShuttleConsole(uid); | ||
} | ||
|
||
private void OnNFDronePilotConsoleClose(EntityUid uid, NFDroneConsoleComponent component, BoundUIClosedEvent args) | ||
{ | ||
// Only if last person closed UI. | ||
if (!_ui.IsUiOpen(uid, args.UiKey)) | ||
component.Entity = null; | ||
} | ||
|
||
private void OnNFCargoGetConsole(EntityUid uid, NFDroneConsoleComponent component, ref ConsoleShuttleEvent args) | ||
{ | ||
args.Console = GetNFShuttleConsole(uid, component); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the relevant shuttle console to proxy from the drone console. | ||
/// </summary> | ||
private EntityUid? GetNFShuttleConsole(EntityUid uid, NFDroneConsoleComponent? sourceComp = null) | ||
{ | ||
if (!Resolve(uid, ref sourceComp)) | ||
return null; | ||
|
||
var query = AllEntityQuery<ShuttleConsoleComponent, NFDroneConsoleTargetComponent>(); | ||
|
||
while (query.MoveNext(out var cUid, out _, out var targetComp)) | ||
{ | ||
if (sourceComp.Id == targetComp.Id) | ||
return cUid; | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.