]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Rodents can be Faxecuted (executed via Fax machine) (#21461)
authorbrainfood1183 <113240905+brainfood1183@users.noreply.github.com>
Sat, 27 Apr 2024 13:50:57 +0000 (14:50 +0100)
committerGitHub <noreply@github.com>
Sat, 27 Apr 2024 13:50:57 +0000 (23:50 +1000)
* Rodents can be Faxecuted (executed via Fax machine)

* use brute instead of new group.

* fax visuals now use tags for mouse and hamster instead of comps

* fix for ubuntu, damn ubuntu bane of my life

* cant copy hamlet, can now faxecute mothroaches.

* fix

* fix

* fixes

* removed ifs now using switch, removed hastag now using string.

* fixes and no more switch

* cleanup

* more cleanup

* fix

* cleanup

* moved damage out of faxmachine and into own system and component.

* changes

* fixes and done i think.

* tidy

* Fixes

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
18 files changed:
Content.Client/Fax/System/FaxVisualsSystem.cs [new file with mode: 0644]
Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs
Content.Server/Fax/AdminUI/AdminFaxEui.cs
Content.Server/Fax/FaxSystem.cs
Content.Server/Nuke/NukeCodePaperSystem.cs
Content.Shared/Fax/Components/FaxMachineComponent.cs [moved from Content.Server/Fax/FaxMachineComponent.cs with 84% similarity]
Content.Shared/Fax/Components/FaxableObjectComponent.cs [new file with mode: 0644]
Content.Shared/Fax/Components/FaxecuteComponent.cs [new file with mode: 0644]
Content.Shared/Fax/DamageOnFaxecuteEvent.cs [new file with mode: 0644]
Content.Shared/Fax/Systems/FaxecuteSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/fax/fax.ftl
Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Resources/Prototypes/Entities/Objects/Misc/paper.yml
Resources/Prototypes/Entities/Structures/Machines/fax_machine.yml
Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_hamster.png [new file with mode: 0644]
Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mothroach.png [new file with mode: 0644]
Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mouse.png [new file with mode: 0644]
Resources/Textures/Structures/Machines/fax_machine.rsi/meta.json

diff --git a/Content.Client/Fax/System/FaxVisualsSystem.cs b/Content.Client/Fax/System/FaxVisualsSystem.cs
new file mode 100644 (file)
index 0000000..892aec1
--- /dev/null
@@ -0,0 +1,48 @@
+using Robust.Client.GameObjects;
+using Content.Shared.Fax.Components;
+using Content.Shared.Fax;
+using Robust.Client.Animations;
+
+namespace Content.Client.Fax.System;
+
+/// <summary>
+/// Visualizer for the fax machine which displays the correct sprite based on the inserted entity.
+/// </summary>
+public sealed class FaxVisualsSystem : EntitySystem
+{
+    [Dependency] private readonly AnimationPlayerSystem _player = default!;
+    [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<FaxMachineComponent, AppearanceChangeEvent>(OnAppearanceChanged);
+    }
+
+    private void OnAppearanceChanged(EntityUid uid, FaxMachineComponent component, ref AppearanceChangeEvent args)
+    {
+        if (args.Sprite == null)
+            return;
+
+        if (_appearance.TryGetData(uid, FaxMachineVisuals.VisualState, out FaxMachineVisualState visuals) && visuals == FaxMachineVisualState.Inserting)
+        {
+            _player.Play(uid, new Animation()
+            {
+                Length = TimeSpan.FromSeconds(2.4),
+                AnimationTracks =
+                {
+                    new AnimationTrackSpriteFlick()
+                    {
+                        LayerKey = FaxMachineVisuals.VisualState,
+                        KeyFrames =
+                        {
+                            new AnimationTrackSpriteFlick.KeyFrame(component.InsertingState, 0f),
+                            new AnimationTrackSpriteFlick.KeyFrame("icon", 2.4f),
+                        }
+                    }
+                }
+            }, "faxecute");
+        }
+    }
+}
index 94a3fe2186168adea915fa25b23922465b163e74..c375d97b8c3f7ed65d9ef34bf9ae8fba0e8a56ec 100644 (file)
@@ -20,7 +20,7 @@ public sealed class TransformableContainerSystem : EntitySystem
         SubscribeLocalEvent<TransformableContainerComponent, SolutionContainerChangedEvent>(OnSolutionChange);
     }
 
