-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Content.Server/_Sunrise/ElectricChair/ElectricChairSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
/// <summary> | ||
/// This handles ElectricChairComponent | ||
/// TODO: make electric chair drain power from a power grid | ||
/// TODO: add delay | ||
/// </summary> | ||
public sealed class ElectricChairSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ElectrocutionSystem _electrocutionSystem = default!; | ||
[Dependency] private readonly PopupSystem _popup = default!; | ||
[Dependency] private readonly IAdminLogManager _adminLogManager = default!; | ||
/// <inheritdoc/> | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ElectricChairComponent, TriggerEvent>(OnTrigger); | ||
} | ||
|
||
private void OnTrigger(EntityUid uid, ElectricChairComponent component, TriggerEvent args) | ||
{ | ||
if (!HasComp<StrapComponent>(uid)) | ||
return; | ||
var comp = Comp<StrapComponent>(uid); | ||
if (comp.BuckledEntities.Count == 0) | ||
return; | ||
var target = comp.BuckledEntities.First(); | ||
if (HasComp<HumanoidAppearanceComponent>(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; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Content.Shared/_Sunrise/ElectricChair/ElectricChairComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Content.Shared._Sunrise.ElectricChair; | ||
|
||
/// <summary> | ||
/// This is used for... | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ElectricChairComponent : Component | ||
{ | ||
[DataField] | ||
public int ShockDamage = 200; | ||
|
||
[DataField] | ||
public int ShockDelay = 30; | ||
} |
13 changes: 13 additions & 0 deletions
13
Resources/Prototypes/_Sunrise/Structures/Furniture/chairs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |