]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add telecommunication server (#14415)
authorSlava0135 <40753025+Slava0135@users.noreply.github.com>
Mon, 6 Mar 2023 21:11:36 +0000 (00:11 +0300)
committerGitHub <noreply@github.com>
Mon, 6 Mar 2023 21:11:36 +0000 (17:11 -0400)
14 files changed:
Content.Server/Radio/EntitySystems/TelecomSystem.cs [new file with mode: 0644]
Content.Shared/Radio/Components/TelecomServerComponent.cs [new file with mode: 0644]
Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs
Resources/Locale/en-US/headset/headset-component.ftl
Resources/Locale/en-US/radio/components/encryption-key-component.ftl [new file with mode: 0644]
Resources/Prototypes/Catalog/Research/technologies.yml
Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml
Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Resources/Prototypes/Entities/Structures/Machines/telecomms.yml [new file with mode: 0644]
Resources/Prototypes/Recipes/Lathes/electronics.yml
Resources/Textures/Structures/Machines/telecomms.rsi/icon.png [new file with mode: 0644]
Resources/Textures/Structures/Machines/telecomms.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Structures/Machines/telecomms.rsi/panel.png [new file with mode: 0644]
Resources/Textures/Structures/Machines/telecomms.rsi/unlit.png [new file with mode: 0644]

diff --git a/Content.Server/Radio/EntitySystems/TelecomSystem.cs b/Content.Server/Radio/EntitySystems/TelecomSystem.cs
new file mode 100644 (file)
index 0000000..b4d8897
--- /dev/null
@@ -0,0 +1,5 @@
+namespace Content.Server.Radio.EntitySystems;
+
+public sealed class TelecomSystem : EntitySystem
+{
+}
diff --git a/Content.Shared/Radio/Components/TelecomServerComponent.cs b/Content.Shared/Radio/Components/TelecomServerComponent.cs
new file mode 100644 (file)
index 0000000..2aa003a
--- /dev/null
@@ -0,0 +1,6 @@
+namespace Content.Shared.Radio.Components;
+
+[RegisterComponent]
+public sealed class TelecomServerComponent : Component
+{
+}
\ No newline at end of file
index e3c60b99f97bc503645b3fc5e623e4cf5f32d6d7..96e7863c868aeb084325d0646b81f8946eb0d1eb 100644 (file)
@@ -8,7 +8,6 @@ using Content.Shared.Radio.Components;
 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;
 
@@ -56,7 +55,7 @@ public sealed class EncryptionKeySystem : EntitySystem
         }
 
         // 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;
     }
@@ -89,45 +88,55 @@ public sealed class EncryptionKeySystem : EntitySystem
 
     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;
         }
 
@@ -136,8 +145,7 @@ public sealed class EncryptionKeySystem : EntitySystem
 
         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)
@@ -153,14 +161,14 @@ public sealed class EncryptionKeySystem : EntitySystem
 
         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");
         }
     }
 
@@ -171,8 +179,8 @@ public sealed class EncryptionKeySystem : EntitySystem
 
         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");
         }
     }
 
@@ -187,7 +195,7 @@ public sealed class EncryptionKeySystem : EntitySystem
         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()
@@ -202,11 +210,21 @@ public sealed class EncryptionKeySystem : EntitySystem
 
         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);
+            }
         }
     }
 
index e4706ecad2f8e99ca13fcd80c48d88a227f4289b..7a1637c9d373ecc1a2db403b32d3ee91492f63b4 100644 (file)
@@ -1,22 +1,7 @@
 # Chat window radio wrap (prefix and postfix)
 chat-radio-message-wrap = [color={$color}]{$channel} {$name} says: "{$message}"[/color]
 
-headset-encryption-key-successfully-installed = You put the key into the headset.
-headset-encryption-key-slots-already-full = There is no place for another key.
-headset-encryption-keys-all-extracted = You pop out the encryption keys from the headset!
-headset-encryption-keys-no-keys = This headset has no encryption keys!
-headset-encryption-keys-are-locked = The headset's key slots are locked, you cannot add or remove any keys.
-
-examine-encryption-key-channels-prefix = It is providing these frequencies to the headset:
-
-examine-radio-frequency = It's set to broadcast over the {$frequency} frequency.
-
-examine-headset-channels-prefix = A small screen on the headset displays the following available frequencies:
-examine-headset-channel = [color={$color}]{$key} for {$id} ({$freq})[/color]
-examine-headset-no-keys = It seems broken. There are no encryption keys in it.
-examine-default-channel = Use {$prefix} for the default channel ([color={$color}]{$channel}[/color]).
-examine-headset-default-channel = It indicates that the default channel of this headset is [color={$color}]{$channel}[/color].
-examine-encryption-key-default-channel = The default channel is [color={$color}]{$channel}[/color].
+examine-headset-default-channel = Use {$prefix} for the default channel ([color={$color}]{$channel}[/color]).
 
 chat-radio-common = Common
 chat-radio-centcom = CentCom
