|
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) |
89 | | - |
90 | | - //Delete item instance |
91 | | - qdel(item) |
| 90 | + qdel(initialized_item) |
92 | 91 |
|
93 | 92 | //Loop through children of /datum/info_tab/icecream_vat for data to send to info tab |
94 | | - 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)) |
95 | 94 |
|
96 | 95 | //Create needed list and variable for geting data for UI |
97 | 96 | var/list/details = list() |
98 | 97 |
|
99 | 98 | //Get info from children |
100 | | - //Use of : to get info without instancing thanks to JohnFulpWillard |
101 | | - details["section_title"] = info_detail:section |
102 | | - details["section_text"] = info_detail:section_text |
| 99 | + details["section_title"] = info_detail_path::section |
| 100 | + details["section_text"] = info_detail_path::section_text |
103 | 101 |
|
104 | 102 | //Add info to data |
105 | 103 | data["info_tab"] += list(details) |
|
153 | 151 | . = ..() |
154 | 152 |
|
155 | 153 | //Selected cones |
156 | | - if(selected_cone == null) |
| 154 | + if(selected_cone_type == null) |
157 | 155 | . += span_notice("You can <b>Alt Click</b> to dispense a cone once one is selected.") |
158 | 156 | else |
159 | | - . += span_notice("<b>Alt Click</b> to dispense [selected_cone:name].") |
| 157 | + . += span_notice("<b>Alt Click</b> to dispense [selected_cone_type::name].") |
160 | 158 |
|
161 | 159 | //Selected scoops |
162 | | - if(selected_scoop == null) |
| 160 | + if(selected_scoop_type == null) |
163 | 161 | . += span_notice("No ice cream scoop currently selected.") |
164 | 162 | else |
165 | | - . += span_notice("[selected_scoop:name] is currently selected.") |
| 163 | + . += span_notice("[selected_scoop_type::name] is currently selected.") |
166 | 164 |
|
167 | 165 | //Scooping cone instruction |
168 | 166 | . += span_notice("<b>Right Click</b> to add a scoop to a cone.") |
169 | 167 |
|
170 | 168 | //For dispensing selected cone |
171 | 169 | /obj/machinery/icecream_vat/AltClick(mob/living/carbon/user) |
172 | | - if(selected_cone != null) |
173 | | - dispense_item(selected_cone) |
| 170 | + if(selected_cone_type != null) |
| 171 | + dispense_item(selected_cone_type) |
174 | 172 | else |
175 | 173 | user.balloon_alert(user, "None selected!") |
176 | 174 |
|
|
223 | 221 |
|
224 | 222 | return amount |
225 | 223 |
|
226 | | -/obj/machinery/icecream_vat/proc/dispense_item(received_item, mob/user = usr) |
227 | | - |
228 | | - //Make a variable for checking the type of the selected item |
229 | | - var/obj/item/reagent_containers/food/snacks/ui_item = new received_item |
230 | | - |
| 224 | +/obj/machinery/icecream_vat/proc/dispense_item(obj/item/reagent_containers/food/snacks/received_item_type, mob/user = usr) |
231 | 225 | //If the vat has some of the desired item, dispense it |
232 | | - if(find_amount(ui_item) > 0) |
| 226 | + if(find_amount(received_item_type) > 0) |
233 | 227 | //Select the last(most recent) of desired item |
234 | | - 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)) |
235 | 229 | //Drop it on the floor and then move it into the user's hands |
236 | 230 | dispensed_item.forceMove(loc) |
237 | 231 | user.put_in_hands(dispensed_item) |
238 | | - user.visible_message(span_notice("[user] dispenses [received_item:name] from [src]."), span_notice("You dispense [received_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].")) |
239 | 233 | playsound(src, dispense_sound, 25, TRUE, extrarange = -3) |
240 | 234 | else |
241 | 235 | //For Alt click and because UI buttons are slow to disable themselves |
242 | 236 | user.balloon_alert(user, "All out!") |
243 | 237 |
|
244 | | - //Delete item instance |
245 | | - qdel(ui_item) |
246 | | - |
247 | | -/obj/machinery/icecream_vat/proc/select_item(received_item, mob/user = usr) |
248 | | - |
249 | | - //Make a variable for checking the type of the selected item |
250 | | - var/obj/item/reagent_containers/food/snacks/ui_item = new received_item |
251 | | - |
| 238 | +/obj/machinery/icecream_vat/proc/select_item(obj/item/reagent_containers/food/snacks/received_item_type, mob/user = usr) |
252 | 239 | //Deselecting |
253 | | - if(istype(ui_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
254 | | - if(selected_cone == ui_item.type) |
255 | | - user.visible_message(span_notice("[user] deselects [received_item:name] from [src]."), span_notice("You deselect [received_item:name] from [src].")) |
256 | | - 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 |
257 | 244 | playsound(src, select_sound, 25, TRUE, extrarange = -3) |
258 | | - |
259 | 245 | return |
260 | | - else if(selected_scoop == ui_item.type) |
261 | | - user.visible_message(span_notice("[user] deselects [received_item:name] from [src]."), span_notice("You deselect [received_item:name] from [src].")) |
262 | | - selected_scoop = null |
263 | | - playsound(src, select_sound, 25, TRUE, extrarange = -3) |
264 | 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) |
265 | 251 | return |
266 | 252 |
|
267 | 253 | //Selecting |
268 | | - if(find_amount(ui_item.type) > 0) |
| 254 | + if(find_amount(received_item_type) > 0) |
269 | 255 | //Set item to selected based on its type |
270 | | - if(istype(ui_item, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
271 | | - 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 |
272 | 258 | else |
273 | | - selected_scoop = ui_item.type |
| 259 | + selected_scoop_type = received_item_type |
274 | 260 | playsound(src, select_sound, 25, TRUE, extrarange = -3) |
275 | | - user.visible_message(span_notice("[user] sets [src] to dispense [received_item:name]s."), span_notice("You set [src] to dispense [received_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.")) |
276 | 262 | //Prevent them from selecting items that the vat does not have |
277 | 263 | else |
278 | 264 | user.balloon_alert(user, "All out!") |
279 | 265 |
|
280 | | - //Delete item instance |
281 | | - qdel(received_item) |
282 | | - |
283 | 266 | /obj/machinery/icecream_vat/proc/last_index(obj/item/search_item) |
284 | 267 |
|
285 | | - var/obj/item/reagent_containers/food/snacks/item_index = null |
| 268 | + var/obj/item/reagent_containers/food/snacks/item_index |
286 | 269 |
|
287 | 270 | //Search for the same item path in storage |
288 | 271 | for(var/i in 1 to LAZYLEN(contents)) |
|
349 | 332 | if(istype(target_cone, /obj/item/reagent_containers/food/snacks/ice_cream_cone)) |
350 | 333 | var/obj/item/reagent_containers/food/snacks/ice_cream_cone/cone = target_cone |
351 | 334 | //Check if a scoop has been selected |
352 | | - if(selected_scoop != null) |
| 335 | + if(selected_scoop_type != null) |
353 | 336 | //Check if there are any of selected scoop in contents |
354 | | - if(find_amount(selected_scoop) > 0) |
| 337 | + if(find_amount(selected_scoop_type) > 0) |
355 | 338 | //Increase scooped variable |
356 | 339 | cone.scoops += 1 |
357 | 340 | //Select last of selected scoop in contents |
358 | | - 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)) |
359 | 342 | //Remove scoop from contents |
360 | 343 | cone_scoop.forceMove(loc) |
361 | 344 | //Increase maximum volume to make room for scoop's chems |
|
0 commit comments