Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 34 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6c8a802
Rodents can be Faxecuted (executed via Fax machine)
brainfood1183 Nov 5, 2023
3a7b958
use brute instead of new group.
brainfood1183 Nov 5, 2023
b61d15a
fax visuals now use tags for mouse and hamster instead of comps
brainfood1183 Nov 5, 2023
4fc4077
fix for ubuntu, damn ubuntu bane of my life
brainfood1183 Nov 5, 2023
03cc90e
Merge branch 'master' into hamletdeaths
brainfood1183 Dec 25, 2023
7210ee7
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Jan 5, 2024
3a5a578
cant copy hamlet, can now faxecute mothroaches.
brainfood1183 Jan 5, 2024
123d6d8
fix
brainfood1183 Jan 6, 2024
a3275fb
fix
brainfood1183 Jan 6, 2024
95f0a2d
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Jan 20, 2024
3b97ef8
fixes
brainfood1183 Jan 20, 2024
b9b738e
removed ifs now using switch, removed hastag now using string.
brainfood1183 Jan 27, 2024
eb8e800
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Jan 27, 2024
9ae02f2
Merge branch 'master' into hamletdeaths
brainfood1183 Feb 2, 2024
acfa26e
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Feb 4, 2024
2f8482e
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Feb 12, 2024
7959024
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Feb 14, 2024
91b8565
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Feb 19, 2024
aa29e68
fixes and no more switch
brainfood1183 Feb 20, 2024
280cb81
cleanup
brainfood1183 Feb 20, 2024
841db52
more cleanup
brainfood1183 Feb 20, 2024
62a8aef
fix
brainfood1183 Feb 20, 2024
02706ab
cleanup
brainfood1183 Feb 20, 2024
89f8a87
moved damage out of faxmachine and into own system and component.
brainfood1183 Feb 21, 2024
22420e4
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Feb 25, 2024
b18f536
Merge branch 'master' into hamletdeaths
brainfood1183 Mar 13, 2024
9bdee7b
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Apr 2, 2024
8a4f8ba
Merge branch 'space-wizards:master' into hamletdeaths
brainfood1183 Apr 17, 2024
e6a52c0
changes
brainfood1183 Apr 18, 2024
ddeba87
fixes and done i think.
brainfood1183 Apr 19, 2024
16d8bd3
tidy
brainfood1183 Apr 19, 2024
f91379f
Merge remote-tracking branch 'upstream/master' into hamletdeaths
metalgearsloth Apr 25, 2024
378f743
Fixes
metalgearsloth Apr 27, 2024
c3be0c1
Merge remote-tracking branch 'upstream/master' into hamletdeaths
metalgearsloth Apr 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Content.Client/Fax/System/FaxVisualsSystem.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void Initialize()
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))
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Fax/AdminUI/AdminFaxEui.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
24 changes: 20 additions & 4 deletions Content.Server/Fax/FaxSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
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;
Expand All @@ -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";

Expand Down Expand Up @@ -313,12 +317,18 @@ private void OnFileButtonPressed(EntityUid uid, FaxMachineComponent component, F

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)
Expand All @@ -336,14 +346,20 @@ private void UpdateAppearance(EntityUid uid, FaxMachineComponent? component = nu
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))
Expand Down Expand Up @@ -477,7 +493,7 @@ public void Send(EntityUid uid, FaxMachineComponent? component = null, EntityUid
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()
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Nuke/NukeCodePaperSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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>
Expand All @@ -26,47 +34,47 @@ 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>
/// Is fax machine should respond to pings in network
/// 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>
Expand All @@ -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>
Expand All @@ -111,7 +119,7 @@ public sealed partial class FaxMachineComponent : Component
/// <summary>
/// Remaining time of printing animation
/// </summary>
[DataField("printingTimeRemaining")]
[DataField]
public float PrintingTimeRemaining;

/// <summary>
Expand All @@ -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")]
Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/Fax/Components/FaxableObjectComponent.cs
Original file line number Diff line number Diff line change
@@ -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";
}
19 changes: 19 additions & 0 deletions Content.Shared/Fax/Components/FaxecuteComponent.cs
Original file line number Diff line number Diff line change
@@ -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();
}

9 changes: 9 additions & 0 deletions Content.Shared/Fax/DamageOnFaxecuteEvent.cs
Original file line number Diff line number Diff line change
@@ -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);

34 changes: 34 additions & 0 deletions Content.Shared/Fax/Systems/FaxecuteSystem.cs
Original file line number Diff line number Diff line change
@@ -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;

}
}
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/fax/fax.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading