Skip to content

Commit

Permalink
Добавил базовый электрический стул
Browse files Browse the repository at this point in the history
  • Loading branch information
pxc1984 committed Jun 16, 2024
1 parent f7ddde2 commit 6b8bd9f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Content.Server/_Sunrise/ElectricChair/ElectricChairSystem.cs
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 Content.Shared/_Sunrise/ElectricChair/ElectricChairComponent.cs
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 Resources/Prototypes/_Sunrise/Structures/Furniture/chairs.yml
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

0 comments on commit 6b8bd9f

Please sign in to comment.