This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
forked from new-frontiers-14/frontier-station-14
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from FireNameFN/FaxMultiaddress
Ability to send fax to all shuttles
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
Content.Server/Corvax/FaxMultiaddress/FaxMultiaddressComponent.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,4 @@ | ||
namespace Content.Server.Corvax.FaxMultiaddress; | ||
|
||
[RegisterComponent] | ||
public sealed partial class FaxMultiaddressComponent : Component; |
69 changes: 69 additions & 0 deletions
69
Content.Server/Corvax/FaxMultiaddress/FaxMultiaddressSystem.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.DeviceNetwork; | ||
using Content.Server.DeviceNetwork.Components; | ||
using Content.Server.DeviceNetwork.Systems; | ||
using Content.Server.Fax; | ||
using Content.Shared.Fax.Components; | ||
using Content.Shared.GameTicking; | ||
using Content.Shared.Paper; | ||
using Content.Shared.Shipyard.Components; | ||
|
||
namespace Content.Server.Corvax.FaxMultiaddress; | ||
|
||
public sealed class FaxMultiaddressSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly DeviceNetworkSystem _network = default!; | ||
[Dependency] private readonly FaxSystem _fax = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<RoundStartedEvent>(OnRoundStarted); | ||
SubscribeLocalEvent<FaxMultiaddressComponent, DeviceNetworkPacketEvent>(OnDeviceNetworkPacket); | ||
} | ||
|
||
private void OnRoundStarted(RoundStartedEvent e) | ||
{ | ||
Spawn("FaxMultiaddress"); | ||
} | ||
|
||
private void OnDeviceNetworkPacket(EntityUid entity, FaxMultiaddressComponent component, DeviceNetworkPacketEvent e) | ||
{ | ||
if (!TryComp<DeviceNetworkComponent>(entity, out var device)) | ||
return; | ||
|
||
if (!e.Data.TryGetValue(DeviceNetworkConstants.Command, out string? command)) | ||
return; | ||
|
||
switch (command) | ||
{ | ||
case FaxConstants.FaxPingCommand: | ||
_network.QueuePacket(entity, e.SenderAddress, new() | ||
{ | ||
[DeviceNetworkConstants.Command] = FaxConstants.FaxPongCommand, | ||
[FaxConstants.FaxNameData] = "All Shuttles" | ||
}); | ||
|
||
break; | ||
case FaxConstants.FaxPrintCommand: | ||
if (!e.Data.TryGetValue(FaxConstants.FaxPaperNameData, out string? name)) | ||
return; | ||
|
||
if (!e.Data.TryGetValue(FaxConstants.FaxPaperContentData, out string? content)) | ||
return; | ||
|
||
e.Data.TryGetValue(FaxConstants.FaxPaperLabelData, out string? label); | ||
e.Data.TryGetValue(FaxConstants.FaxPaperStampStateData, out string? stampState); | ||
e.Data.TryGetValue(FaxConstants.FaxPaperStampedByData, out List<StampDisplayInfo>? stampedBy); | ||
e.Data.TryGetValue(FaxConstants.FaxPaperPrototypeData, out string? prototype); | ||
|
||
FaxPrintout printout = new(content, name, label, prototype, stampState, stampedBy); | ||
|
||
var faxes = AllEntityQuery<FaxMachineComponent>(); | ||
|
||
while (faxes.MoveNext(out var fax, out var faxComponent)) | ||
if (fax != e.Sender && HasComp<ShuttleDeedComponent>(Transform(fax).GridUid)) | ||
_fax.Receive(fax, printout, device.Address, faxComponent); | ||
|
||
break; | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Resources/Prototypes/CorvaxFrontier/Entities/fax_multiaddress.yml
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,8 @@ | ||
- type: entity | ||
id: FaxMultiaddress | ||
components: | ||
- type: FaxMultiaddress | ||
- type: DeviceNetwork | ||
deviceNetId: Wireless | ||
receiveFrequencyId: Fax | ||
transmitFrequencyId: Fax |