|
12 | 12 | new /obj/item/circuitboard/machine/icecream_vat) |
13 | 13 | circuit = /obj/item/circuitboard/machine/icecream_vat |
14 | 14 | //Ice cream to be dispensed into cone on attackby |
15 | | - var/selected_scoop = null |
| 15 | + var/obj/item/reagent_containers/food/snacks/ice_cream_scoop/selected_scoop_type |
16 | 16 | //Cone to be dispensed with alt click |
17 | | - var/selected_cone = null |
| 17 | + var/obj/item/reagent_containers/food/snacks/selected_cone_type |
18 | 18 | //Max amount of items that can be in vat's storage |
19 | 19 | var/storage_capacity = 80 |
20 | 20 | //If it starts empty or not |
|
60 | 60 | data["storage"] = list() |
61 | 61 |
|
62 | 62 | //Loop through starting list for data to send to main tab |
63 | | - for(var/item_detail in ui_list) |
| 63 | + for(var/obj/item/reagent_containers/food/snacks/item_path as anything in ui_list) |
64 | 64 |
|
65 | 65 | //Create needed list and variable for geting data for UI |
66 | 66 | var/list/details = list() |
67 | | - var/obj/item/reagent_containers/food/snacks/item = new item_detail |
68 | 67 |
|
69 | 68 | //Get information for UI |
70 | | - details["item_name"] = item.name |
71 | | - details["item_quantity"] = find_amount(item) |
72 | | - details["item_type_path"] = item.type |
| 69 | + details["item_name"] = item_path::name |
| 70 | + details["item_quantity"] = find_amount(item_path) |
| 71 | + details["item_type_path"] = item_path |
73 | 72 |
|
| 73 | + |
| 74 | + var/obj/item/reagent_containers/food/snacks/initialized_item = new item_path |
74 | 75 | //Get an image for the UI |
75 | | - var/icon/item_pic = getFlatIcon(item) |
| 76 | + var/icon/item_pic = getFlatIcon(initialized_item) |
76 | 77 | var/md5 = md5(fcopy_rsc(item_pic)) |
77 | | - if(!SSassets.cache["photo_[md5]_[item.name]_icon.png"]) |
78 | | - SSassets.transport.register_asset("photo_[md5]_[item.name]_icon.png", item_pic) |
79 | | - SSassets.transport.send_assets(user, list("photo_[md5]_[item.name]_icon.png" = item_pic)) |
80 | | - details["item_image"] = SSassets.transport.get_asset_url("photo_[md5]_[item.name]_icon.png") |
| 78 | + if(!SSassets.cache["photo_[md5]_[initialized_item.name]_icon.png"]) |
| 79 | + SSassets.transport.register_asset("photo_[md5]_[initialized_item.name]_icon.png", item_pic) |
| 80 | + SSassets.transport.send_assets(user, list("photo_[md5]_[initialized_item.name]_icon.png" = item_pic)) |
| 81 | + details["item_image"] = SSassets.transport.get_asset_url("photo_[md5]_[initialized_item.name]_icon.png") |
81 | 82 |
|
82 | 83 | //Sort into different data lists depending on what the item is |
83 | | - if(istype(item, /obj/item/reagent_containers/food/snacks/ice_cream_scoop)) |
84 | | - details["selected_item"] = selected_scoop |
| 84 | + if(ispath(item_path, /obj/item/reagent_containers/food/snacks/ice_cream_scoop)) |
| 85 | + details["selected_item"] = selected_scoop_type |
85 | 86 | data["ice_cream"] += list(details) |
86 | 87 | else |
87 | | - details["selected_item"] = selected_cone |
| 88 | + details["selected_item"] = selected_cone_type |
88 | 89 | data["cones"] += list(details) |
| 90 | + qdel(initialized_item) |
89 | 91 |
|
90 | 92 | //Loop through children of /datum/info_tab/icecream_vat for data to send to info tab |
91 | | - for(var/info_detail in subtypesof(/datum/info_tab/icecream_vat)) |
| 93 | + for(var/datum/info_tab/icecream_vat/info_detail_path as anything in subtypesof(/datum/info_tab/icecream_vat)) |
92 | 94 |
|
93 | 95 | //Create needed list and variable for geting data for UI |
94 | 96 | var/list/details = list() |
95 | | - var/datum/info_tab/icecream_vat/item = new info_detail |
96 | 97 |
|
97 | 98 | //Get info from children |
98 | | - details["section_title"] = item.section |
99 | | - details["section_text"] = item.section_text |
| 99 | + details["section_title"] = info_detail_path::section |
| 100 | + details["section_text"] = info_detail_path::section_text |
100 | 101 |
|
101 | 102 | //Add info to data |
102 | 103 | data["info_tab"] += list(details) |
|
150 | 151 | . = ..() |
151 | 152 |
|
152 | 153 | //Selected cones |
153 | | - if(selected_cone == null) |
| 154 | + if(selected_cone_type == null) |
154 | 155 | . += span_notice("You can <b>Alt Click</b> to dispense a cone once one is selected.") |
155 | 156 | else |
156 | | - var/obj/item/reagent_containers/food/snacks/examine_cone = new selected_cone |
157 | | - . += span_notice("<b>Alt Click</b> to dispense [examine_cone.name].") |
| 157 | + . += span_notice("<b>Alt Click</b> to dispense [selected_cone_type::name].") |
158 | 158 |
|
159 | 159 | //Selected scoops |
160 | | - if(selected_scoop == null) |
| 160 | + if(selected_scoop_type == null) |
161 | 161 | . += span_notice("No ice cream scoop currently selected.") |
162 | 162 | else |
163 | | - var/obj/item/reagent_containers/food/snacks/examine_scoop = new selected_scoop |
164 | | - . += span_notice("[examine_scoop.name] is currently selected.") |
| 163 | + . += span_notice("[selected_scoop_type::name] is currently selected.") |
165 | 164 |
|
166 | 165 | //Scooping cone instruction |
167 | 166 | . += span_notice("<b>Right Click</b> to add a scoop to a cone.") |
168 | 167 |
|
169 | 168 | //For dispensing selected cone |
170 | 169 | /obj/machinery/icecream_vat/AltClick(mob/living/carbon/user) |
171 | | - if(selected_cone != null) |
172 | | - dispense_item(selected_cone) |
| 170 | + if(selected_cone_type != null) |
| 171 | + dispense_item(selected_cone_type) |
173 | 172 | else |
174 | 173 | user.balloon_alert(user, "None selected!") |
175 | 174 |
|
|
222 | 221 |
|
223 | 222 | return amount |
224 | 223 |
|
225 | | -/obj/machinery/icecream_vat/proc/dispense_item(received_item, mob/user = usr) |
226 | | - |
227 | | - //Make a variable for checking the type of the selected item |
228 | | - var/obj/item/reagent_containers/food/snacks/ui_item = new received_item |
229 | | - |
| 224 | +/obj/machinery/icecream_vat/proc/dispense_item(obj/item/reagent_containers/food/snacks/received_item_type, mob/user = usr) |
230 | 225 | //If the vat has some of the desired item, dispense it |
231 | | - if(find_amount(ui_item) > 0) |
| 226 | + if(find_amount(received_item_type) > 0) |
232 | 227 | //Select the last(most recent) of desired item |
233 | | - var/obj/item/reagent_containers/food/snacks/dispensed_item = LAZYACCESS(contents, last_index(ui_item)) |
| 228 | + var/obj/item/reagent_containers/food/snacks/dispensed_item = LAZYACCESS(contents, last_index(received_item_type)) |
234 | 229 | //Drop it on the floor and then move it into the user's hands |
235 | 230 | dispensed_item.forceMove(loc) |
236 | 231 | user.put_in_hands(dispensed_item) |
237 | | - user.visible_message(span_notice("[user] dispenses [ui_item.name] from [src]."), span_notice("You dispense [ui_item.name] from [src].")) |
| 232 | + user.visible_message(span_notice("[user] dispenses [received_item_type::name] from [src]."), span_notice("You dispense [received_item_type::name] from [src].")) |
238 | 233 | playsound(src, dispense_sound, 25, TRUE, extrarange = -3) |
239 | 234 | else |
240 | 235 | //For Alt click and because UI buttons are slow to disable themselves |
241 | 236 | user.balloon_alert(user, "All out!") |
242 | 237 |
|
243 | | -/obj/machinery/icecream_vat/proc/select_item(received_item, mob/user = usr) |
244 | | - |
245 | | - //Make a variable for checking the type of the selected item |
246 | | - var/obj/item/reagent_containers/food/snacks/ui_item = new received_item |
247 | | - |
| 238 | +/obj/machinery/icecream_vat/proc/select_item(obj/item/reagent_containers/food/snacks/received_item_type, mob/user = usr) |
248 | 239 | //Deselecting |
249 | | - if(istype(ui_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
250 | | - if(selected_cone == ui_item.type) |
251 | | - user.visible_message(span_notice("[user] deselects [ui_item.name] from [src]."), span_notice("You deselect [ui_item.name] from [src].")) |
252 | | - selected_cone = null |
| 240 | + if(ispath(received_item_type, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
| 241 | + if(selected_cone_type == received_item_type) |
| 242 | + user.visible_message(span_notice("[user] deselects [received_item_type::name] from [src]."), span_notice("You deselect [received_item_type::name] from [src].")) |
| 243 | + selected_cone_type = null |
253 | 244 | playsound(src, select_sound, 25, TRUE, extrarange = -3) |
254 | | - |
255 | 245 | return |
256 | | - else if(selected_scoop == ui_item.type) |
257 | | - user.visible_message(span_notice("[user] deselects [ui_item.name] from [src]."), span_notice("You deselect [ui_item.name] from [src].")) |
258 | | - selected_scoop = null |
259 | | - playsound(src, select_sound, 25, TRUE, extrarange = -3) |
260 | 246 |
|
| 247 | + else if(selected_scoop_type == received_item_type) |
| 248 | + user.visible_message(span_notice("[user] deselects [received_item_type::name] from [src]."), span_notice("You deselect [received_item_type::name] from [src].")) |
| 249 | + selected_scoop_type = null |
| 250 | + playsound(src, select_sound, 25, TRUE, extrarange = -3) |
261 | 251 | return |
262 | 252 |
|
263 | 253 | //Selecting |
264 | | - if(find_amount(ui_item.type) > 0) |
| 254 | + if(find_amount(received_item_type) > 0) |
265 | 255 | //Set item to selected based on its type |
266 | | - if(istype(ui_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
267 | | - selected_cone = ui_item.type |
| 256 | + if(ispath(received_item_type, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
| 257 | + selected_cone_type = received_item_type |
268 | 258 | else |
269 | | - selected_scoop = ui_item.type |
| 259 | + selected_scoop_type = received_item_type |
270 | 260 | playsound(src, select_sound, 25, TRUE, extrarange = -3) |
271 | | - user.visible_message(span_notice("[user] sets [src] to dispense [ui_item.name]s."), span_notice("You set [src] to dispense [ui_item.name]s.")) |
| 261 | + user.visible_message(span_notice("[user] sets [src] to dispense [received_item_type::name]s."), span_notice("You set [src] to dispense [received_item_type::name]s.")) |
272 | 262 | //Prevent them from selecting items that the vat does not have |
273 | 263 | else |
274 | 264 | user.balloon_alert(user, "All out!") |
275 | 265 |
|
276 | 266 | /obj/machinery/icecream_vat/proc/last_index(obj/item/search_item) |
277 | 267 |
|
278 | | - var/obj/item/reagent_containers/food/snacks/item_index = null |
| 268 | + var/obj/item/reagent_containers/food/snacks/item_index |
279 | 269 |
|
280 | 270 | //Search for the same item path in storage |
281 | 271 | for(var/i in 1 to LAZYLEN(contents)) |
|
342 | 332 | if(istype(target_cone, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
343 | 333 | var/obj/item/reagent_containers/food/snacks/ice_cream_cone/cone = target_cone |
344 | 334 | //Check if a scoop has been selected |
345 | | - if(selected_scoop != null) |
| 335 | + if(selected_scoop_type != null) |
346 | 336 | //Check if there are any of selected scoop in contents |
347 | | - if(find_amount(selected_scoop) > 0) |
| 337 | + if(find_amount(selected_scoop_type) > 0) |
348 | 338 | //Increase scooped variable |
349 | 339 | cone.scoops += 1 |
350 | 340 | //Select last of selected scoop in contents |
351 | | - var/obj/item/reagent_containers/food/snacks/cone_scoop = LAZYACCESS(contents, last_index(selected_scoop)) |
| 341 | + var/obj/item/reagent_containers/food/snacks/cone_scoop = LAZYACCESS(contents, last_index(selected_scoop_type)) |
352 | 342 | //Remove scoop from contents |
353 | 343 | cone_scoop.forceMove(loc) |
354 | 344 | //Increase maximum volume to make room for scoop's chems |
|
0 commit comments