Electrocution. (#4958)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
committed by
GitHub
parent
66a3d5bf29
commit
ed3bf94a3b
@@ -8,7 +8,14 @@ using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Power.Components
|
||||
{
|
||||
public abstract class BaseNetConnectorComponent<TNetType> : Component
|
||||
public interface IBaseNetConnectorComponent<in TNetType>
|
||||
{
|
||||
public TNetType? Net { set; }
|
||||
public Voltage Voltage { get; }
|
||||
public string? NodeId { get; }
|
||||
}
|
||||
|
||||
public abstract class BaseNetConnectorComponent<TNetType> : Component, IBaseNetConnectorComponent<TNetType>
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Voltage Voltage { get => _voltage; set => SetVoltage(value); }
|
||||
@@ -22,7 +29,7 @@ namespace Content.Server.Power.Components
|
||||
[ViewVariables]
|
||||
private bool _needsNet => _net != null;
|
||||
|
||||
[DataField("node")] [ViewVariables] public string? NodeId;
|
||||
[DataField("node")] [ViewVariables] public string? NodeId { get; set; }
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,11 @@ using Content.Server.Power.NodeGroups;
|
||||
|
||||
namespace Content.Server.Power.Components
|
||||
{
|
||||
public interface IBasePowerNetComponent : IBaseNetConnectorComponent<IPowerNet>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract class BasePowerNetComponent : BaseNetConnectorComponent<IPowerNet>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Electrocution;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
@@ -43,6 +44,8 @@ namespace Content.Server.Power.Components
|
||||
|
||||
if (!await EntitySystem.Get<ToolSystem>().UseTool(eventArgs.Using.Uid, eventArgs.User.Uid, Owner.Uid, 0f, 0.25f, _cuttingQuality)) return false;
|
||||
|
||||
if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner.Uid, eventArgs.User.Uid)) return false;
|
||||
|
||||
Owner.Delete();
|
||||
var droppedEnt = Owner.EntityManager.SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Content.Server.Power.Components
|
||||
/// Draws power directly from an MV or HV wire it is on top of.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class PowerConsumerComponent : BasePowerNetComponent
|
||||
public class PowerConsumerComponent : BaseNetConnectorComponent<IBasePowerNet>
|
||||
{
|
||||
public override string Name => "PowerConsumer";
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace Content.Server.Power.Components
|
||||
|
||||
public PowerState.Load NetworkLoad { get; } = new();
|
||||
|
||||
protected override void AddSelfToNet(IPowerNet powerNet)
|
||||
protected override void AddSelfToNet(IBasePowerNet powerNet)
|
||||
{
|
||||
powerNet.AddConsumer(this);
|
||||
}
|
||||
|
||||
protected override void RemoveSelfFromNet(IPowerNet powerNet)
|
||||
protected override void RemoveSelfFromNet(IBasePowerNet powerNet)
|
||||
{
|
||||
powerNet.RemoveConsumer(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user