From 6b8bd9f2a8c7fd90bc72840977beb4e1bde8ca9d Mon Sep 17 00:00:00 2001 From: JDtrimble Date: Sun, 16 Jun 2024 10:22:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B1=D0=B0=D0=B7=D0=BE=D0=B2=D1=8B=D0=B9=20=D1=8D=D0=BB=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D1=80=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B9=20?= =?UTF-8?q?=D1=81=D1=82=D1=83=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ElectricChair/ElectricChairSystem.cs | 54 +++++++++++++++++++ .../ElectricChair/ElectricChairComponent.cs | 14 +++++ .../_Sunrise/Structures/Furniture/chairs.yml | 13 +++++ 3 files changed, 81 insertions(+) create mode 100644 Content.Server/_Sunrise/ElectricChair/ElectricChairSystem.cs create mode 100644 Content.Shared/_Sunrise/ElectricChair/ElectricChairComponent.cs create mode 100644 Resources/Prototypes/_Sunrise/Structures/Furniture/chairs.yml diff --git a/Content.Server/_Sunrise/ElectricChair/ElectricChairSystem.cs b/Content.Server/_Sunrise/ElectricChair/ElectricChairSystem.cs new file mode 100644 index 00000000000..517095749f7 --- /dev/null +++ b/Content.Server/_Sunrise/ElectricChair/ElectricChairSystem.cs @@ -0,0 +1,54 @@ +using System.Linq; +using Content.Server.Administration.Logs; +using Content.Server.Electrocution; +using Content.Server.Explosion.EntitySystems; +using Content.Server.Popups; +using Content.Shared._Sunrise.ElectricChair; +using Content.Shared.Buckle.Components; +using Content.Shared.Database; +using Content.Shared.Humanoid; +using Content.Shared.Popups; + +namespace Content.Server._Sunrise.ElectricChair; + +/// +/// This handles ElectricChairComponent +/// TODO: make electric chair drain power from a power grid +/// TODO: add delay +/// +public sealed class ElectricChairSystem : EntitySystem +{ + [Dependency] private readonly ElectrocutionSystem _electrocutionSystem = default!; + [Dependency] private readonly PopupSystem _popup = default!; + [Dependency] private readonly IAdminLogManager _adminLogManager = default!; + /// + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnTrigger); + } + + private void OnTrigger(EntityUid uid, ElectricChairComponent component, TriggerEvent args) + { + if (!HasComp(uid)) + return; + var comp = Comp(uid); + if (comp.BuckledEntities.Count == 0) + return; + var target = comp.BuckledEntities.First(); + if (HasComp(target)) + { + _electrocutionSystem.TryDoElectrocution(target, null, component.ShockDamage, TimeSpan.FromSeconds(5), true, 1F, null, true); + _popup.PopupEntity(Loc.GetString("electrocution-success"), target, PopupType.Large); + _adminLogManager.Add( + LogType.Electrocution, + LogImpact.Extreme, + $"{ToPrettyString(args.User):entity} successfully electrocuted {ToPrettyString(target):entity}"); + } + else + { + _popup.PopupEntity(Loc.GetString("electrocution-failed"), target, PopupType.Medium); + } + args.Handled = true; + } +} diff --git a/Content.Shared/_Sunrise/ElectricChair/ElectricChairComponent.cs b/Content.Shared/_Sunrise/ElectricChair/ElectricChairComponent.cs new file mode 100644 index 00000000000..3036fd3c35d --- /dev/null +++ b/Content.Shared/_Sunrise/ElectricChair/ElectricChairComponent.cs @@ -0,0 +1,14 @@ +namespace Content.Shared._Sunrise.ElectricChair; + +/// +/// This is used for... +/// +[RegisterComponent] +public sealed partial class ElectricChairComponent : Component +{ + [DataField] + public int ShockDamage = 200; + + [DataField] + public int ShockDelay = 30; +} diff --git a/Resources/Prototypes/_Sunrise/Structures/Furniture/chairs.yml b/Resources/Prototypes/_Sunrise/Structures/Furniture/chairs.yml new file mode 100644 index 00000000000..4358bac7fe9 --- /dev/null +++ b/Resources/Prototypes/_Sunrise/Structures/Furniture/chairs.yml @@ -0,0 +1,13 @@ +- type: entity + id: ElectricChair + name: electric chair + description: used to execute very bad people + parent: ChairBase + components: + - type: Sprite + state: chair + - type: ElectricChair + - type: TriggerOnSignal + - type: DeviceLinkSink + ports: + - Trigger