Rodents can be Faxecuted (executed via Fax machine) (#21461)

* 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>
This commit is contained in:
brainfood1183
2024-04-27 14:50:57 +01:00
committed by GitHub
parent 37105b3400
commit c0ce5fba2a
18 changed files with 250 additions and 28 deletions

View File

@@ -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");
}
}
}

View File

@@ -1,6 +1,7 @@
using Content.Server.DeviceNetwork.Components; using Content.Server.DeviceNetwork.Components;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Shared.Eui; using Content.Shared.Eui;
using Content.Shared.Fax.Components;
using Content.Shared.Fax; using Content.Shared.Fax;
using Content.Shared.Follower; using Content.Shared.Follower;
using Content.Shared.Ghost; using Content.Shared.Ghost;

View File

@@ -16,7 +16,10 @@ using Content.Shared.DeviceNetwork;
using Content.Shared.Emag.Components; using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems; using Content.Shared.Emag.Systems;
using Content.Shared.Fax; using Content.Shared.Fax;
using Content.Shared.Fax.Systems;
using Content.Shared.Fax.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Mobs.Components;
using Content.Shared.Paper; using Content.Shared.Paper;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -42,6 +45,7 @@ public sealed class FaxSystem : EntitySystem
[Dependency] private readonly UserInterfaceSystem _userInterface = default!; [Dependency] private readonly UserInterfaceSystem _userInterface = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly FaxecuteSystem _faxecute = default!;
private const string PaperSlotId = "Paper"; private const string PaperSlotId = "Paper";
@@ -313,12 +317,18 @@ public sealed class FaxSystem : EntitySystem
private void OnCopyButtonPressed(EntityUid uid, FaxMachineComponent component, FaxCopyMessage args) 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) 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) private void OnRefreshButtonPressed(EntityUid uid, FaxMachineComponent component, FaxRefreshMessage args)
@@ -336,14 +346,20 @@ public sealed class FaxSystem : EntitySystem
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
if (TryComp<FaxableObjectComponent>(component.PaperSlot.Item, out var faxable))
component.InsertingState = faxable.InsertingState;
if (component.InsertingTimeRemaining > 0) if (component.InsertingTimeRemaining > 0)
{
_appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Inserting); _appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Inserting);
Dirty(uid, component);
}
else if (component.PrintingTimeRemaining > 0) else if (component.PrintingTimeRemaining > 0)
_appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Printing); _appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Printing);
else else
_appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Normal); _appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Normal);
} }
private void UpdateUserInterface(EntityUid uid, FaxMachineComponent? component = null) private void UpdateUserInterface(EntityUid uid, FaxMachineComponent? component = null)
{ {
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
@@ -477,7 +493,7 @@ public sealed class FaxSystem : EntitySystem
return; return;
if (!TryComp<MetaDataComponent>(sendEntity, out var metadata) || if (!TryComp<MetaDataComponent>(sendEntity, out var metadata) ||
!TryComp<PaperComponent>(sendEntity, out var paper)) !TryComp<PaperComponent>(sendEntity, out var paper))
return; return;
var payload = new NetworkPayload() var payload = new NetworkPayload()

View File

@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Content.Server.Chat.Systems; using Content.Server.Chat.Systems;
using Content.Server.Fax; using Content.Server.Fax;
using Content.Shared.Fax.Components;
using Content.Server.Paper; using Content.Server.Paper;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;

View File

@@ -1,12 +1,13 @@
using Content.Shared.Containers.ItemSlots; using Content.Shared.Containers.ItemSlots;
using Content.Shared.Paper; using Content.Shared.Paper;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; 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 public sealed partial class FaxMachineComponent : Component
{ {
/// <summary> /// <summary>
@@ -16,6 +17,13 @@ public sealed partial class FaxMachineComponent : Component
[DataField("name")] [DataField("name")]
public string FaxName { get; set; } = "Unknown"; 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> /// <summary>
/// Device address of fax in network to which data will be send /// Device address of fax in network to which data will be send
/// </summary> /// </summary>
@@ -26,7 +34,7 @@ public sealed partial class FaxMachineComponent : Component
/// <summary> /// <summary>
/// Contains the item to be sent, assumes it's paper... /// Contains the item to be sent, assumes it's paper...
/// </summary> /// </summary>
[DataField("paperSlot", required: true)] [DataField(required: true)]
public ItemSlot PaperSlot = new(); public ItemSlot PaperSlot = new();
/// <summary> /// <summary>
@@ -34,39 +42,39 @@ public sealed partial class FaxMachineComponent : Component
/// This will make it visible to others on the network /// This will make it visible to others on the network
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("responsePings")] [DataField]
public bool ResponsePings { get; set; } = true; public bool ResponsePings { get; set; } = true;
/// <summary> /// <summary>
/// Should admins be notified on message receive /// Should admins be notified on message receive
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("notifyAdmins")] [DataField]
public bool NotifyAdmins { get; set; } = false; public bool NotifyAdmins { get; set; } = false;
/// <summary> /// <summary>
/// Should that fax receive nuke codes send by admins. Probably should be captain fax only /// Should that fax receive nuke codes send by admins. Probably should be captain fax only
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("receiveNukeCodes")] [DataField]
public bool ReceiveNukeCodes { get; set; } = false; public bool ReceiveNukeCodes { get; set; } = false;
/// <summary> /// <summary>
/// Sound to play when fax has been emagged /// Sound to play when fax has been emagged
/// </summary> /// </summary>
[DataField("emagSound")] [DataField]
public SoundSpecifier EmagSound = new SoundCollectionSpecifier("sparks"); public SoundSpecifier EmagSound = new SoundCollectionSpecifier("sparks");
/// <summary> /// <summary>
/// Sound to play when fax printing new message /// Sound to play when fax printing new message
/// </summary> /// </summary>
[DataField("printSound")] [DataField]
public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/printer.ogg"); public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/printer.ogg");
/// <summary> /// <summary>
/// Sound to play when fax successfully send message /// Sound to play when fax successfully send message
/// </summary> /// </summary>
[DataField("sendSound")] [DataField]
public SoundSpecifier SendSound = new SoundPathSpecifier("/Audio/Machines/high_tech_confirm.ogg"); public SoundSpecifier SendSound = new SoundPathSpecifier("/Audio/Machines/high_tech_confirm.ogg");
/// <summary> /// <summary>
@@ -79,27 +87,27 @@ public sealed partial class FaxMachineComponent : Component
/// Print queue of the incoming message /// Print queue of the incoming message
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("printingQueue")] [DataField]
public Queue<FaxPrintout> PrintingQueue { get; private set; } = new(); public Queue<FaxPrintout> PrintingQueue { get; private set; } = new();
/// <summary> /// <summary>
/// Message sending timeout /// Message sending timeout
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("sendTimeoutRemaining")] [DataField]
public float SendTimeoutRemaining; public float SendTimeoutRemaining;
/// <summary> /// <summary>
/// Message sending timeout /// Message sending timeout
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("sendTimeout")] [DataField]
public float SendTimeout = 5f; public float SendTimeout = 5f;
/// <summary> /// <summary>
/// Remaining time of inserting animation /// Remaining time of inserting animation
/// </summary> /// </summary>
[DataField("insertingTimeRemaining")] [DataField]
public float InsertingTimeRemaining; public float InsertingTimeRemaining;
/// <summary> /// <summary>
@@ -111,7 +119,7 @@ public sealed partial class FaxMachineComponent : Component
/// <summary> /// <summary>
/// Remaining time of printing animation /// Remaining time of printing animation
/// </summary> /// </summary>
[DataField("printingTimeRemaining")] [DataField]
public float PrintingTimeRemaining; public float PrintingTimeRemaining;
/// <summary> /// <summary>
@@ -124,13 +132,13 @@ public sealed partial class FaxMachineComponent : Component
[DataDefinition] [DataDefinition]
public sealed partial class FaxPrintout public sealed partial class FaxPrintout
{ {
[DataField("name", required: true)] [DataField(required: true)]
public string Name { get; private set; } = default!; public string Name { get; private set; } = default!;
[DataField("content", required: true)] [DataField(required: true)]
public string Content { get; private set; } = default!; 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!; public string PrototypeId { get; private set; } = default!;
[DataField("stampState")] [DataField("stampState")]

View File

@@ -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";
}

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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;
}
}

