Skip to content

Separation Of Cash Payment From VendingMachineComponent - #3871

Open
ThanosDeGraf wants to merge 29 commits into
Monolith-Station:mainfrom
ThanosDeGraf:CreditReceiver-Created
Open

Separation Of Cash Payment From VendingMachineComponent#3871
ThanosDeGraf wants to merge 29 commits into
Monolith-Station:mainfrom
ThanosDeGraf:CreditReceiver-Created

Conversation

@ThanosDeGraf

@ThanosDeGraf ThanosDeGraf commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

About the PR

This PR tries to refactor all mentions of cash payment from VendingMachineComponeng (and hopefully VendingMachineSystem) into it's own areas. The new CreditReceiverComponent is a couple of attributes stolen and moved there. By giving baseVendingMachine the CreditReceiver parent, they should all function as they should before.

Later on, it should be possible to give non-vending machines this parent and allow em to process cash money for their features.

Why / Balance

The goal of this PR is to lay the foundation for more machines that can accept cash credit payment without access/need for a bank account. I've seperated out the refactoring into this PR for easier review as any change in behavior is unintended and should be more easily spotted. The other request is here #3913

Also, wanted content.
https://discord.com/channels/1329292619834069034/1431695702882386001/1494546272579752096
grafik

Media

Requirements

  • I have read relevant guidelines/documentation to this PR found on our devwiki.
  • I have added media to this PR or it does not require an ingame showcase.
  • I can confirm this PR contains either no AI-generated content, or AI-generated content that meets our guidelines.

How to test

  • Load up that game
  • grab some hard earned dosh
  • smack it in tha vendomat
  • punch that button fora cold one
  • watch your dosh disappear
  • enjoy the cold one with the lads

Breaking changes

Content.Server.VendingMachines.VendingMachineSystem.cs
Content.Client\VendingMachines\VendingMachineBoundUserInterface.cs
and sumsuch systems now use CreditReceiverComponent to check for the cash slot of a vending machine

New CreditReceiver abstract prototype that VendingMachine needs to inherit from.

An entity parented from VendingMachine that does NOT accept cash needs cashSlot: Null set in their CreditReceiver comp.

Changelog

No CL no fun.

This one still has an issue where the Vendomat doesn't update the GUI correctly until you purchase another update or re-insert the cash.
@monolith8319 monolith8319 changed the title Separation Of Cash Payment from VendingMachineComponent Separation Of Cash Payment From VendingMachineComponent Apr 24, 2026
@ThanosDeGraf

Copy link
Copy Markdown
Contributor Author

@Redrover1760 On draft as said on discord. This is probably very clumsy and not yet done since much of the actual payment logic is still stuck in VendingMachineSystem that I want to break out.

Comment thread Content.Server/VendingMachines/VendingMachineSystem.cs Outdated
@ThanosDeGraf

Copy link
Copy Markdown
Contributor Author

To be fair the "fix" is a bit clumsy, because it sort of needs to check for exactly VendingMachineBoundUserInterface to then update the UI. I've never worked with _uiSystem before, but I think removing that generic should do the trick

ThanosDeGraf and others added 16 commits April 25, 2026 17:58
… void Update()

There was an empty abstract Update method available already, so just use that like a sane person.
Finally! The component handling is one step closer to being seperated from vending machine behavior!
As a cool side effect, inserting cash into vends is now predicted!
looots of WiP still here.
for some reason the client bankComponent doesn't update before the bui.Update, so the bank balance is always one action behind.
@ThanosDeGraf
ThanosDeGraf marked this pull request as ready for review April 29, 2026 12:40
@ThanosDeGraf ThanosDeGraf mentioned this pull request Apr 29, 2026
5 tasks
Every entity parented from VendingMachine that does NOT accept cash needs `cashSlot: Null` in the CreditReceiver comp.

@OneZerooo0 OneZerooo0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crashes the server when an entity without a bank account tries inserting cash

@ThanosDeGraf

Copy link
Copy Markdown
Contributor Author

Crashes the server when an entity without a bank account tries inserting cash

