Separation Of Cash Payment From VendingMachineComponent - #3871
Separation Of Cash Payment From VendingMachineComponent#3871ThanosDeGraf wants to merge 29 commits into
Conversation
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.
|
@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 |
|
To be fair the "fix" is a bit clumsy, because it sort of needs to check for exactly |
… 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.
Plus some comment edits.
Every entity parented from VendingMachine that does NOT accept cash needs `cashSlot: Null` in the CreditReceiver comp.
OneZerooo0
left a comment
There was a problem hiding this comment.
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? |
|
When spawning a Urist and trying to put in cash, the localhost crashes |
|
Updated, still no crash with an urist. Any idea what it could be caused by @OneZerooo0 ? |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
fixin this rn Fuck off ilya and your 3000 file change commit. |
| /// The type of currency to accept in the item slot. | ||
| /// </summary> | ||
| [DataField] | ||
| public string? CurrencyStackType; |
There was a problem hiding this comment.
use non-nullable ProtoId with a default value set to normal credits stack prototype
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: BaseVendomatand parent vendomats accordingly
or make the first one BaseVendomatNoCredit and make the second one just BaseVendomat
| /// <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; |
There was a problem hiding this comment.
make non-nullable and remove relevant checks, the comp just shouldn't be added if not needed
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
also don't need this and everything related anymore
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
your Update() seems to only handle the cached credits count variable which i told you to remove
There was a problem hiding this comment.
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.
| /// Mono Change: Anything related to actually accepting physical cash or other currencies has been | ||
| /// moved over to <see cref="CreditReceiverComponent"/>. <seealso cref="CreditReceiverComponent.CashSlot"/> |
There was a problem hiding this comment.
remove, as well unneeded usings
| - 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 | ||
|
|
There was a problem hiding this comment.
should be its own file in _Mono considering this isn't just for vending machines
|
also, use |

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
CreditReceiverComponentis 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
Media
Requirements
How to test
Breaking changes
Content.Server.VendingMachines.VendingMachineSystem.csContent.Client\VendingMachines\VendingMachineBoundUserInterface.csand sumsuch systems now use
CreditReceiverComponentto check for the cash slot of a vending machineNew
CreditReceiverabstract prototype thatVendingMachineneeds to inherit from.An entity parented from VendingMachine that does NOT accept cash needs
cashSlot: Nullset in their CreditReceiver comp.Changelog
No CL no fun.