View 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-long = Fax name is too long
fax-machine-popup-name-exist = Fax with same name already exist in network 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-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-rename = Rename
fax-machine-dialog-field-name = Name fax-machine-dialog-field-name = Name

View File

@@ -432,6 +432,8 @@
- type: Speech - type: Speech
speechVerb: Moth speechVerb: Moth
speechSounds: Squeak speechSounds: Squeak
- type: FaxableObject
insertingState: inserting_mothroach
- type: MothAccent - type: MothAccent
- type: Sprite - type: Sprite
sprite: Mobs/Animals/mothroach.rsi sprite: Mobs/Animals/mothroach.rsi
@@ -1535,6 +1537,8 @@
rootTask: rootTask:
task: MouseCompound task: MouseCompound
- type: Physics - type: Physics
- type: FaxableObject
insertingState: inserting_mouse
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:
@@ -3049,6 +3053,8 @@
- type: Item - type: Item
size: Tiny size: Tiny
- type: Physics - type: Physics
- type: FaxableObject
insertingState: inserting_hamster
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:

View File

@@ -32,6 +32,7 @@
- Trash - Trash
- Paper - Paper
- type: Appearance - type: Appearance
- type: FaxableObject
- type: PaperVisuals - type: PaperVisuals
- type: Flammable - type: Flammable
fireSpread: true fireSpread: true

