|
6 | 6 | density = TRUE |
7 | 7 | anchored = FALSE |
8 | 8 | use_power = NO_POWER_USE |
9 | | - //Max amount of items that can be in cart's storage |
10 | | - var/storage_capacity = 80 |
| 9 | + //Max amount of items that can be in the cart's contents list |
| 10 | + var/contents_capacity = 80 |
| 11 | + //How many drinking glasses the cart has |
| 12 | + var/glass_quantity = 0 |
| 13 | + //Max amount of drink glasses the cart can have |
| 14 | + var/glass_capacity = 30 |
| 15 | + //Max amount of reagents that can be in cart's mixer |
| 16 | + var/reagent_capacity = 200 |
11 | 17 | //Sound made when an item is dispensed |
12 | 18 | var/dispense_sound = 'sound/machines/click.ogg' |
13 | | - //List used to show items in UI |
14 | | - var/list/ui_list = list() |
| 19 | + //List used to show food items in UI |
| 20 | + var/list/food_ui_list = list() |
| 21 | + //List used to show reagents in cart's reagent storage |
| 22 | + var/list/drink_ui_list = list() |
| 23 | + //List used to show reagents in mixer's reagent storage |
| 24 | + var/list/mixer_ui_list = list() |
| 25 | + //Mixer for dispencing drinks |
| 26 | + var/obj/item/reagent_containers/mixer |
15 | 27 |
|
16 | 28 | /obj/machinery/food_cart_TGUI/ui_interact(mob/user, datum/tgui/ui) |
17 | 29 | ui = SStgui.try_update_ui(user, src, ui) |
|
26 | 38 | data["food"] = list() |
27 | 39 | data["storage"] = list() |
28 | 40 |
|
29 | | - //Loop through starting list for data to send to main tab |
30 | | - for(var/item_detail in ui_list) |
31 | | - |
| 41 | + //Loop through food list for data to send to food tab |
| 42 | + for(var/item_detail in food_ui_list) |
32 | 43 | //Create needed list and variable for geting data for UI |
33 | 44 | var/list/details = list() |
34 | 45 | var/obj/item/reagent_containers/food/item = new item_detail |
|
49 | 60 | //Add to food list |
50 | 61 | data["food"] += list(details) |
51 | 62 |
|
| 63 | + //Loop through drink list for data to send to cart's reagent storage tab |
| 64 | + for(var/datum/reagent/drink in reagents.reagent_list) |
| 65 | + var/list/details = list() |
| 66 | + |
| 67 | + //Get information for UI |
| 68 | + details["drink_name"] = drink.name |
| 69 | + details["drink_quantity"] = drink.volume |
| 70 | + details["drink_type_path"] = drink.type |
| 71 | + |
| 72 | + //Add to drink list |
| 73 | + data["mainDrinks"] += list(details) |
| 74 | + |
| 75 | + //Loop through drink list for data to send to cart's reagent mixer tab |
| 76 | + for(var/datum/reagent/drink in mixer.reagents.reagent_list) |
| 77 | + var/list/details = list() |
| 78 | + |
| 79 | + //Get information for UI |
| 80 | + details["drink_name"] = drink.name |
| 81 | + details["drink_quantity"] = drink.volume |
| 82 | + details["drink_type_path"] = drink.type |
| 83 | + |
| 84 | + //Add to drink list |
| 85 | + data["mixerDrinks"] += list(details) |
| 86 | + |
52 | 87 | //Get content and capacity data |
53 | | - data["contents_length"] = contents.len |
54 | | - data["storage_capacity"] = storage_capacity |
| 88 | + //Have to subtract contents.len by 1 due to reagents container being in contents |
| 89 | + data["contents_length"] = contents.len - 1 |
| 90 | + data["storage_capacity"] = contents_capacity |
| 91 | + data["glass_quantity"] = glass_quantity |
| 92 | + data["glass_capacity"] = glass_capacity |
55 | 93 |
|
56 | 94 | //Send stored information to UI |
57 | 95 | return data |
|
67 | 105 | var/itemPath = text2path(params["itemPath"]) |
68 | 106 | dispense_item(itemPath) |
69 | 107 |
|
70 | | -//For adding items to storage |
| 108 | +/obj/machinery/food_cart_TGUI/Initialize(mapload) |
| 109 | + . = ..() |
| 110 | + //Create reagents holder for drinks |
| 111 | + create_reagents(reagent_capacity, OPENCONTAINER | NO_REACT) |
| 112 | + mixer = new /obj/item/reagent_containers(src, 100) |
| 113 | + |
| 114 | +/obj/machinery/food_cart_TGUI/Destroy() |
| 115 | + QDEL_NULL(mixer) |
| 116 | + return ..() |
| 117 | + |
| 118 | +//For adding items and reagents to storage |
71 | 119 | /obj/machinery/food_cart_TGUI/attackby(obj/item/A, mob/user, params) |
72 | | - //Check to make sure it is a food item |
73 | | - if(istype(A, /obj/item/reagent_containers/food)) |
| 120 | + //Depending on the item, either attempt to store it or ignore it |
| 121 | + if(istype(A, /obj/item/reagent_containers/food/snacks)) |
74 | 122 | storage_single(A) |
| 123 | + else if(istype(A, /obj/item/reagent_containers/food/drinks/drinkingglass)) |
| 124 | + //Check if glass is empty |
| 125 | + if(!A.reagents.total_volume) |
| 126 | + qdel(A) |
| 127 | + glass_quantity++ |
| 128 | + user.visible_message(span_notice("[user] inserts [A] into [src]."), span_notice("You insert [A] into [src].")) |
| 129 | + playsound(src, 'sound/effects/rustle2.ogg', 50, TRUE, extrarange = -3) |
| 130 | + else if(A.is_drainable()) |
| 131 | + return |
75 | 132 |
|
76 | 133 | ..() |
77 | 134 |
|
|
90 | 147 | playsound(src, dispense_sound, 25, TRUE, extrarange = -3) |
91 | 148 | //If the last one was dispenced, remove from UI |
92 | 149 | if(find_amount(ui_item) == 0) |
93 | | - LAZYREMOVE(ui_list, received_item) |
| 150 | + LAZYREMOVE(food_ui_list, received_item) |
94 | 151 | else |
95 | 152 | //For Alt click and because UI buttons are slow to disable themselves |
96 | 153 | user.balloon_alert(user, "All out!") |
97 | 154 |
|
98 | 155 | /obj/machinery/food_cart_TGUI/proc/storage_single(obj/item/target_item, mob/user = usr) |
99 | 156 | //Check if there is room |
100 | | - if(contents.len < storage_capacity) |
101 | | - //If item's typepath is not already in ui_list, add it |
102 | | - if(!LAZYFIND(ui_list, target_item.type)) |
103 | | - LAZYADD(ui_list, target_item.type) |
| 157 | + if(contents.len - 1 < contents_capacity) |
| 158 | + //If item's typepath is not already in food_ui_list, add it |
| 159 | + if(!LAZYFIND(food_ui_list, target_item.type)) |
| 160 | + LAZYADD(food_ui_list, target_item.type) |
104 | 161 | //Move item to content |
105 | 162 | target_item.forceMove(src) |
106 | 163 | user.visible_message(span_notice("[user] inserts [target_item] into [src]."), span_notice("You insert [target_item] into [src].")) |
|
0 commit comments