Skip to content

Commit

Permalink
IPCs now use integrated radios!
Browse files Browse the repository at this point in the history
IPCs now have blank RadioReceiver, Transmitter, and Active components which get updated by their EncryptionKeyHolderComponent (had to write a system for that).
Their encryption keys get filled in based on their job's headset with some modifications to StationSpawningSystem that I'm not super proud of...
  • Loading branch information
Pspritechologist committed Jun 22, 2023
1 parent e0e3ad2 commit cdf6318
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ namespace Content.Server.Radio.Components;
public sealed class IntrinsicRadioTransmitterComponent : Component
{
[DataField("channels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
public readonly HashSet<string> Channels = new() { SharedChatSystem.CommonChannel };
public HashSet<string> Channels = new() { SharedChatSystem.CommonChannel }; // Parkstation-IPC // Did this really need to be readonly? :prerealization:
}
32 changes: 32 additions & 0 deletions Content.Server/SimpleStation14/Radio/IntrinsicRadioKeySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Content.Server.Radio.Components;
using Content.Shared.Radio;
using Content.Shared.Radio.Components;

namespace Content.Server.SimpleStation14.Radio;

public sealed class IntrinsicRadioKeySystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<IntrinsicRadioTransmitterComponent, EncryptionChannelsChangedEvent>(OnTransmitterChannelsChanged);
SubscribeLocalEvent<ActiveRadioComponent, EncryptionChannelsChangedEvent>(OnReceiverChannelsChanged);
}

private void OnTransmitterChannelsChanged(EntityUid uid, IntrinsicRadioTransmitterComponent component, EncryptionChannelsChangedEvent args)
{
UpdateChannels(uid, args.Component, ref component.Channels);
}

private void OnReceiverChannelsChanged(EntityUid uid, ActiveRadioComponent component, EncryptionChannelsChangedEvent args)
{
UpdateChannels(uid, args.Component, ref component.Channels);
}

private void UpdateChannels(EntityUid uid, EncryptionKeyHolderComponent keyHolderComp, ref HashSet<string> channels)
{
channels.Clear();
channels.UnionWith(keyHolderComp.Channels);
}
}
30 changes: 30 additions & 0 deletions Content.Server/Station/Systems/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Shared.Radio.Components; // Parkstation-IPC
using Content.Shared.Containers; // Parkstation-IPC

namespace Content.Server.Station.Systems;

Expand Down Expand Up @@ -190,6 +192,34 @@ public void EquipStartingGear(EntityUid entity, StartingGearPrototype startingGe
}
}

// Parkstation-IPC-Start
// This is kinda gross, and weird, and very hardcoded, but it's the best way I could think of to do it.
// If they have an EncryptionKeyHolderComponent, spawn in their headset, find the
// EncryptionKeyHolderComponent on it, move the keys over, and delete the headset.
if (TryComp<EncryptionKeyHolderComponent>(entity, out var keyHolderComp))
{
var earEquipString = startingGear.GetGear("ears", profile);

if (string.IsNullOrEmpty(earEquipString))
return;

var earEntity = Spawn(earEquipString, Transform(entity).Coordinates);

if (TryComp<EncryptionKeyHolderComponent>(earEntity, out _) && // I had initially wanted this to spawn the headset, and simply move all the keys over, but the headset didn't seem to have any keys in it when spawned...
TryComp<ContainerFillComponent>(earEntity, out var fillComp) &&
fillComp.Containers.TryGetValue(EncryptionKeyHolderComponent.KeyContainerName, out var defaultKeys))
{
foreach (var key in defaultKeys)
{
var keyEntity = Spawn(key, Transform(entity).Coordinates);
keyHolderComp.KeyContainer.Insert(keyEntity, force: true);
}
}

EntityManager.QueueDeleteEntity(earEntity);
}
// Parkstation-IPC-End

if (!TryComp(entity, out HandsComponent? handsComponent))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public sealed class EncryptionKeyHolderComponent : Component
public Container KeyContainer = default!;
public const string KeyContainerName = "key_slots";

// Parkstation-IPC-Start
/// <summary>
/// Whether or not the headset can be examined to see the encryption keys while the keys aren't accessible.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("examineWhileLocked")]
public bool ExamineWhileLocked = true;
// Parkstation-IPC-End

/// <summary>
/// Combined set of radio channels provided by all contained keys.
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ private void OnHolderExamined(EntityUid uid, EncryptionKeyHolderComponent compon
if (!args.IsInDetailsRange)
return;

// Parkstation-IPC-Start
if (!component.ExamineWhileLocked && !component.KeysUnlocked)
return;

if (!component.ExamineWhileLocked && TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
return;
// Parkstation-IPC-End

if (component.KeyContainer.ContainedEntities.Count == 0)
{
args.PushMarkup(Loc.GetString("encryption-keys-no-keys"));
Expand Down
10 changes: 10 additions & 0 deletions Resources/Prototypes/SimpleStation14/Entities/Mobs/Player/ipc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
4: 0.00
- type: Carriable
- type: BatteryDrinker
- type: EncryptionKeyHolder
keySlots: 3
examineWhileLocked: false
keysExtractionMethod: Cutting
- type: ActiveRadio
- type: IntrinsicRadioReceiver
- type: IntrinsicRadioTransmitter
- type: Wires
BoardName: "IPC"
LayoutId: IPC

- type: entity
save: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
- map: ["enum.HumanoidVisualLayers.RLeg"]
- map: ["enum.HumanoidVisualLayers.LLeg"]
- shader: StencilClear
sprite: SimpleStation14/Mobs/Species/IPC/parts.rsi
sprite: Mobs/Species/Human/parts.rsi
state: l_leg
- shader: StencilMask
map: ["enum.HumanoidVisualLayers.StencilMask"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@
# uiWindowPos: 0,0
# strippingWindowPos: 0,0
# displayName: Eyes
- name: ears
slotTexture: ears
slotFlags: EARS
stripTime: 3
uiWindowPos: 2,0
strippingWindowPos: 2,0
displayName: Ears
# - name: ears
# slotTexture: ears
# slotFlags: EARS
# stripTime: 3
# uiWindowPos: 2,0
# strippingWindowPos: 2,0
# displayName: Ears
- name: head
slotTexture: head
slotFlags: HEAD
uiWindowPos: 1,0
strippingWindowPos: 1,0
displayName: Head
offset: 0, 0.03125
offset: 0, 0
- name: pocket1
slotTexture: pocket
slotFlags: POCKET
Expand Down

0 comments on commit cdf6318

Please sign in to comment.