Refactor custom vending machine brand selection (#92205)

The list of options you could choose from when screwdrivering a custom
vending machine circuit board was hard-coded and also contained copy
pastes of every vending machine name (some of which were outdated). It
was yucky
- Add a new var on `/obj/machinery/vending` called `allow_custom`,
defaults to FALSE and determines whether that type shows up as an option
when screwdrivering a custom vending machine board, I've went through
and made assignments for it mirror what was in the old static list i.e.
this won't introduce any new options
- Change the hard-coded static list to be built on Initialize,
populating with every subtype that has `allow_custom` set to TRUE
- Eliminate a second static list that was just the inverse of the first
one (first one was typepath = name and this one was just name =
typepath)
- Changed an `istype` check to `==` because old behavior meant subtypes
of a given vending machine would have their type set to the supertype if
that was also a valid custom vending machine option

Cleaner code, no needing to maintain two separate entries for the name
of a vending machine, eligibility for a machine to be used in custom
vending machines is now a var on the type instead of in a random file
pertaining to circuit boards

🆑
refactor: refactored custom vending machine brand code, a new var on
/obj/machinery/vending called allow_custom now determines whether the
machine can be chosen when screwdrivering the circuit board
/🆑
This commit is contained in:
Roxy
2025-07-29 11:11:24 -04:00
parent 9bf9c875bb
commit 7a9b25c2b7
27 changed files with 91 additions and 69 deletions
@@ -660,88 +660,37 @@
build_path = /obj/machinery/vending/custom
req_components = list(/obj/item/vending_refill/custom = 1)
var/static/list/vending_names_paths = list(
/obj/machinery/vending/assist = "Part-Mart",
/obj/machinery/vending/autodrobe = "AutoDrobe",
/obj/machinery/vending/boozeomat = "Booze-O-Mat",
/obj/machinery/vending/cart = "PTech",
/obj/machinery/vending/cigarette = "ShadyCigs Deluxe",
/obj/machinery/vending/clothing = "ClothesMate",
/obj/machinery/vending/coffee = "Solar's Best Hot Drinks",
/obj/machinery/vending/cola = "Robust Softdrinks",
/obj/machinery/vending/custom = "Custom Vendor",
/obj/machinery/vending/cytopro = "CytoPro",
/obj/machinery/vending/dinnerware = "Plasteel Chef's Dinnerware Vendor",
/obj/machinery/vending/drugs = "NanoDrug Plus",
/obj/machinery/vending/engineering = "Robco Tool Maker",
/obj/machinery/vending/engivend = "Engi-Vend",
/obj/machinery/vending/games = "\improper Good Clean Fun",
/obj/machinery/vending/hydronutrients = "NutriMax",
/obj/machinery/vending/hydroseeds = "MegaSeed Servitor",
/obj/machinery/vending/medical = "NanoMed Plus",
/obj/machinery/vending/modularpc = "Deluxe Silicate Selections",
/obj/machinery/vending/robotics = "Robotech Deluxe",
/obj/machinery/vending/security = "SecTech",
/obj/machinery/vending/snack = "Getmore Chocolate Corp",
/obj/machinery/vending/sovietsoda = "BODA",
/obj/machinery/vending/sustenance = "Sustenance Vendor",
/obj/machinery/vending/tool = "YouTool",
/obj/machinery/vending/wallmed = "NanoMed",
/obj/machinery/vending/wardrobe/atmos_wardrobe = "AtmosDrobe",
/obj/machinery/vending/wardrobe/bar_wardrobe = "BarDrobe",
/obj/machinery/vending/wardrobe/cargo_wardrobe = "CargoDrobe",
/obj/machinery/vending/wardrobe/chap_wardrobe = "ChapDrobe",
/obj/machinery/vending/wardrobe/chef_wardrobe = "ChefDrobe",
/obj/machinery/vending/wardrobe/chem_wardrobe = "ChemDrobe",
/obj/machinery/vending/wardrobe/coroner_wardrobe = "MortiDrobe",
/obj/machinery/vending/wardrobe/curator_wardrobe = "CuraDrobe",
/obj/machinery/vending/wardrobe/det_wardrobe = "DetDrobe",
/obj/machinery/vending/wardrobe/engi_wardrobe = "EngiDrobe",
/obj/machinery/vending/wardrobe/gene_wardrobe = "GeneDrobe",
/obj/machinery/vending/wardrobe/hydro_wardrobe = "HyDrobe",
/obj/machinery/vending/wardrobe/jani_wardrobe = "JaniDrobe",
/obj/machinery/vending/wardrobe/law_wardrobe = "LawDrobe",
/obj/machinery/vending/wardrobe/medi_wardrobe = "MediDrobe",
/obj/machinery/vending/wardrobe/robo_wardrobe = "RoboDrobe",
/obj/machinery/vending/wardrobe/science_wardrobe = "SciDrobe",
/obj/machinery/vending/wardrobe/sec_wardrobe = "SecDrobe",
/obj/machinery/vending/wardrobe/viro_wardrobe = "ViroDrobe",
// SKYRAT STUFF AT THE BOTTOM I SUPPOSE FOR SIMPLICITY'S SAKE
/obj/machinery/vending/access/command = "Command Outfitting Station", //SKYRAT EDIT ADDITION
/obj/machinery/vending/barbervend = "Fab-O-Vend", //SKYRAT EDIT ADDITION
/obj/machinery/vending/dorms = "LustWish", //SKYRAT EDIT CHANGE - ERP UPDATE - ORIGINAL: /obj/machinery/vending/dorms = "KinkVend"
/obj/machinery/vending/imported = "NT Sustenance Supplier", //SKYRAT EDIT ADDITION
/obj/machinery/vending/imported/mothic = "Nomad Fleet Ration Chit Exchange", //SKYRAT EDIT ADDITION
/obj/machinery/vending/imported/tiziran = "Tiziran Imported Delicacies", //SKYRAT EDIT ADDITION
/obj/machinery/vending/imported/yangyu = "Fudobenda", //SKYRAT EDIT ADDITION
/obj/machinery/vending/security = "Armadyne Peacekeeper Equipment Vendor", //SKYRAT EDIT CHANGE - SEC_HUAL - ORIGINAL: /obj/machinery/vending/security = "SecTech",
/obj/machinery/vending/deforest_medvend = "DeForest Med-Vend", //SKYRAT PORT ADDITION
)
///Assoc list (machine name = machine typepath) of all vendors that can be chosen when the circuit is screwdrivered
var/static/list/valid_vendor_names_paths
/obj/item/circuitboard/machine/vendor/Initialize(mapload)
. = ..()
if(!valid_vendor_names_paths)
valid_vendor_names_paths = list()
for(var/obj/machinery/vending/vendor_type as anything in subtypesof(/obj/machinery/vending))
if(vendor_type::allow_custom)
valid_vendor_names_paths[vendor_type::name] = vendor_type
/obj/item/circuitboard/machine/vendor/screwdriver_act(mob/living/user, obj/item/tool)
var/static/list/display_vending_names_paths
if(!display_vending_names_paths)
display_vending_names_paths = list()
for(var/path in vending_names_paths)
display_vending_names_paths[vending_names_paths[path]] = path
var/choice = tgui_input_list(user, "Choose a new brand", "Select an Item", sort_list(display_vending_names_paths))
var/choice = tgui_input_list(user, "Choose a new brand", "Select an Item", sort_list(valid_vendor_names_paths))
if(isnull(choice))
return
if(isnull(display_vending_names_paths[choice]))
if(isnull(valid_vendor_names_paths[choice]))
return
set_type(display_vending_names_paths[choice])
set_type(valid_vendor_names_paths[choice])
return TRUE
/obj/item/circuitboard/machine/vendor/proc/set_type(obj/machinery/vending/typepath)
build_path = typepath
name = "[vending_names_paths[build_path]] Vendor"
name = "[typepath::name] Vendor"
req_components = list(initial(typepath.refill_canister) = 1)
flatpack_components = list(initial(typepath.refill_canister))
/obj/item/circuitboard/machine/vendor/apply_default_parts(obj/machinery/machine)
for(var/typepath in vending_names_paths)
if(istype(machine, typepath))
set_type(typepath)
for(var/key in valid_vendor_names_paths)
// == instead of istype so subtypes don't pass check for their supertypes
if(machine.type == valid_vendor_names_paths[key])
set_type(valid_vendor_names_paths[key])
break
return ..()