Wires refactor (#7699)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
Flipp Syder
2022-05-05 19:35:06 -07:00
committed by GitHub
parent 39a35641ab
commit 2c6158e115
51 changed files with 2656 additions and 1660 deletions

View File

@@ -1,6 +1,6 @@
using System;
using Content.Server.UserInterface;
using Content.Server.WireHacking;
using Content.Shared.Interaction;
using Content.Shared.Sound;
using Content.Shared.VendingMachines;
using Robust.Server.GameObjects;
@@ -8,13 +8,12 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using Content.Server.VendingMachines.systems;
using static Content.Shared.Wires.SharedWiresComponent;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.VendingMachines
{
[RegisterComponent]
public sealed class VendingMachineComponent : SharedVendingMachineComponent, IWires
public sealed class VendingMachineComponent : SharedVendingMachineComponent
{
public bool Ejecting;
public bool Emagged = false;
@@ -37,45 +36,5 @@ namespace Content.Server.VendingMachines
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(VendingMachineUiKey.Key);
public float NonLimitedEjectForce = 7.5f;
public float NonLimitedEjectRange = 5f;
public enum Wires
{
/// <summary>
/// Shoots a random item when pulsed.
/// </summary>
Limiter
}
public void RegisterWires(WiresComponent.WiresBuilder builder)
{
builder.CreateWire(Wires.Limiter);
}
public void WiresUpdate(WiresUpdateEventArgs args)
{
var identifier = (Wires) args.Identifier;
if (identifier == Wires.Limiter && args.Action == WiresAction.Pulse)
{
EntitySystem.Get<VendingMachineSystem>().EjectRandom(this.Owner, true, this);
}
}
}
public sealed class WiresUpdateEventArgs : EventArgs
{
public readonly object Identifier;
public readonly WiresAction Action;
public WiresUpdateEventArgs(object identifier, WiresAction action)
{
Identifier = identifier;
Action = action;
}
}
public interface IWires
{
void RegisterWires(WiresComponent.WiresBuilder builder);
void WiresUpdate(WiresUpdateEventArgs args);
}
}