View File

@@ -1,4 +1,4 @@
- type: entity - type: entity
parent: BaseMachinePowered parent: BaseMachinePowered
id: FaxMachineBase id: FaxMachineBase
name: long range fax machine name: long range fax machine
@@ -9,7 +9,7 @@
drawdepth: SmallObjects drawdepth: SmallObjects
layers: layers:
- state: icon - state: icon
map: ["base"] map: [ "enum.FaxMachineVisuals.VisualState" ]
- type: Icon - type: Icon
sprite: Structures/Machines/fax_machine.rsi sprite: Structures/Machines/fax_machine.rsi
state: icon state: icon
@@ -36,23 +36,27 @@
type: FaxBoundUi type: FaxBoundUi
- type: ApcPowerReceiver - type: ApcPowerReceiver
powerLoad: 250 powerLoad: 250
- type: Faxecute
damage:
types:
Blunt: 100
- type: FaxMachine - type: FaxMachine
paperSlot: paperSlot:
insertSound: /Audio/Machines/scanning.ogg insertSound: /Audio/Machines/scanning.ogg
ejectSound: /Audio/Machines/tray_eject.ogg ejectSound: /Audio/Machines/tray_eject.ogg
whitelist: whitelist:
components: components:
- Paper - FaxableObject #used to be PaperComponent - brainfood1183
- type: GenericVisualizer - type: GenericVisualizer
visuals: visuals:
enum.PowerDeviceVisuals.Powered: enum.PowerDeviceVisuals.Powered:
base: enum.FaxMachineVisuals.VisualState:
True: { state: idle } True: { state: idle }
False: { state: icon } False: { state: icon }
enum.FaxMachineVisuals.VisualState: enum.FaxMachineVisuals.VisualState:
base: enum.FaxMachineVisuals.VisualState:
Inserting: { state: inserting }
Printing: { state: printing } Printing: { state: printing }
Normal: {state: idle}
- type: ItemSlots - type: ItemSlots
- type: ContainerContainer - type: ContainerContainer
containers: containers:

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -40,6 +40,63 @@
] ]
] ]
}, },
{
"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", "name": "printing",
"delays": [ "delays": [