Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contraband never getting added to vend inventory #32431

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ namespace Content.Server.VendingMachines;
[DataDefinition]
public sealed partial class VendingMachineContrabandWireAction : BaseToggleWireAction
{
private VendingMachineSystem _vendingMachineSystem = default!;

public override Color Color { get; set; } = Color.Green;
public override string Name { get; set; } = "wire-name-vending-contraband";
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;

public override void Initialize()
{
base.Initialize();

_vendingMachineSystem = EntityManager.System<VendingMachineSystem>();
}

public override StatusLightState? GetLightState(Wire wire)
{
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
Expand All @@ -28,7 +37,7 @@ public override void ToggleValue(EntityUid owner, bool setting)
{
if (EntityManager.TryGetComponent(owner, out VendingMachineComponent? vending))
{
vending.Contraband = !setting;
_vendingMachineSystem.SetContraband(owner, !vending.Contraband, vending);
}
}

Expand Down
12 changes: 12 additions & 0 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ public void SetShooting(EntityUid uid, bool canShoot, VendingMachineComponent? c
component.CanShoot = canShoot;
}

/// <summary>
/// Sets the <see cref="VendingMachineComponent.Contraband"/> property of the vending machine.
/// </summary>
public void SetContraband(EntityUid uid, bool contraband, VendingMachineComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

component.Contraband = contraband;
Dirty(uid, component);
}

public void Deny(EntityUid uid, VendingMachineComponent? vendComponent = null)
{
if (!Resolve(uid, ref vendComponent))
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/VendingMachines/VendingMachineComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public sealed partial class VendingMachineComponent : Component
[DataField, AutoNetworkedField]
public Dictionary<string, VendingMachineInventoryEntry> ContrabandInventory = new();

[DataField, AutoNetworkedField]
public bool Contraband;

public bool Ejecting;
Expand Down
Loading