Vending machine changes (#8060)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Content.Client.VendingMachines.UI
|
|||||||
|
|
||||||
public void ItemSelected(ItemList.ItemListSelectedEventArgs args)
|
public void ItemSelected(ItemList.ItemListSelectedEventArgs args)
|
||||||
{
|
{
|
||||||
Owner.Eject(_cachedInventory[args.ItemIndex].ID);
|
Owner.Eject(_cachedInventory[args.ItemIndex].Type, _cachedInventory[args.ItemIndex].ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,15 +32,15 @@ namespace Content.Client.VendingMachines
|
|||||||
VendingMachine = vendingMachine;
|
VendingMachine = vendingMachine;
|
||||||
|
|
||||||
_menu = new VendingMachineMenu(this) {Title = entMan.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
|
_menu = new VendingMachineMenu(this) {Title = entMan.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
|
||||||
_menu.Populate(VendingMachine.Inventory);
|
_menu.Populate(VendingMachine.AllInventory);
|
||||||
|
|
||||||
_menu.OnClose += Close;
|
_menu.OnClose += Close;
|
||||||
_menu.OpenCentered();
|
_menu.OpenCentered();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Eject(string id)
|
public void Eject(InventoryType type, string id)
|
||||||
{
|
{
|
||||||
SendMessage(new VendingMachineEjectMessage(id));
|
SendMessage(new VendingMachineEjectMessage(type, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Content.Server.VendingMachines.systems;
|
using Content.Server.VendingMachines.Systems;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
namespace Content.Server.VendingMachines
|
namespace Content.Server.VendingMachines
|
||||||
@@ -16,25 +16,34 @@ namespace Content.Server.VendingMachines
|
|||||||
public sealed class VendingMachineComponent : SharedVendingMachineComponent
|
public sealed class VendingMachineComponent : SharedVendingMachineComponent
|
||||||
{
|
{
|
||||||
public bool Ejecting;
|
public bool Ejecting;
|
||||||
public bool Emagged = false;
|
|
||||||
public TimeSpan AnimationDuration = TimeSpan.Zero;
|
public TimeSpan AnimationDuration = TimeSpan.Zero;
|
||||||
[ViewVariables] [DataField("pack", customTypeSerializer:typeof(PrototypeIdSerializer<VendingMachineInventoryPrototype>))] public string PackPrototypeId = string.Empty;
|
|
||||||
[ViewVariables] [DataField("emagPack", customTypeSerializer:typeof(PrototypeIdSerializer<VendingMachineInventoryPrototype>))] public string EmagPackPrototypeId = string.Empty;
|
[ViewVariables] [DataField("pack", customTypeSerializer:typeof(PrototypeIdSerializer<VendingMachineInventoryPrototype>))]
|
||||||
|
public string PackPrototypeId = string.Empty;
|
||||||
|
|
||||||
public string SpriteName = "";
|
public string SpriteName = "";
|
||||||
|
|
||||||
public bool Broken;
|
public bool Broken;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When true, will forcefully throw any object it dispenses
|
/// When true, will forcefully throw any object it dispenses
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("speedLimiter")]
|
[DataField("speedLimiter")]
|
||||||
public bool CanShoot = false;
|
public bool CanShoot = false;
|
||||||
|
|
||||||
[DataField("soundVend")]
|
[DataField("soundVend")]
|
||||||
// Grabbed from: https://github.com/discordia-space/CEV-Eris/blob/f702afa271136d093ddeb415423240a2ceb212f0/sound/machines/vending_drop.ogg
|
// Grabbed from: https://github.com/discordia-space/CEV-Eris/blob/f702afa271136d093ddeb415423240a2ceb212f0/sound/machines/vending_drop.ogg
|
||||||
public SoundSpecifier SoundVend = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg");
|
public SoundSpecifier SoundVend = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg");
|
||||||
|
|
||||||
[DataField("soundDeny")]
|
[DataField("soundDeny")]
|
||||||
// Yoinked from: https://github.com/discordia-space/CEV-Eris/blob/35bbad6764b14e15c03a816e3e89aa1751660ba9/sound/machines/Custom_deny.ogg
|
// Yoinked from: https://github.com/discordia-space/CEV-Eris/blob/35bbad6764b14e15c03a816e3e89aa1751660ba9/sound/machines/Custom_deny.ogg
|
||||||
public SoundSpecifier SoundDeny = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
|
public SoundSpecifier SoundDeny = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
|
||||||
|
|
||||||
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(VendingMachineUiKey.Key);
|
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(VendingMachineUiKey.Key);
|
||||||
|
|
||||||
public float NonLimitedEjectForce = 7.5f;
|
public float NonLimitedEjectForce = 7.5f;
|
||||||
|
|
||||||
public float NonLimitedEjectRange = 5f;
|
public float NonLimitedEjectRange = 5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using Content.Server.Wires;
|
||||||
|
using Content.Shared.VendingMachines;
|
||||||
|
using Content.Shared.Wires;
|
||||||
|
|
||||||
|
namespace Content.Server.VendingMachines;
|
||||||
|
|
||||||
|
[DataDefinition]
|
||||||
|
public sealed class VendingMachineContrabandWireAction : BaseToggleWireAction
|
||||||
|
{
|
||||||
|
private readonly Color _color = Color.Green;
|
||||||
|
private readonly string _text = "MNGR";
|
||||||
|
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
|
||||||
|
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;
|
||||||
|
|
||||||
|
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||||
|
{
|
||||||
|
var lightState = StatusLightState.Off;
|
||||||
|
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
|
||||||
|
{
|
||||||
|
lightState = vending.Contraband
|
||||||
|
? StatusLightState.BlinkingSlow
|
||||||
|
: StatusLightState.On;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new StatusLightData(
|
||||||
|
_color,
|
||||||
|
lightState,
|
||||||
|
_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ToggleValue(EntityUid owner, bool setting)
|
||||||
|
{
|
||||||
|
if (EntityManager.TryGetComponent(owner, out VendingMachineComponent vending))
|
||||||
|
{
|
||||||
|
vending.Contraband = !setting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool GetValue(EntityUid owner)
|
||||||
|
{
|
||||||
|
return EntityManager.TryGetComponent(owner, out VendingMachineComponent vending) && !vending.Contraband;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
using Content.Server.VendingMachines.Systems;
|
||||||
|
using Content.Server.Wires;
|
||||||
|
using Content.Shared.VendingMachines;
|
||||||
|
using Content.Shared.Wires;
|
||||||
|
|
||||||
|
namespace Content.Server.VendingMachines;
|
||||||
|
|
||||||
|
[DataDefinition]
|
||||||
|
public sealed class VendingMachineEjectItemWireAction : BaseWireAction
|
||||||
|
{
|
||||||
|
private VendingMachineSystem _vendingMachineSystem = default!;
|
||||||
|
|
||||||
|
private Color _color = Color.Red;
|
||||||
|
private string _text = "VEND";
|
||||||
|
public override object? StatusKey { get; } = EjectWireKey.StatusKey;
|
||||||
|
|
||||||
|
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||||
|
{
|
||||||
|
var lightState = StatusLightState.Off;
|
||||||
|
|
||||||
|
if (IsPowered(wire.Owner)
|
||||||
|
&& EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
|
||||||
|
{
|
||||||
|
lightState = vending.CanShoot
|
||||||
|
? StatusLightState.BlinkingFast
|
||||||
|
: StatusLightState.On;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new StatusLightData(
|
||||||
|
_color,
|
||||||
|
lightState,
|
||||||
|
_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
_vendingMachineSystem = EntitySystem.Get<VendingMachineSystem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Cut(EntityUid user, Wire wire)
|
||||||
|
{
|
||||||
|
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
|
||||||
|
{
|
||||||
|
vending.CanShoot = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Mend(EntityUid user, Wire wire)
|
||||||
|
{
|
||||||
|
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent vending))
|
||||||
|
{
|
||||||
|
vending.CanShoot = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Pulse(EntityUid user, Wire wire)
|
||||||
|
{
|
||||||
|
_vendingMachineSystem.EjectRandom(wire.Owner, true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ using Content.Shared.Emag.Systems;
|
|||||||
using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
|
using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
|
|
||||||
namespace Content.Server.VendingMachines.systems
|
namespace Content.Server.VendingMachines.Systems
|
||||||
{
|
{
|
||||||
public sealed class VendingMachineSystem : EntitySystem
|
public sealed class VendingMachineSystem : EntitySystem
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,12 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
if (!IsPowered(uid, component))
|
if (!IsPowered(uid, component))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.UserInterface?.SendMessage(new VendingMachineInventoryMessage(component.Inventory));
|
var inventory = new List<VendingMachineInventoryEntry>(component.Inventory);
|
||||||
|
|
||||||
|
if (component.Emagged) inventory.AddRange(component.EmaggedInventory);
|
||||||
|
if (component.Contraband) inventory.AddRange(component.ContrabandInventory);
|
||||||
|
|
||||||
|
component.UserInterface?.SendMessage(new VendingMachineInventoryMessage(inventory));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInventoryEjectMessage(EntityUid uid, VendingMachineComponent component, VendingMachineEjectMessage args)
|
private void OnInventoryEjectMessage(EntityUid uid, VendingMachineComponent component, VendingMachineEjectMessage args)
|
||||||
@@ -63,7 +68,7 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
if (args.Session.AttachedEntity is not { Valid: true } entity || Deleted(entity))
|
if (args.Session.AttachedEntity is not { Valid: true } entity || Deleted(entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AuthorizedVend(uid, entity, args.ID, component);
|
AuthorizedVend(uid, entity, args.Type, args.ID, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPowerChanged(EntityUid uid, VendingMachineComponent component, PowerChangedEvent args)
|
private void OnPowerChanged(EntityUid uid, VendingMachineComponent component, PowerChangedEvent args)
|
||||||
@@ -79,10 +84,9 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
|
|
||||||
private void OnEmagged(EntityUid uid, VendingMachineComponent component, GotEmaggedEvent args)
|
private void OnEmagged(EntityUid uid, VendingMachineComponent component, GotEmaggedEvent args)
|
||||||
{
|
{
|
||||||
if (component.Emagged || component.EmagPackPrototypeId == string.Empty)
|
if (component.Emagged || component.EmaggedInventory.Count == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AddVendEntries(component, component.EmagPackPrototypeId);
|
|
||||||
component.Emagged = true;
|
component.Emagged = true;
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
@@ -121,36 +125,42 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
spriteComp.BaseRSIPath = string.Format(vendingMachineRSIPath, vendComponent.SpriteName);
|
spriteComp.BaseRSIPath = string.Format(vendingMachineRSIPath, vendComponent.SpriteName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var inventory = new List<VendingMachineInventoryEntry>();
|
|
||||||
foreach (var (id, amount) in packPrototype.StartingInventory)
|
AddInventoryFromPrototype(uid, packPrototype.StartingInventory, InventoryType.Regular, vendComponent);
|
||||||
{
|
AddInventoryFromPrototype(uid, packPrototype.EmaggedInventory, InventoryType.Emagged, vendComponent);
|
||||||
if (!_prototypeManager.TryIndex(id, out EntityPrototype? prototype))
|
AddInventoryFromPrototype(uid, packPrototype.ContrabandInventory, InventoryType.Contraband, vendComponent);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
inventory.Add(new VendingMachineInventoryEntry(id, amount));
|
|
||||||
}
|
|
||||||
vendComponent.Inventory = inventory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void AddInventoryFromPrototype(EntityUid uid, Dictionary<string, uint>? entries,
|
||||||
/// Add more entries for any reason AFTER initialization (emag, machine upgrades, etc)
|
InventoryType type,
|
||||||
/// </summary>
|
VendingMachineComponent? component = null)
|
||||||
public void AddVendEntries(VendingMachineComponent component, string pack)
|
|
||||||
{
|
{
|
||||||
if (!_prototypeManager.TryIndex(pack, out VendingMachineInventoryPrototype? packPrototype))
|
if (!Resolve(uid, ref component) || entries == null)
|
||||||
{
|
{
|
||||||
Logger.Error($"Pack has no valid inventory prototype: {pack}");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var (id, amount) in packPrototype.StartingInventory)
|
var inventory = new List<VendingMachineInventoryEntry>();
|
||||||
|
|
||||||
|
foreach (var (id, amount) in entries)
|
||||||
{
|
{
|
||||||
if (!_prototypeManager.TryIndex(id, out EntityPrototype? prototype))
|
if (_prototypeManager.HasIndex<EntityPrototype>(id))
|
||||||
{
|
{
|
||||||
continue;
|
inventory.Add(new VendingMachineInventoryEntry(type, id, amount));
|
||||||
}
|
}
|
||||||
component.Inventory.Add(new VendingMachineInventoryEntry(id, amount));
|
}
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case InventoryType.Regular:
|
||||||
|
component.Inventory.AddRange(inventory);
|
||||||
|
break;
|
||||||
|
case InventoryType.Emagged:
|
||||||
|
component.EmaggedInventory.AddRange(inventory);
|
||||||
|
break;
|
||||||
|
case InventoryType.Contraband:
|
||||||
|
component.ContrabandInventory.AddRange(inventory);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,12 +181,12 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
|
|
||||||
public bool IsAuthorized(EntityUid uid, EntityUid? sender, VendingMachineComponent? vendComponent = null)
|
public bool IsAuthorized(EntityUid uid, EntityUid? sender, VendingMachineComponent? vendComponent = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref vendComponent))
|
if (!Resolve(uid, ref vendComponent) || sender == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (TryComp<AccessReaderComponent?>(vendComponent.Owner, out var accessReader))
|
if (TryComp<AccessReaderComponent?>(vendComponent.Owner, out var accessReader))
|
||||||
{
|
{
|
||||||
if (sender == null || !_accessReader.IsAllowed(accessReader, sender.Value))
|
if (!_accessReader.IsAllowed(accessReader, sender.Value) && !vendComponent.Emagged)
|
||||||
{
|
{
|
||||||
_popupSystem.PopupEntity(Loc.GetString("vending-machine-component-try-eject-access-denied"), uid, Filter.Pvs(uid));
|
_popupSystem.PopupEntity(Loc.GetString("vending-machine-component-try-eject-access-denied"), uid, Filter.Pvs(uid));
|
||||||
Deny(uid, vendComponent);
|
Deny(uid, vendComponent);
|
||||||
@@ -186,7 +196,7 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryEjectVendorItem(EntityUid uid, string itemId, bool throwItem, VendingMachineComponent? vendComponent = null)
|
public void TryEjectVendorItem(EntityUid uid, InventoryType type, string itemId, bool throwItem, VendingMachineComponent? vendComponent = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref vendComponent))
|
if (!Resolve(uid, ref vendComponent))
|
||||||
return;
|
return;
|
||||||
@@ -196,7 +206,14 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entry = vendComponent.Inventory.Find(x => x.ID == itemId);
|
var entry = type switch
|
||||||
|
{
|
||||||
|
InventoryType.Regular => vendComponent.Inventory.Find(x => x.ID == itemId),
|
||||||
|
InventoryType.Emagged when vendComponent.Emagged => vendComponent.EmaggedInventory.Find(x => x.ID == itemId),
|
||||||
|
InventoryType.Contraband when vendComponent.Contraband => vendComponent.ContrabandInventory.Find(x => x.ID == itemId),
|
||||||
|
_ => null
|
||||||
|
};
|
||||||
|
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
_popupSystem.PopupEntity(Loc.GetString("vending-machine-component-try-eject-invalid-item"), uid, Filter.Pvs(uid));
|
_popupSystem.PopupEntity(Loc.GetString("vending-machine-component-try-eject-invalid-item"), uid, Filter.Pvs(uid));
|
||||||
@@ -211,7 +228,7 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.ID == null)
|
if (string.IsNullOrEmpty(entry.ID))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryComp<TransformComponent>(vendComponent.Owner, out var transformComp))
|
if (!TryComp<TransformComponent>(vendComponent.Owner, out var transformComp))
|
||||||
@@ -220,7 +237,7 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
// Start Ejecting, and prevent users from ordering while anim playing
|
// Start Ejecting, and prevent users from ordering while anim playing
|
||||||
vendComponent.Ejecting = true;
|
vendComponent.Ejecting = true;
|
||||||
entry.Amount--;
|
entry.Amount--;
|
||||||
vendComponent.UserInterface?.SendMessage(new VendingMachineInventoryMessage(vendComponent.Inventory));
|
vendComponent.UserInterface?.SendMessage(new VendingMachineInventoryMessage(vendComponent.AllInventory));
|
||||||
TryUpdateVisualState(uid, VendingMachineVisualState.Eject, vendComponent);
|
TryUpdateVisualState(uid, VendingMachineVisualState.Eject, vendComponent);
|
||||||
vendComponent.Owner.SpawnTimer(vendComponent.AnimationDuration, () =>
|
vendComponent.Owner.SpawnTimer(vendComponent.AnimationDuration, () =>
|
||||||
{
|
{
|
||||||
@@ -237,13 +254,12 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
SoundSystem.Play(Filter.Pvs(vendComponent.Owner), vendComponent.SoundVend.GetSound(), vendComponent.Owner, AudioParams.Default.WithVolume(-2f));
|
SoundSystem.Play(Filter.Pvs(vendComponent.Owner), vendComponent.SoundVend.GetSound(), vendComponent.Owner, AudioParams.Default.WithVolume(-2f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AuthorizedVend(EntityUid uid, EntityUid sender, string itemId, VendingMachineComponent component)
|
public void AuthorizedVend(EntityUid uid, EntityUid sender, InventoryType type, string itemId, VendingMachineComponent component)
|
||||||
{
|
{
|
||||||
if (IsAuthorized(uid, sender, component))
|
if (IsAuthorized(uid, sender, component))
|
||||||
{
|
{
|
||||||
TryEjectVendorItem(uid, itemId, component.CanShoot, component);
|
TryEjectVendorItem(uid, type, itemId, component.CanShoot, component);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryUpdateVisualState(EntityUid uid, VendingMachineVisualState? state = VendingMachineVisualState.Normal, VendingMachineComponent? vendComponent = null)
|
public void TryUpdateVisualState(EntityUid uid, VendingMachineVisualState? state = VendingMachineVisualState.Normal, VendingMachineComponent? vendComponent = null)
|
||||||
@@ -276,13 +292,14 @@ namespace Content.Server.VendingMachines.systems
|
|||||||
if (!Resolve(uid, ref vendComponent))
|
if (!Resolve(uid, ref vendComponent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var availableItems = vendComponent.Inventory.Where(x => x.Amount > 0).ToList();
|
var availableItems = vendComponent.AllInventory.Where(x => x.Amount > 0).ToList();
|
||||||
if (availableItems.Count <= 0)
|
if (availableItems.Count <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TryEjectVendorItem(uid, _random.Pick(availableItems).ID, throwItem, vendComponent);
|
var item = _random.Pick(availableItems);
|
||||||
|
TryEjectVendorItem(uid, item.Type, item.ID, throwItem, vendComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,25 @@ namespace Content.Shared.VendingMachines
|
|||||||
[NetworkedComponent()]
|
[NetworkedComponent()]
|
||||||
public class SharedVendingMachineComponent : Component
|
public class SharedVendingMachineComponent : Component
|
||||||
{
|
{
|
||||||
[ViewVariables]
|
[ViewVariables] public List<VendingMachineInventoryEntry> Inventory = new();
|
||||||
public List<VendingMachineInventoryEntry> Inventory = new();
|
[ViewVariables] public List<VendingMachineInventoryEntry> EmaggedInventory = new();
|
||||||
|
[ViewVariables] public List<VendingMachineInventoryEntry> ContrabandInventory = new();
|
||||||
|
|
||||||
|
public List<VendingMachineInventoryEntry> AllInventory
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var inventory = new List<VendingMachineInventoryEntry>(Inventory);
|
||||||
|
|
||||||
|
if (Emagged) inventory.AddRange(EmaggedInventory);
|
||||||
|
if (Contraband) inventory.AddRange(ContrabandInventory);
|
||||||
|
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Emagged;
|
||||||
|
public bool Contraband;
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public enum VendingMachineVisuals
|
public enum VendingMachineVisuals
|
||||||
@@ -33,9 +50,11 @@ namespace Content.Shared.VendingMachines
|
|||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class VendingMachineEjectMessage : BoundUserInterfaceMessage
|
public sealed class VendingMachineEjectMessage : BoundUserInterfaceMessage
|
||||||
{
|
{
|
||||||
|
public readonly InventoryType Type;
|
||||||
public readonly string ID;
|
public readonly string ID;
|
||||||
public VendingMachineEjectMessage(string id)
|
public VendingMachineEjectMessage(InventoryType type, string id)
|
||||||
{
|
{
|
||||||
|
Type = type;
|
||||||
ID = id;
|
ID = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,12 +83,14 @@ namespace Content.Shared.VendingMachines
|
|||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public sealed class VendingMachineInventoryEntry
|
public sealed class VendingMachineInventoryEntry
|
||||||
{
|
{
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)] public InventoryType Type;
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string ID;
|
public string ID;
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public uint Amount;
|
public uint Amount;
|
||||||
public VendingMachineInventoryEntry(string id, uint amount)
|
public VendingMachineInventoryEntry(InventoryType type, string id, uint amount)
|
||||||
{
|
{
|
||||||
|
Type = type;
|
||||||
ID = id;
|
ID = id;
|
||||||
Amount = amount;
|
Amount = amount;
|
||||||
}
|
}
|
||||||
@@ -82,5 +103,26 @@ namespace Content.Shared.VendingMachines
|
|||||||
Advertisement,
|
Advertisement,
|
||||||
Limiter
|
Limiter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum InventoryType : byte
|
||||||
|
{
|
||||||
|
Regular,
|
||||||
|
Emagged,
|
||||||
|
Contraband
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum ContrabandWireKey : byte
|
||||||
|
{
|
||||||
|
StatusKey,
|
||||||
|
TimeoutKey
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum EjectWireKey : byte
|
||||||
|
{
|
||||||
|
StatusKey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,5 +25,11 @@ namespace Content.Shared.VendingMachines
|
|||||||
|
|
||||||
[DataField("startingInventory")]
|
[DataField("startingInventory")]
|
||||||
public Dictionary<string, uint> StartingInventory { get; } = new();
|
public Dictionary<string, uint> StartingInventory { get; } = new();
|
||||||
|
|
||||||
|
[DataField("emaggedInventory")]
|
||||||
|
public Dictionary<string, uint>? EmaggedInventory { get; }
|
||||||
|
|
||||||
|
[DataField("contrabandInventory")]
|
||||||
|
public Dictionary<string, uint>? ContrabandInventory { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,7 @@
|
|||||||
ClothingOuterPlagueSuit: 1
|
ClothingOuterPlagueSuit: 1
|
||||||
ClothingMaskPlague: 1
|
ClothingMaskPlague: 1
|
||||||
ClothingHeadsetService: 2
|
ClothingHeadsetService: 2
|
||||||
|
emaggedInventory:
|
||||||
- type: vendingMachineInventory
|
|
||||||
id: PietyVendEmagInventory
|
|
||||||
spriteName: chapel
|
|
||||||
startingInventory:
|
|
||||||
ClothingOuterArmorCult: 1
|
ClothingOuterArmorCult: 1
|
||||||
ClothingHeadHelmetCult: 1
|
ClothingHeadHelmetCult: 1
|
||||||
ClothingOuterRobesCult: 3
|
ClothingOuterRobesCult: 3
|
||||||
|
|||||||
@@ -7,10 +7,12 @@
|
|||||||
Handcuffs: 8
|
Handcuffs: 8
|
||||||
GrenadeFlashBang: 4
|
GrenadeFlashBang: 4
|
||||||
Flash: 5
|
Flash: 5
|
||||||
FoodDonutHomer: 12
|
|
||||||
FoodBoxDonut: 2
|
|
||||||
FlashlightLantern: 4 #seclite
|
FlashlightLantern: 4 #seclite
|
||||||
ClothingEyesGlassesSunglasses: 2
|
ClothingEyesGlassesSunglasses: 2
|
||||||
ClothingBeltSecurityWebbing: 5
|
ClothingBeltSecurityWebbing: 5
|
||||||
Zipties: 12
|
Zipties: 12
|
||||||
|
# security officers need to follow a diet regimen!
|
||||||
|
contrabandInventory:
|
||||||
|
FoodDonutHomer: 12
|
||||||
|
FoodBoxDonut: 2
|
||||||
#box evidence
|
#box evidence
|
||||||
|
|||||||
@@ -932,7 +932,6 @@
|
|||||||
components:
|
components:
|
||||||
- type: VendingMachine
|
- type: VendingMachine
|
||||||
pack: PietyVendInventory
|
pack: PietyVendInventory
|
||||||
emagPack: PietyVendEmagInventory
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Machines/VendingMachines/chapdrobe.rsi
|
sprite: Structures/Machines/VendingMachines/chapdrobe.rsi
|
||||||
layers:
|
layers:
|
||||||
|
|||||||
@@ -23,10 +23,11 @@
|
|||||||
|
|
||||||
- type: wireLayout
|
- type: wireLayout
|
||||||
id: Vending
|
id: Vending
|
||||||
dummyWires: 2
|
|
||||||
wires:
|
wires:
|
||||||
- !type:PowerWireAction
|
- !type:PowerWireAction
|
||||||
- !type:AccessWireAction
|
- !type:AccessWireAction
|
||||||
|
- !type:VendingMachineContrabandWireAction
|
||||||
|
- !type:VendingMachineEjectItemWireAction
|
||||||
|
|
||||||
- type: wireLayout
|
- type: wireLayout
|
||||||
id: AirAlarm
|
id: AirAlarm
|
||||||
|
|||||||
Reference in New Issue
Block a user