RE-SS3D / SS3D

Space Station 3D, another remake of SS13, but with an extra D.
https://ss3d.space/
249 stars 138 forks source link

Fix vendor machines and add multiple options and stock #1439

Closed David-Goru closed 1 month ago

David-Goru commented 4 months ago

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

imagen

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