-    private void OnMapInit(Entity<TransformableContainerComponent> entity, ref MapInitEvent args)
+    private void OnMapInit(Entity<TransformableContainerComponent> entity, ref MapInitEvent args) 
     {
         var meta = MetaData(entity.Owner);
         if (string.IsNullOrEmpty(entity.Comp.InitialName))
index c8be6618e45eda64489d442a7d3f804e00fcd503..5153e6219565af1f5a0a48c15627a3ef361bac0a 100644 (file)
@@ -1,6 +1,7 @@
 using Content.Server.DeviceNetwork.Components;
 using Content.Server.EUI;
 using Content.Shared.Eui;
+using Content.Shared.Fax.Components;
 using Content.Shared.Fax;
 using Content.Shared.Follower;
 using Content.Shared.Ghost;
index f492595444aae54635babbbd43d93b334e3d2118..c21e0db20cc5cf520c56054e837ba6d8f4b206cd 100644 (file)
@@ -16,7 +16,10 @@ using Content.Shared.DeviceNetwork;
 using Content.Shared.Emag.Components;
 using Content.Shared.Emag.Systems;
 using Content.Shared.Fax;
+using Content.Shared.Fax.Systems;
+using Content.Shared.Fax.Components;
 using Content.Shared.Interaction;
+using Content.Shared.Mobs.Components;
 using Content.Shared.Paper;
 using Robust.Server.GameObjects;
 using Robust.Shared.Audio;
@@ -42,6 +45,7 @@ public sealed class FaxSystem : EntitySystem
     [Dependency] private readonly UserInterfaceSystem _userInterface = default!;
     [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
     [Dependency] private readonly MetaDataSystem _metaData = default!;
+    [Dependency] private readonly FaxecuteSystem _faxecute = default!;
 
     private const string PaperSlotId = "Paper";
 
@@ -313,12 +317,18 @@ public sealed class FaxSystem : EntitySystem
 
     private void OnCopyButtonPressed(EntityUid uid, FaxMachineComponent component, FaxCopyMessage args)
     {
-        Copy(uid, component, args);
+        if (HasComp<MobStateComponent>(component.PaperSlot.Item))
+            _faxecute.Faxecute(uid, component); /// when button pressed it will hurt the mob.
+        else
+            Copy(uid, component, args);
     }
 
     private void OnSendButtonPressed(EntityUid uid, FaxMachineComponent component, FaxSendMessage args)
     {
-        Send(uid, component, args.Actor);
+        if (HasComp<MobStateComponent>(component.PaperSlot.Item))
+            _faxecute.Faxecute(uid, component); /// when button pressed it will hurt the mob.
+        else
+            Send(uid, component, args.Actor);
     }
 
     private void OnRefreshButtonPressed(EntityUid uid, FaxMachineComponent component, FaxRefreshMessage args)
@@ -336,14 +346,20 @@ public sealed class FaxSystem : EntitySystem
         if (!Resolve(uid, ref component))
             return;
 
+        if (TryComp<FaxableObjectComponent>(component.PaperSlot.Item, out var faxable))
+            component.InsertingState = faxable.InsertingState;
+
+
         if (component.InsertingTimeRemaining > 0)
+        {
             _appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Inserting);
+            Dirty(uid, component);
+        }
         else if (component.PrintingTimeRemaining > 0)
             _appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Printing);
         else
             _appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Normal);
     }
-
     private void UpdateUserInterface(EntityUid uid, FaxMachineComponent? component = null)
     {
         if (!Resolve(uid, ref component))
@@ -477,7 +493,7 @@ public sealed class FaxSystem : EntitySystem
             return;
 
         if (!TryComp<MetaDataComponent>(sendEntity, out var metadata) ||
-            !TryComp<PaperComponent>(sendEntity, out var paper))
+           !TryComp<PaperComponent>(sendEntity, out var paper))
             return;
 
         var payload = new NetworkPayload()
index 8df25feebfabcaea92a07f5eb9413b00d21ea880..c1725536e7cea38dd50fb64b203aacb8d22114bb 100644 (file)
@@ -1,6 +1,7 @@
 using System.Diagnostics.CodeAnalysis;
 using Content.Server.Chat.Systems;
 using Content.Server.Fax;
