Skip to content

Commit

Permalink
Merge pull request #3944 from out-of-phaze/tweak/vendor-materials
Browse files Browse the repository at this point in the history
Make vendors include products in matter
  • Loading branch information
MistakeNot4892 authored Apr 28, 2024
2 parents 7d7a363 + 4807053 commit 08c86e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions code/datums/repositories/atom_info.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var/global/repository/atom_info/atom_info_repository = new()
qdel(instance)

/repository/atom_info/proc/get_matter_for(var/path, var/material, var/amount)
RETURN_TYPE(/list)
var/key = create_key_for(path, material, amount)
update_cached_info_for(path, material, amount, key)
. = matter_cache[key]
Expand Down
14 changes: 13 additions & 1 deletion code/datums/vending/stored_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,16 @@
/datum/stored_items/proc/migrate(atom/new_storing_obj)
storing_object = new_storing_obj
for(var/atom/movable/thing in instances)
thing.forceMove(new_storing_obj)
thing.forceMove(new_storing_obj)

/datum/stored_items/proc/get_combined_matter(include_instances = TRUE)
var/virtual_amount = amount - length(instances)
if(virtual_amount)
. = atom_info_repository.get_matter_for(item_path)?.Copy()
for(var/key in .)
.[key] *= virtual_amount
else
. = list()
if(include_instances)
for(var/atom/instance in instances)
. = MERGE_ASSOCS_WITH_NUM_VALUES(., instance.get_contained_matter())
10 changes: 10 additions & 0 deletions code/game/machinery/vending_deconstruction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
return TRUE
. = ..()

/obj/structure/vending_refill/get_contained_matter()
. = ..()
for(var/datum/stored_items/vending_products/record in product_records)
. = MERGE_ASSOCS_WITH_NUM_VALUES(., record.get_combined_matter(include_instances = FALSE))

/obj/machinery/vending/get_contained_matter()
. = ..()
for(var/datum/stored_items/vending_products/record in product_records)
. = MERGE_ASSOCS_WITH_NUM_VALUES(., record.get_combined_matter(include_instances = FALSE))

/obj/machinery/vending/dismantle()
var/obj/structure/vending_refill/dump = new(loc)
dump.SetName("[dump.name] ([name])")
Expand Down

0 comments on commit 08c86e6

Please sign in to comment.