mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
ADDED costume restocking unit
REMOVED many useless comments ADDED invoke vending_refill consutructor superclass ADDED: Cargo can order the autodrobe supply crate
This commit is contained in:
@@ -112,11 +112,8 @@
|
||||
|
||||
var/to_restock = 0
|
||||
for(var/datum/data/vending_product/machine_content in machine)
|
||||
//first pass we count how many items are missing
|
||||
to_restock += machine_content.max_amount - machine_content.amount
|
||||
|
||||
|
||||
//we attempt to go on the "fast lane" (restock all to max)
|
||||
if(to_restock <= refill.charges)
|
||||
for(var/datum/data/vending_product/machine_content in machine)
|
||||
if(machine_content.amount != machine_content.max_amount)
|
||||
@@ -125,23 +122,17 @@
|
||||
refill.charges -= to_restock
|
||||
total = to_restock
|
||||
else
|
||||
//We need to stock items equally in each categories based on the amount of items missing.
|
||||
//This algorithm will restock each category by percentage, the more items being missing, the larger the
|
||||
//amount of refills it will get, keeps stocks even.
|
||||
var/tmp_charges = refill.charges //we need to cache the charges to keep the equation from changing
|
||||
var/tmp_charges = refill.charges
|
||||
for(var/datum/data/vending_product/machine_content in machine)
|
||||
var/restock = Ceiling(((machine_content.max_amount - machine_content.amount)/to_restock)*tmp_charges)
|
||||
|
||||
//we cannot restock more than what we have, might happen since we are rounding up.
|
||||
if(restock > refill.charges)
|
||||
restock = refill.charges
|
||||
|
||||
machine_content.amount += restock
|
||||
refill.charges -= restock
|
||||
total += restock
|
||||
if(restock)
|
||||
usr << "<span class='notice'>[restock] of [machine_content.product_name]</span>"
|
||||
if(refill.charges == 0)//due to rounding, we ran out of refill charges, exit.
|
||||
if(refill.charges == 0) //due to rounding, we ran out of refill charges, exit.
|
||||
break
|
||||
return total
|
||||
|
||||
@@ -171,24 +162,20 @@
|
||||
return
|
||||
else if(istype(W, refill_canister) && refill_canister != null)
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
//we do nothing if the machine is unpowered.
|
||||
user << "<span class='notice'>It does nothing.</span>"
|
||||
else if(panel_open)
|
||||
//if the panel is open
|
||||
//we attempt to refill the machine
|
||||
//if the panel is open we attempt to refill the machine
|
||||
var/obj/item/weapon/vending_refill/canister = W
|
||||
if(canister.charges == 0)
|
||||
//there is no charge left in this canister.
|
||||
user << "<span class='notice'>This [canister.name] is empty!</span>"
|
||||
else
|
||||
var/transfered = refill_inventory(canister,product_records,user)
|
||||
if(transfered)
|
||||
user << "<span class='notice'>You loaded [transfered] items in [name].</span>"
|
||||
user << "<span class='notice'>You loaded [transfered] items in \the [name].</span>"
|
||||
else
|
||||
user << "<span class='notice'>[name] is fully stocked.</span>"
|
||||
user << "<span class='notice'>The [name] is fully stocked.</span>"
|
||||
return;
|
||||
else
|
||||
//the service panel is closed, lets "subtly" hint at opening it.
|
||||
user << "<span class='notice'>You should probably unscrew the service panel first.</span>"
|
||||
else
|
||||
..()
|
||||
@@ -694,6 +681,7 @@
|
||||
/obj/item/clothing/head/rabbitears =1) //Pretty much everything that had a chance to spawn.
|
||||
contraband = list(/obj/item/clothing/suit/cardborg = 1,/obj/item/clothing/head/cardborg = 1,/obj/item/clothing/suit/judgerobe = 1,/obj/item/clothing/head/powdered_wig = 1)
|
||||
premium = list(/obj/item/clothing/suit/hgpirate = 1, /obj/item/clothing/head/hgpiratecap = 1, /obj/item/clothing/head/helmet/roman = 1, /obj/item/clothing/head/helmet/roman/legionaire = 1, /obj/item/clothing/under/roman = 1, /obj/item/clothing/shoes/roman = 1, /obj/item/weapon/shield/riot/roman = 1)
|
||||
refill_canister = /obj/item/weapon/vending_refill/autodrobe
|
||||
|
||||
/obj/machinery/vending/dinnerware
|
||||
name = "dinnerware"
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
var/charges = 0 //how many restocking "charges" the refill has
|
||||
|
||||
/obj/item/weapon/vending_refill/New()
|
||||
..()
|
||||
name = "\improper [machine_name] restocking unit"
|
||||
|
||||
/obj/item/weapon/vending_refill/examine()
|
||||
@@ -23,36 +24,35 @@
|
||||
if(charges)
|
||||
usr << "It can restock [charges] item(s)."
|
||||
else
|
||||
usr << "it is empty!"
|
||||
usr << "It's empty!"
|
||||
|
||||
//NOTE I decided to go for about 1/3 of a machine's capacity
|
||||
|
||||
/obj/item/weapon/vending_refill/boozeomat
|
||||
machine_name = "Booze-O-Mat"
|
||||
icon_state = "refill_booze"
|
||||
//machine contains max 138 items
|
||||
charges = 50
|
||||
charges = 50//of 138
|
||||
|
||||
/obj/item/weapon/vending_refill/coffee
|
||||
machine_name = "hot drinks"
|
||||
icon_state = "refill_joe"
|
||||
//machine contains max 85 items
|
||||
charges = 30
|
||||
charges = 30//of 85
|
||||
|
||||
/obj/item/weapon/vending_refill/snack
|
||||
machine_name = "Getmore Chocolate Corp"
|
||||
//machine contains max 48 items
|
||||
charges = 15
|
||||
charges = 15//of 48
|
||||
|
||||
/obj/item/weapon/vending_refill/cola
|
||||
machine_name = "Robust Softdrinks"
|
||||
icon_state = "refill_cola"
|
||||
//machine contains max 65 items
|
||||
charges = 20
|
||||
charges = 20//of 65
|
||||
|
||||
/obj/item/weapon/vending_refill/cigarette
|
||||
machine_name = "cigarette"
|
||||
icon_state = "refill_smoke"
|
||||
//machine contains max 30 items
|
||||
charges = 10
|
||||
charges = 10// of 30
|
||||
|
||||
/obj/item/weapon/vending_refill/autodrobe
|
||||
machine_name = "AutoDrobe"
|
||||
icon_state = "refill_costume"
|
||||
charges = 28// of 58
|
||||
|
||||
Reference in New Issue
Block a user