+using Content.Shared.Fax.Components;
 using Content.Server.Paper;
 using Content.Server.Station.Components;
 using Content.Server.Station.Systems;
similarity index 84%
rename from Content.Server/Fax/FaxMachineComponent.cs
rename to Content.Shared/Fax/Components/FaxMachineComponent.cs
index d1f269dd37055b078b5cab0d7eace0a9920af42e..ee9459f5084057b485e1da248da5df3c20e7a993 100644 (file)
@@ -1,12 +1,13 @@
 using Content.Shared.Containers.ItemSlots;
 using Content.Shared.Paper;
 using Robust.Shared.Audio;
+using Robust.Shared.GameStates;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
 
-namespace Content.Server.Fax;
+namespace Content.Shared.Fax.Components;
 
-[RegisterComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
 public sealed partial class FaxMachineComponent : Component
 {
     /// <summary>
@@ -16,6 +17,13 @@ public sealed partial class FaxMachineComponent : Component
     [DataField("name")]
     public string FaxName { get; set; } = "Unknown";
 
+    /// <summary>
+    /// Sprite to use when inserting an object.
+    /// </summary>
+    [ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
+    public string InsertingState = "inserting";
+
     /// <summary>
     /// Device address of fax in network to which data will be send
     /// </summary>
@@ -26,7 +34,7 @@ public sealed partial class FaxMachineComponent : Component
     /// <summary>
     /// Contains the item to be sent, assumes it's paper...
     /// </summary>
-    [DataField("paperSlot", required: true)]
+    [DataField(required: true)]
     public ItemSlot PaperSlot = new();
 
     /// <summary>
@@ -34,39 +42,39 @@ public sealed partial class FaxMachineComponent : Component
     /// This will make it visible to others on the network
     /// </summary>
     [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("responsePings")]
+    [DataField]
     public bool ResponsePings { get; set; } = true;
 
     /// <summary>
     /// Should admins be notified on message receive
     /// </summary>
     [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("notifyAdmins")]
+    [DataField]
     public bool NotifyAdmins { get; set; } = false;
 
     /// <summary>
     /// Should that fax receive nuke codes send by admins. Probably should be captain fax only
     /// </summary>
     [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("receiveNukeCodes")]
+    [DataField]
     public bool ReceiveNukeCodes { get; set; } = false;
 
     /// <summary>
     /// Sound to play when fax has been emagged
     /// </summary>
-    [DataField("emagSound")]
+    [DataField]
     public SoundSpecifier EmagSound = new SoundCollectionSpecifier("sparks");
 
     /// <summary>
     /// Sound to play when fax printing new message
     /// </summary>
-    [DataField("printSound")]
+    [DataField]
     public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/printer.ogg");
 
     /// <summary>
     /// Sound to play when fax successfully send message
     /// </summary>
-    [DataField("sendSound")]
+    [DataField]
     public SoundSpecifier SendSound = new SoundPathSpecifier("/Audio/Machines/high_tech_confirm.ogg");
 
     /// <summary>
@@ -79,27 +87,27 @@ public sealed partial class FaxMachineComponent : Component
     /// Print queue of the incoming message
     /// </summary>
     [ViewVariables]
-    [DataField("printingQueue")]
+    [DataField]
     public Queue<FaxPrintout> PrintingQueue { get; private set; } = new();
 
     /// <summary>
     /// Message sending timeout
     /// </summary>
     [ViewVariables]
-    [DataField("sendTimeoutRemaining")]
+    [DataField]
     public float SendTimeoutRemaining;
 
     /// <summary>
     /// Message sending timeout
     /// </summary>
     [ViewVariables]
-    [DataField("sendTimeout")]
+    [DataField]
     public float SendTimeout = 5f;
 
     /// <summary>
     /// Remaining time of inserting animation
     /// </summary>
-    [DataField("insertingTimeRemaining")]
+    [DataField]
     public float InsertingTimeRemaining;
 
     /// <summary>
@@ -111,7 +119,7 @@ public sealed partial class FaxMachineComponent : Component
     /// <summary>
     /// Remaining time of printing animation
     /// </summary>
-    [DataField("printingTimeRemaining")]
+    [DataField]
     public float PrintingTimeRemaining;
 
     /// <summary>
@@ -124,13 +132,13 @@ public sealed partial class FaxMachineComponent : Component
 [DataDefinition]
 public sealed partial class FaxPrintout
 {
-    [DataField("name", required: true)]
+    [DataField(required: true)]
     public string Name { get; private set; } = default!;
 
-    [DataField("content", required: true)]
+    [DataField(required: true)]
     public string Content { get; private set; } = default!;
 
-    [DataField("prototypeId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>), required: true)]
+    [DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>), required: true)]
     public string PrototypeId { get; private set; } = default!;
 
     [DataField("stampState")]
diff --git a/Content.Shared/Fax/Components/FaxableObjectComponent.cs b/Content.Shared/Fax/Components/FaxableObjectComponent.cs
new file mode 100644 (file)
index 0000000..57b6e61
--- /dev/null
@@ -0,0 +1,16 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Fax.Components;
+/// <summary>
+/// Entity with this component can be faxed.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class FaxableObjectComponent : Component
+{
+    /// <summary>
+    /// Sprite to use when inserting an object.
+    /// </summary>
+    [ViewVariables(VVAccess.ReadWrite)]
+    [DataField, AutoNetworkedField]
+    public string InsertingState = "inserting";
+}
diff --git a/Content.Shared/Fax/Components/FaxecuteComponent.cs b/Content.Shared/Fax/Components/FaxecuteComponent.cs
new file mode 100644 (file)
index 0000000..9c9bd03
--- /dev/null
@@ -0,0 +1,19 @@
+using Content.Shared.Damage;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Fax.Components;
+
+/// <summary>
+/// A fax component which stores a damage specifier for attempting to fax a mob.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class FaxecuteComponent : Component
+{
+
+    /// <summary>
+    /// Type of damage dealt when entity is faxecuted.
+    /// </summary>
+    [DataField(required: true), AutoNetworkedField]
+    public DamageSpecifier Damage = new();
+}
+
diff --git a/Content.Shared/Fax/DamageOnFaxecuteEvent.cs b/Content.Shared/Fax/DamageOnFaxecuteEvent.cs
new file mode 100644 (file)
index 0000000..b36f55a
--- /dev/null
@@ -0,0 +1,9 @@
+
+namespace Content.Shared.Fax.Components;
+
+/// <summary>
+/// Event for killing any mob within the fax machine.
+/// </summary
+[ByRefEvent]
+public record struct DamageOnFaxecuteEvent(FaxMachineComponent? Action);
+
diff --git a/Content.Shared/Fax/Systems/FaxecuteSystem.cs b/Content.Shared/Fax/Systems/FaxecuteSystem.cs
new file mode 100644 (file)
index 0000000..7768c7a
--- /dev/null
@@ -0,0 +1,34 @@
+using Content.Shared.Damage;
+using Content.Shared.Popups;
+using Content.Shared.Fax.Components;
+
+namespace Content.Shared.Fax.Systems;
+/// <summary>
+/// System for handling execution of a mob within fax when copy or send attempt is made.
+/// </summary>
+public sealed class FaxecuteSystem : EntitySystem
+{
+    [Dependency] private readonly DamageableSystem _damageable = default!;
+    [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+    }
+
+    public void Faxecute(EntityUid uid, FaxMachineComponent component, DamageOnFaxecuteEvent? args = null)
+    {
+        var sendEntity = component.PaperSlot.Item;
+        if (sendEntity == null)
+            return;
+
+        if (!TryComp<FaxecuteComponent>(uid, out var faxecute))
+            return;
+
+        var damageSpec = faxecute.Damage;
+        _damageable.TryChangeDamage(sendEntity, damageSpec);
+        _popupSystem.PopupEntity(Loc.GetString("fax-machine-popup-error", ("target", uid)), uid, PopupType.LargeCaution);
+        return;
+
+    }
+}
index 1f1881a05d6ee9b5a3e2854b5d731fc8ea305f2c..412f3d7f4353041740a7aff91b2f15507a1b8e6e 100644 (file)
@@ -3,6 +3,8 @@ fax-machine-popup-received = Received correspondence from { $from }.
 fax-machine-popup-name-long = Fax name is too long
 fax-machine-popup-name-exist = Fax with same name already exist in network
 fax-machine-popup-name-set = Fax name has been updated
+fax-machine-popup-error = ERROR - jam in paper feed
+fax-machine-popup-copy-error = ERROR - unable to copy!
 
 fax-machine-dialog-rename = Rename
 fax-machine-dialog-field-name = Name
index ad5b51d998d1a465806944cc510ddf1733ad53a8..1cf56c29c6aea67e3e77182e572befd8b3dedacc 100644 (file)
   - type: Speech
     speechVerb: Moth
     speechSounds: Squeak
+  - type: FaxableObject
+    insertingState: inserting_mothroach
   - type: MothAccent
   - type: Sprite
     sprite: Mobs/Animals/mothroach.rsi
     rootTask:
       task: MouseCompound
   - type: Physics
+  - type: FaxableObject
+    insertingState: inserting_mouse
   - type: Fixtures
     fixtures:
       fix1:
   - type: Item
     size: Tiny
   - type: Physics
+  - type: FaxableObject
+    insertingState: inserting_hamster
   - type: Fixtures
     fixtures:
       fix1:
index 08e5e3caafd90a89fbdecf5f4de2fa57f6fdebd0..0c87459164a54519e42059223af9f6d81dee05a5 100644 (file)
@@ -32,6 +32,7 @@
     - Trash
     - Paper
   - type: Appearance
+  - type: FaxableObject
   - type: PaperVisuals
   - type: Flammable
     fireSpread: true
index 583b5e3548a18256ba8aa40ffddcd7e8d151bc99..36be6451d2094747b3ef133420dbb7a88eb74267 100644 (file)
@@ -1,4 +1,4 @@
-- type: entity
+- type: entity
   parent: BaseMachinePowered
   id: FaxMachineBase
   name: long range fax machine
@@ -9,7 +9,7 @@
     drawdepth: SmallObjects
     layers:
     - state: icon
-      map: ["base"]
+      map: [ "enum.FaxMachineVisuals.VisualState" ]
   - type: Icon
     sprite: Structures/Machines/fax_machine.rsi
     state: icon
         type: FaxBoundUi
   - type: ApcPowerReceiver
     powerLoad: 250
+  - type: Faxecute
+    damage:
+      types:
+        Blunt: 100
   - type: FaxMachine
     paperSlot:
       insertSound: /Audio/Machines/scanning.ogg
       ejectSound: /Audio/Machines/tray_eject.ogg
       whitelist:
         components:
-          - Paper
+          - FaxableObject #used to be PaperComponent - brainfood1183
   - type: GenericVisualizer
     visuals:
       enum.PowerDeviceVisuals.Powered:
-        base:
+        enum.FaxMachineVisuals.VisualState:
           True: { state: idle }
           False: { state: icon }
       enum.FaxMachineVisuals.VisualState:
-        base:
-          Inserting: { state: inserting }
+        enum.FaxMachineVisuals.VisualState:
           Printing: { state: printing }
+          Normal: {state: idle}
   - type: ItemSlots
   - type: ContainerContainer
     containers:
diff --git a/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_hamster.png b/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_hamster.png
new file mode 100644 (file)
index 0000000..5f14e30
Binary files /dev/null and b/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_hamster.png differ
diff --git a/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mothroach.png b/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mothroach.png
new file mode 100644 (file)
index 0000000..d034322
Binary files /dev/null and b/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mothroach.png differ
diff --git a/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mouse.png b/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mouse.png
new file mode 100644 (file)
index 0000000..7fb8705
Binary files /dev/null and b/Resources/Textures/Structures/Machines/fax_machine.rsi/inserting_mouse.png differ
index 1a8856301d52afcf75755dfee20832e5cd4ab624..00681ca6da1de1cf9a1e99418e174f0bad4587c7 100644 (file)
         ]
       ]
     },
+    {
+      "name": "inserting_hamster",
+      "delays": [
+        [
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2
+        ]
+      ]
+    },
+    {
+      "name": "inserting_mothroach",
+      "delays": [
+        [
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2
+        ]
+      ]
+    },
+    {
+      "name": "inserting_mouse",
+      "delays": [
+        [
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2,
+          0.2
+        ]
+      ]
+    },
     {
       "name": "printing",
       "delays": [