using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Robust.Shared.Containers;
-using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
}
// if tool use ever gets predicted this needs changing.
- _popupSystem.PopupEntity(Loc.GetString("headset-encryption-keys-all-extracted"), uid, args.User);
+ _popupSystem.PopupEntity(Loc.GetString("encryption-keys-all-extracted"), uid, args.User);
_audio.PlayPvs(component.KeyExtractionSound, uid);
component.Removing = false;
}
private void OnInteractUsing(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
{
- if (!TryComp<ContainerManagerComponent>(uid, out var storage) || args.Handled || component.Removing)
+ if (!TryComp<ContainerManagerComponent>(uid, out var _) || args.Handled || component.Removing)
return;
-
+ if (!component.KeysUnlocked)
+ {
+ if (_timing.IsFirstTimePredicted)
+ _popupSystem.PopupEntity(Loc.GetString("encryption-keys-are-locked"), uid, args.User);
+ return;
+ }
if (TryComp<EncryptionKeyComponent>(args.Used, out var key))
{
- args.Handled = true;
+ TryInsertKey(uid, component, args);
+ }
+ else
+ {
+ TryRemoveKey(uid, component, args);
+ }
+ }
- if (!component.KeysUnlocked)
- {
- if (_timing.IsFirstTimePredicted)
- _popupSystem.PopupEntity(Loc.GetString("headset-encryption-keys-are-locked"), uid, Filter.Local(), false);
- return;
- }
+ private void TryInsertKey(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
+ {
+ args.Handled = true;
- if (component.KeySlots <= component.KeyContainer.ContainedEntities.Count)
- {
- if (_timing.IsFirstTimePredicted)
- _popupSystem.PopupEntity(Loc.GetString("headset-encryption-key-slots-already-full"), uid, Filter.Local(), false);
- return;
- }
+ if (component.KeySlots <= component.KeyContainer.ContainedEntities.Count)
+ {
+ if (_timing.IsFirstTimePredicted)
+ _popupSystem.PopupEntity(Loc.GetString("encryption-key-slots-already-full"), uid, args.User);
+ return;
+ }
- if (component.KeyContainer.Insert(args.Used))
- {
- if (_timing.IsFirstTimePredicted)
- _popupSystem.PopupEntity(Loc.GetString("headset-encryption-key-successfully-installed"), uid, Filter.Local(), false);
- _audio.PlayPredicted(component.KeyInsertionSound, args.Target, args.User);
- return;
- }
+ if (component.KeyContainer.Insert(args.Used))
+ {
+ if (_timing.IsFirstTimePredicted)
+ _popupSystem.PopupEntity(Loc.GetString("encryption-key-successfully-installed"), uid, args.User);
+ _audio.PlayPredicted(component.KeyInsertionSound, args.Target, args.User);
+ return;
}
+ }
+ private void TryRemoveKey(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
+ {
if (!TryComp<ToolComponent>(args.Used, out var tool) || !tool.Qualities.Contains(component.KeysExtractionMethod))
return;
-
+
args.Handled = true;
if (component.KeyContainer.ContainedEntities.Count == 0)
{
if (_timing.IsFirstTimePredicted)
- _popupSystem.PopupEntity(Loc.GetString("headset-encryption-keys-no-keys"), uid, Filter.Local(), false);
+ _popupSystem.PopupEntity(Loc.GetString("encryption-keys-no-keys"), uid, args.User);
return;
}
var toolEvData = new ToolEventData(new EncryptionRemovalFinishedEvent(args.User), cancelledEv: new EncryptionRemovalCancelledEvent(), targetEntity: uid);
- if(!_toolSystem.UseTool(args.Used, args.User, uid, 1f, new[] { component.KeysExtractionMethod }, toolEvData, toolComponent: tool))
- return;
+ _toolSystem.UseTool(args.Used, args.User, uid, 1f, new[] { component.KeysExtractionMethod }, toolEvData, toolComponent: tool);
}
private void OnStartup(EntityUid uid, EncryptionKeyHolderComponent component, ComponentStartup args)
if (component.KeyContainer.ContainedEntities.Count == 0)
{
- args.PushMarkup(Loc.GetString("examine-headset-no-keys"));
+ args.PushMarkup(Loc.GetString("encryption-keys-no-keys"));
return;
}
if (component.Channels.Count > 0)
{
- args.PushMarkup(Loc.GetString("examine-headset-channels-prefix"));
- AddChannelsExamine(component.Channels, component.DefaultChannel, args, _protoManager, "examine-headset-channel");
+ args.PushMarkup(Loc.GetString("examine-encryption-channels-prefix"));
+ AddChannelsExamine(component.Channels, component.DefaultChannel, args, _protoManager, "examine-encryption-channel");
}
}
if(component.Channels.Count > 0)
{
- args.PushMarkup(Loc.GetString("examine-encryption-key-channels-prefix"));
- AddChannelsExamine(component.Channels, component.DefaultChannel, args, _protoManager, "examine-headset-channel");
+ args.PushMarkup(Loc.GetString("examine-encryption-channels-prefix"));
+ AddChannelsExamine(component.Channels, component.DefaultChannel, args, _protoManager, "examine-encryption-channel");
}
}
RadioChannelPrototype? proto;
foreach (var id in channels)
{
- proto = protoManager.Index<RadioChannelPrototype>(id);
+ proto = _protoManager.Index<RadioChannelPrototype>(id);
var key = id == SharedChatSystem.CommonChannel
? SharedChatSystem.RadioCommonPrefix.ToString()
if (defaultChannel != null && _protoManager.TryIndex(defaultChannel, out proto))
{
- var msg = Loc.GetString("examine-default-channel",
+ if (HasComp<HeadsetComponent>(examineEvent.Examined))
+ {
+ var msg = Loc.GetString("examine-headset-default-channel",
("prefix", SharedChatSystem.DefaultChannelPrefix),
("channel", defaultChannel),
("color", proto.Color));
- examineEvent.PushMarkup(msg);
+ examineEvent.PushMarkup(msg);
+ }
+ if (HasComp<EncryptionKeyComponent>(examineEvent.Examined))
+ {
+ var msg = Loc.GetString("examine-encryption-default-channel",
+ ("channel", defaultChannel),
+ ("color", proto.Color));
+ examineEvent.PushMarkup(msg);
+ }
}
}
--- /dev/null
+- type: entity
+ parent: [ BaseMachinePowered, ConstructibleMachine ]
+ id: TelecomServer
+ name: telecommunication server
+ description: When powered and filled with encryption keys it allows radio headset communication
+ components:
+ - type: Sprite
+ sprite: Structures/Machines/telecomms.rsi
+ snapCardinals: true
+ netsync: false
+ layers:
+ - state: icon
+ - state: unlit
+ shader: unshaded
+ map: ["enum.PowerDeviceVisualLayers.Powered"]
+ - state: panel
+ map: ["enum.WiresVisualLayers.MaintenancePanel"]
+ - type: GenericVisualizer
+ visuals:
+ enum.PowerDeviceVisuals.Powered:
+ enum.PowerDeviceVisualLayers.Powered:
+ True: { visible: true }
+ False: { visible: false }
+ - type: Appearance
+ - type: WiresVisuals
+ - type: Physics
+ bodyType: Static
+ - type: Fixtures
+ fixtures:
+ - shape:
+ !type:PhysShapeAabb
+ bounds: "-0.4,-0.4,0.4,0.4"
+ density: 190
+ mask:
+ - MachineMask
+ layer:
+ - MachineLayer
+ - type: Destructible
+ thresholds:
+ - trigger:
+ !type:DamageTrigger
+ damage: 100
+ behaviors:
+ - !type:ChangeConstructionNodeBehavior
+ node: machineFrame
+ - !type:DoActsBehavior
+ acts: ["Destruction"]
+ - type: Machine
+ board: TelecomServerCircuitboard
+ - type: Wires
+ BoardName: "TelecomServer"
+ LayoutId: TelecomServer
+ - type: Transform
+ anchored: true
+ - type: Pullable
+ - type: EncryptionKeyHolder
+ keysExtractionMethod: Prying
+ keySlots: 10
+ - type: TelecomServer
+ - type: ContainerContainer
+ containers:
+ key_slots: !type:Container
+ machine_board: !type:Container
+ machine_parts: !type:Container
+
+- type: entity
+ parent: TelecomServer
+ id: TelecomServerFilled
+ suffix: Filled
+ components:
+ - type: ContainerFill
+ containers:
+ key_slots:
+ - EncryptionKeyCommon
+ - EncryptionKeyCargo
+ - EncryptionKeyEngineering
+ - EncryptionKeyMedical
+ - EncryptionKeyScience
+ - EncryptionKeySecurity
+ - EncryptionKeyService
+ - EncryptionKeyCommand