2020-08-22 22:29:20 +02:00
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.UserInterface;
|
2021-07-04 18:11:52 +02:00
|
|
|
using Content.Server.WireHacking;
|
2021-07-10 17:35:33 +02:00
|
|
|
using Content.Shared.Sound;
|
2019-08-14 10:49:28 +02:00
|
|
|
using Content.Shared.VendingMachines;
|
2019-11-13 17:37:46 -05:00
|
|
|
using Robust.Server.GameObjects;
|
2019-08-14 10:49:28 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-08-24 20:47:17 +02:00
|
|
|
using Robust.Shared.ViewVariables;
|
2022-01-30 22:16:41 -06:00
|
|
|
using Content.Server.VendingMachines.systems;
|
2021-06-09 22:19:39 +02:00
|
|
|
using static Content.Shared.Wires.SharedWiresComponent;
|
2019-08-14 10:49:28 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.VendingMachines
|
2019-08-14 10:49:28 +02:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class VendingMachineComponent : SharedVendingMachineComponent, IWires
|
2019-08-14 10:49:28 +02:00
|
|
|
{
|
2022-01-30 22:16:41 -06:00
|
|
|
public bool Ejecting;
|
|
|
|
|
public TimeSpan AnimationDuration = TimeSpan.Zero;
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("pack")]
|
2022-01-30 22:16:41 -06:00
|
|
|
public string PackPrototypeId = string.Empty;
|
|
|
|
|
public string SpriteName = "";
|
|
|
|
|
public bool Broken;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// When true, will forcefully throw any object it dispenses
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField("speedLimiter")]
|
|
|
|
|
public bool CanShoot = false;
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("soundVend")]
|
|
|
|
|
// Grabbed from: https://github.com/discordia-space/CEV-Eris/blob/f702afa271136d093ddeb415423240a2ceb212f0/sound/machines/vending_drop.ogg
|
2022-01-30 22:16:41 -06:00
|
|
|
public SoundSpecifier SoundVend = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg");
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("soundDeny")]
|
|
|
|
|
// Yoinked from: https://github.com/discordia-space/CEV-Eris/blob/35bbad6764b14e15c03a816e3e89aa1751660ba9/sound/machines/Custom_deny.ogg
|
2022-01-30 22:16:41 -06:00
|
|
|
public SoundSpecifier SoundDeny = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
|
|
|
|
|
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(VendingMachineUiKey.Key);
|
|
|
|
|
public float NonLimitedEjectForce = 7.5f;
|
|
|
|
|
public float NonLimitedEjectRange = 5f;
|
2019-09-01 22:15:34 +02:00
|
|
|
|
|
|
|
|
public enum Wires
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Shoots a random item when pulsed.
|
|
|
|
|
/// </summary>
|
2022-01-30 22:16:41 -06:00
|
|
|
Limiter
|
2019-09-01 22:15:34 +02:00
|
|
|
}
|
2022-01-30 22:16:41 -06:00
|
|
|
public void RegisterWires(WiresComponent.WiresBuilder builder)
|
2019-09-01 22:15:34 +02:00
|
|
|
{
|
2022-01-30 22:16:41 -06:00
|
|
|
builder.CreateWire(Wires.Limiter);
|
2019-09-01 22:15:34 +02:00
|
|
|
}
|
|
|
|
|
|
2022-01-30 22:16:41 -06:00
|
|
|
public void WiresUpdate(WiresUpdateEventArgs args)
|
2019-09-01 22:15:34 +02:00
|
|
|
{
|
|
|
|
|
var identifier = (Wires) args.Identifier;
|
2022-01-30 22:16:41 -06:00
|
|
|
if (identifier == Wires.Limiter && args.Action == WiresAction.Pulse)
|
2019-09-01 22:15:34 +02:00
|
|
|
{
|
2022-01-30 22:16:41 -06:00
|
|
|
EntitySystem.Get<VendingMachineSystem>().EjectRandom(this.Owner, true, this);
|
2019-09-01 22:15:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class WiresUpdateEventArgs : EventArgs
|
2019-09-01 22:15:34 +02:00
|
|
|
{
|
|
|
|
|
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);
|
2019-08-14 10:49:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|