Vendor machine code has been updated to work with more than one product and to have stock. The current four vendor machines (VendorHotDrinks, VendorYouTool, VendorSecTech, VendorRobustDrinks) have at least one product to be dispensed with an initial stock. Both products and stocks are placeholders, so they have functionality for now and can be tested.
They also now run a sound when dispensing, and an error sound when there are is no stock of the product selected. Both sound effects are placeholders.
PR checklist
[ ] The game builds properly without errors.
[ ] No unrelated changes are present.
[ ] No "trash" files are committed.
[ ] Relevant code is documented.
[ ] Update the related GitBook document, or create a new one if needed.
Place a vendor and right-click on it to show the interaction menu, left click different items to dispense. All four vendors should have something to dispense and work correctly. When the stock of one product reaches 0 it should no longer dispense anything.
Networking checklist
[ ] Works from host in host mode.
[ ] Works from server in server mode.
[ ] Works on server in client mode.
[ ] Works and is syncronized across different clients.
[ ] Is persistent.
Changes
VendingMachine.cs has been updated to accept several products.
DispenseProductInteraction.cs has been updated so it works for a specific product, including the index of the product in the VendingMachine and the name/stock of the product to display in the interaction.
VendingMachineProductStock.cs has been created to deal with different products and their stock. Is not an struct, so we can update it easily.
Products are now referenced using the ItemObjectSo instead of the GameObject prefab directly. I'm not 100% sure if that's the correct approach, let me know if we should use something different.
Summary
Vendor machine code has been updated to work with more than one product and to have stock. The current four vendor machines (VendorHotDrinks, VendorYouTool, VendorSecTech, VendorRobustDrinks) have at least one product to be dispensed with an initial stock. Both products and stocks are placeholders, so they have functionality for now and can be tested.
They also now run a sound when dispensing, and an error sound when there are is no stock of the product selected. Both sound effects are placeholders.
PR checklist
Pictures/Videos
https://github.com/RE-SS3D/SS3D/assets/50799541/b7034196-06e0-4088-9ad1-209c68002326
Testing
Place a vendor and right-click on it to show the interaction menu, left click different items to dispense. All four vendors should have something to dispense and work correctly. When the stock of one product reaches 0 it should no longer dispense anything.
Networking checklist
Changes
VendingMachine.cs has been updated to accept several products. DispenseProductInteraction.cs has been updated so it works for a specific product, including the index of the product in the VendingMachine and the name/stock of the product to display in the interaction. VendingMachineProductStock.cs has been created to deal with different products and their stock. Is not an struct, so we can update it easily. Products are now referenced using the ItemObjectSo instead of the GameObject prefab directly. I'm not 100% sure if that's the correct approach, let me know if we should use something different.
Related issues/PRs
Closes #1437