diff --git a/Resources/Locale/en-US/radio/components/encryption-key-component.ftl b/Resources/Locale/en-US/radio/components/encryption-key-component.ftl
new file mode 100644 (file)
index 0000000..6d9dc52
--- /dev/null
@@ -0,0 +1,9 @@
+encryption-key-successfully-installed = You put the encryption key inside.
+encryption-key-slots-already-full = There is no place for another encryption key.
+encryption-keys-all-extracted = You pop out the encryption keys!
+encryption-keys-no-keys = This device has no encryption keys!
+encryption-keys-are-locked = Encryption key slots are locked!
+
+examine-encryption-channels-prefix = Available frequencies:
+examine-encryption-channel = [color={$color}]{$key} for {$id} ({$freq})[/color]
+examine-encryption-default-channel = The default channel is [color={$color}]{$channel}[/color].
index 03b1edbb52e05bbaf0b67dc9e1d6e077c2c7e225..08156f9437a58fd79d4917c9b29961e2bc300508 100644 (file)
   - SignalTrigger
   - VoiceTrigger
   - TimerTrigger
+  - TelecomServerCircuitboard
 
 - type: technology
   name: technologies-electrical-engineering
index 42125ea3e4d27a57ca488dc203056574e566a91e..616a7293f7350ebd651193f2af6a79bb26febd09 100644 (file)
             Amount: 1
             DefaultPrototype: Beaker
             ExamineName: Glass Beaker
+
+- type: entity
+  id: TelecomServerCircuitboard
+  parent: BaseMachineCircuitboard
+  name: telecommunication server machine board 
+  description: A machine printed circuit board for an telecommunication server
+  components:
+    - type: MachineBoard
+      prototype: TelecomServer
+      requirements:
+        Capacitor: 1
+        ScanningModule: 2
+      materialRequirements:
+        Steel: 1
+        Cable: 2
index 6f7401b449a1a76e84c365964d35efad0283db27..582b9ce04b2766b37a9792c3dd12bdd2782e6554 100644 (file)
       - TraversalDistorterMachineCircuitboard
       - BoozeDispenserMachineCircuitboard
       - SodaDispenserMachineCircuitboard
+      - TelecomServerCircuitboard
   - type: MaterialStorage
     whitelist:
       tags:
diff --git a/Resources/Prototypes/Entities/Structures/Machines/telecomms.yml b/Resources/Prototypes/Entities/Structures/Machines/telecomms.yml
new file mode 100644 (file)
index 0000000..e319720
--- /dev/null
@@ -0,0 +1,81 @@
+- 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
index c2d8d6f1a99f194a61ffb7c4c04b0db2674e73c9..c5aea718000d715272ea3c0daa1a67a76ae35b56 100644 (file)
   materials:
      Steel: 100
      Glass: 900
+
+- type: latheRecipe
+  id: TelecomServerCircuitboard
+  result: TelecomServerCircuitboard
+  completetime: 4
+  materials:
+     Steel: 100
+     Glass: 900
diff --git a/Resources/Textures/Structures/Machines/telecomms.rsi/icon.png b/Resources/Textures/Structures/Machines/telecomms.rsi/icon.png
new file mode 100644 (file)
index 0000000..0f78e94
Binary files /dev/null and b/Resources/Textures/Structures/Machines/telecomms.rsi/icon.png differ
diff --git a/Resources/Textures/Structures/Machines/telecomms.rsi/meta.json b/Resources/Textures/Structures/Machines/telecomms.rsi/meta.json
new file mode 100644 (file)
index 0000000..d26455c
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/blob/9c3494fd79e6bf8dc532300b9de4f688ff276ac9/icons/obj/machines/telecomms.dmi",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "unlit",
+      "delays": [
+        [
+          0.1,
+          0.1,
+          0.1,
+          0.1,
+          0.1,
+          0.1,
+          0.1,
+          0.1,
+          0.1,
+          0.1
+        ]
+      ]
+    },
+    {
+      "name": "icon"
+    },
+    {
+      "name": "panel"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/Resources/Textures/Structures/Machines/telecomms.rsi/panel.png b/Resources/Textures/Structures/Machines/telecomms.rsi/panel.png
new file mode 100644 (file)
index 0000000..1ab3cfb
Binary files /dev/null and b/Resources/Textures/Structures/Machines/telecomms.rsi/panel.png differ
diff --git a/Resources/Textures/Structures/Machines/telecomms.rsi/unlit.png b/Resources/Textures/Structures/Machines/telecomms.rsi/unlit.png
new file mode 100644 (file)
index 0000000..b804f4c
Binary files /dev/null and b/Resources/Textures/Structures/Machines/telecomms.rsi/unlit.png differ