@OneZerooo0 I can't reproduce this, even when I spawn in a fresh monkey. The ATM just gives a pop-up saying "No Bank Account!" when I press Deposit. Do you still remember the exact sequence that causes the crash?

@OneZerooo0

Copy link
Copy Markdown
Contributor

When spawning a Urist and trying to put in cash, the localhost crashes

@ThanosDeGraf

Copy link
Copy Markdown
Contributor Author

When spawning a Urist and trying to put in cash, the localhost crashes

On this PR at least, it's not happening

grafik

I'll update and see what happens IG.

@ThanosDeGraf

Copy link
Copy Markdown
Contributor Author

Updated, still no crash with an urist. Any idea what it could be caused by @OneZerooo0 ?

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@ThanosDeGraf

ThanosDeGraf commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

fixin this rn

Fuck off ilya and your 3000 file change commit.

Comment thread Content.Server/VendingMachines/VendingMachineSystem.cs
Comment thread Content.Server/VendingMachines/VendingMachineSystem.cs
Comment thread Content.Server/VendingMachines/VendingMachineSystem.cs
/// The type of currency to accept in the item slot.
/// </summary>
[DataField]
public string? CurrencyStackType;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use non-nullable ProtoId with a default value set to normal credits stack prototype

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A protoID makes sense, as well as the default money ID, but making it non-nullable will be a massive pain the ass YAML side. Instead of only nulling CreditReceiver for the four vendors that dont need it, I have to add the component to every single vendor that DOES accept it EXCEPT the four special goobers.

@Ilya246 Ilya246 May 26, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, you make a new base vendor type and reparent the ones that don't need credit receiver to it
so you have:

id: BaseVendomat
...
id: BaseVendomatCredit
parent: BaseVendomat

and parent vendomats accordingly

or make the first one BaseVendomatNoCredit and make the second one just BaseVendomat

Comment on lines +10 to +23
/// <summary>
/// Item slot for cash.</summary>
/// <remarks>
/// Set this to Null if you want to disable this component
/// in case you can't get rid of it, i.e. YAML inherited.
/// </remarks>
[DataField]
public ItemSlot? CashSlot;

/// <summary>
/// Name of the cash slot, if there is one. Null if there isn't.
/// </summary>
[DataField]
public string? CashSlotName;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make non-nullable and remove relevant checks, the comp just shouldn't be added if not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. All vending machines inherit this component since they base-line expect to be credit receivers. It's only some vendors that don't want this component.

}


protected void Update(Entity<CreditReceiverComponent> ent)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also don't need this and everything related anymore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are referring to all the validation going on inside the Update method, and not saying you want me to obliterate the Update method. I will go with that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your Update() seems to only handle the cached credits count variable which i told you to remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty. As a heads up with that change it will probably take two weeks or more for me to get it done sine I'm on a vacation rn.

Comment thread Content.Shared/VendingMachines/SharedVendingMachineSystem.cs
Comment thread Content.Shared/VendingMachines/SharedVendingMachineSystem.cs
Comment on lines +14 to +15
/// Mono Change: Anything related to actually accepting physical cash or other currencies has been
/// moved over to <see cref="CreditReceiverComponent"/>. <seealso cref="CreditReceiverComponent.CashSlot"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, as well unneeded usings

Comment on lines +1 to +17
- type: entity
id: CreditReceiver # Mono - Made it an abstract parent so any future changes for vending machines are less likely to break.
abstract: true
description: Allows the machine to accept payment with physical credit. Change the whitelist to allow for different currencies.
components:
- type: CreditReceiver
cashSlot:
whitelist:
components:
- Cash
cashSlotName: cash_slot
currencyStackType: Credit
- type: ItemSlots
- type: ContainerContainer
containers:
cash_slot: !type:ContainerSlot

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be its own file in _Mono considering this isn't just for vending machines

@Ilya246

Ilya246 commented May 26, 2026

Copy link
Copy Markdown
Contributor

also, use (Entity<Comp> ent, ref Event args) form of event subscription functions where you added new ones

@MantasDab360 MantasDab360 mentioned this pull request Jun 15, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants