|
19 | 19 | var/list/medical_list
|
20 | 20 | var/list/grenade_list
|
21 | 21 | var/list/engineering_list
|
| 22 | + var/list/food_list |
22 | 23 | //damage type specific item lists
|
23 | 24 | var/list/brute_list
|
24 | 25 | var/list/burn_list
|
|
61 | 62 | QDEL_NULL(medical_list)
|
62 | 63 | QDEL_NULL(grenade_list)
|
63 | 64 | QDEL_NULL(engineering_list)
|
| 65 | + QDEL_NULL(food_list) |
64 | 66 |
|
65 | 67 | QDEL_NULL(brute_list)
|
66 | 68 | QDEL_NULL(burn_list)
|
|
82 | 84 | medical_list = list()
|
83 | 85 | grenade_list = list()
|
84 | 86 | engineering_list = list()
|
| 87 | + food_list = list() |
85 | 88 |
|
86 | 89 | brute_list = list()
|
87 | 90 | burn_list = list()
|
|
103 | 106 | return
|
104 | 107 | if(equipped_item in equipped_list)
|
105 | 108 | return
|
106 |
| - RegisterSignal(equipped_item, COMSIG_ATOM_ENTERED, PROC_REF(item_stored)) |
107 |
| - RegisterSignal(equipped_item, COMSIG_ITEM_REMOVED_INVENTORY, PROC_REF(item_unequipped)) |
108 | 109 | equipped_list += equipped_item
|
109 | 110 |
|
110 | 111 | var/list/sort_list = list(equipped_item)
|
|
136 | 137 | for(var/obj/item/thing AS in sort_list)
|
137 | 138 | SEND_SIGNAL(thing, COMSIG_INVENTORY_STORED_REMOVAL)
|
138 | 139 |
|
139 |
| -//wrapper due to arg order, can probs remove tho |
| 140 | +///Wrapper for sorting a newly stored item |
140 | 141 | /datum/managed_inventory/proc/item_stored(mob/store_mob, obj/item/new_item, slot)
|
141 | 142 | SIGNAL_HANDLER
|
142 | 143 | sort_item(new_item)
|
143 | 144 |
|
| 145 | +///Sorts an item into any relevant lists |
144 | 146 | /datum/managed_inventory/proc/sort_item(obj/item/new_item)
|
145 |
| - if(isgun(new_item)) |
146 |
| - gun_list_add(new_item) |
| 147 | + var/list/chosen_list = get_right_list(new_item) |
| 148 | + if(!chosen_list) |
147 | 149 | return
|
| 150 | + if(new_item in chosen_list) |
| 151 | + return //moved around on our mob |
| 152 | + |
| 153 | + RegisterSignal(new_item, COMSIG_ATOM_ENTERED, PROC_REF(item_stored)) |
| 154 | + RegisterSignal(new_item, COMSIG_ITEM_REMOVED_INVENTORY, PROC_REF(item_unequipped)) |
| 155 | + |
| 156 | + if(chosen_list == gun_list) |
| 157 | + gun_list_add(new_item) |
| 158 | + if(chosen_list == melee_list) |
| 159 | + melee_list_add(new_item) |
| 160 | + if(chosen_list == grenade_list) |
| 161 | + grenade_list_add(new_item) |
| 162 | + if(chosen_list == ammo_list) |
| 163 | + ammo_list_add(new_item) |
| 164 | + if(chosen_list == medical_list) |
| 165 | + medical_list_add(new_item) |
| 166 | + if(chosen_list == engineering_list) |
| 167 | + engineering_list_add(new_item) |
| 168 | + if(chosen_list == food_list) |
| 169 | + food_list_add(new_item) |
| 170 | + |
| 171 | +///Finds the right list for an item |
| 172 | +/datum/managed_inventory/proc/get_right_list(obj/item/new_item) |
| 173 | + if(isgun(new_item)) |
| 174 | + return gun_list |
148 | 175 | if((istype(new_item, /obj/item/weapon))) //|| istype(new_item, /obj/item/attachable/bayonetknife) //they are a completely different type, so fuck out due to the force changes. sob
|
149 | 176 | if(istype(new_item, /obj/item/weapon/twohanded/offhand))
|
150 | 177 | return
|
151 |
| - melee_list_add(new_item) |
152 |
| - return |
| 178 | + return melee_list |
153 | 179 | if(istype(new_item, /obj/item/explosive/grenade))
|
154 | 180 | if(istype(new_item, /obj/item/explosive/grenade/flare))
|
155 | 181 | return
|
156 |
| - grenade_list_add(new_item) |
157 |
| - return |
| 182 | + return grenade_list |
158 | 183 | if(istype(new_item, /obj/item/ammo_magazine) || istype(new_item, /obj/item/cell/lasgun))
|
159 |
| - ammo_list_add(new_item) |
160 |
| - return |
| 184 | + return ammo_list |
161 | 185 | if(isitemstack(new_item))
|
162 | 186 | if(istype(new_item, /obj/item/stack/medical))
|
163 |
| - medical_list_add(new_item) |
164 |
| - return |
| 187 | + return medical_list |
165 | 188 | if(istype(new_item, /obj/item/stack/sheet))
|
166 |
| - engineering_list_add(new_item) |
167 |
| - return |
| 189 | + return engineering_list |
| 190 | + if(isfood(new_item)) |
| 191 | + return food_list |
168 | 192 | if(isreagentcontainer(new_item) || istype(new_item, /obj/item/tweezers_advanced) || istype(new_item, /obj/item/tweezers))
|
169 |
| - medical_list_add(new_item) |
170 |
| - return |
| 193 | + return medical_list |
171 | 194 |
|
172 | 195 | //boiler plate
|
173 | 196 |
|
174 | 197 | ///Adds an item to this list
|
175 | 198 | /datum/managed_inventory/proc/gun_list_add(obj/item/new_item)
|
176 |
| - SIGNAL_HANDLER |
177 | 199 | if(new_item in gun_list)
|
178 | 200 | return
|
179 | 201 | //I feel like there was some dumb ass reason why I wasn't able to do this... but with testing it works fine??
|
180 | 202 | //might have been relevant for non weapons in storage?
|
181 | 203 | //keep an eye on this.
|
182 | 204 | gun_list += new_item
|
183 |
| - RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(gun_list_removal), TRUE)//COMSIG_MOVABLE_MOVED is sent AFTER COMSIG_ATOM_ENTERED.. this is fucking annoying but eh |
| 205 | + RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(gun_list_removal))//COMSIG_MOVABLE_MOVED is sent AFTER COMSIG_ATOM_ENTERED.. this is fucking annoying but eh |
184 | 206 | SEND_SIGNAL(src, COMSIG_INVENTORY_DAT_GUN_ADDED)
|
185 | 207 |
|
186 | 208 | ///Adds an item to this list
|
187 | 209 | /datum/managed_inventory/proc/melee_list_add(obj/item/new_item)
|
188 |
| - SIGNAL_HANDLER |
189 | 210 | if(new_item in melee_list)
|
190 | 211 | return
|
191 | 212 | melee_list += new_item
|
192 |
| - RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(melee_list_removal), TRUE) |
| 213 | + RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(melee_list_removal)) |
193 | 214 | SEND_SIGNAL(src, COMSIG_INVENTORY_DAT_MELEE_ADDED)
|
194 | 215 |
|
195 | 216 | ///Adds an item to the relevant med lists
|
196 | 217 | /datum/managed_inventory/proc/medical_list_add(obj/item/new_item)
|
197 |
| - SIGNAL_HANDLER |
198 |
| - RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(medical_list_removal), TRUE) |
| 218 | + RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(medical_list_removal)) |
199 | 219 | var/generic = TRUE
|
200 | 220 | for(var/damtype in GLOB.ai_damtype_to_heal_list)
|
201 | 221 | if(!(new_item.type in GLOB.ai_damtype_to_heal_list[damtype]))
|
|
242 | 262 |
|
243 | 263 | ///Adds an item to this list
|
244 | 264 | /datum/managed_inventory/proc/ammo_list_add(obj/item/new_item)
|
245 |
| - SIGNAL_HANDLER |
246 | 265 | ammo_list |= new_item
|
247 |
| - RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(ammo_list_removal), TRUE) |
| 266 | + RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(ammo_list_removal)) |
248 | 267 |
|
249 | 268 | ///Adds an item to this list
|
250 | 269 | /datum/managed_inventory/proc/grenade_list_add(obj/item/new_item)
|
251 |
| - SIGNAL_HANDLER |
252 | 270 | grenade_list |= new_item
|
253 |
| - RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(grenade_list_removal), TRUE) |
| 271 | + RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(grenade_list_removal)) |
254 | 272 |
|
255 | 273 | ///Adds an item to this list
|
256 | 274 | /datum/managed_inventory/proc/engineering_list_add(obj/item/new_item)
|
257 |
| - SIGNAL_HANDLER |
258 | 275 | engineering_list |= new_item
|
259 |
| - RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(engineering_list_removal), TRUE) |
| 276 | + RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(engineering_list_removal)) |
| 277 | + |
| 278 | +///Adds an item to this list |
| 279 | +/datum/managed_inventory/proc/food_list_add(obj/item/new_item) |
| 280 | + food_list |= new_item |
| 281 | + RegisterSignals(new_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL), PROC_REF(food_list_removal)) |
260 | 282 |
|
261 | 283 | ///Removes an item from this list
|
262 | 284 | /datum/managed_inventory/proc/gun_list_removal(obj/item/moving_item)
|
|
317 | 339 | engineering_list -= moving_item
|
318 | 340 | UnregisterSignal(moving_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL))
|
319 | 341 |
|
320 |
| - |
| 342 | +///Removes an item from this list |
| 343 | +/datum/managed_inventory/proc/food_list_removal(obj/item/moving_item) |
| 344 | + SIGNAL_HANDLER |
| 345 | + if(!QDELETED(moving_item) && moving_item.loc == owner) |
| 346 | + return //still in inventory |
| 347 | + food_list -= moving_item |
| 348 | + UnregisterSignal(moving_item, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING, COMSIG_INVENTORY_STORED_REMOVAL)) |
0 commit comments