mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-27 01:21:30 +00:00
* Fixes a few bugs with greyscale stacks. (#54858) Fixes greyscale floor tiles merging regardless of their materials. Fixes greyscale floor tiles voiding materials when splitting the stack. Fixes greyscale floor tile stacks being created with no mats_per_unit and only enough custom materials for a single unit. Fixes greyscale tile flooring being created with the wrong amount of materials. Fixes greyscale tile flooring not producing floor tiles/producing floor tiles with 0 units. * Fixes a few bugs with greyscale stacks. Co-authored-by: TemporalOroboros <TemporalOroboros@gmail.com>
69 lines
2.0 KiB
Plaintext
69 lines
2.0 KiB
Plaintext
//Stack-only storage.
|
|
/datum/component/storage/concrete/stack
|
|
display_numerical_stacking = TRUE
|
|
var/max_combined_stack_amount = 300
|
|
max_w_class = WEIGHT_CLASS_NORMAL
|
|
max_combined_w_class = WEIGHT_CLASS_NORMAL * 14
|
|
|
|
/datum/component/storage/concrete/stack/proc/total_stack_amount()
|
|
. = 0
|
|
var/atom/real_location = real_location()
|
|
for(var/i in real_location)
|
|
var/obj/item/stack/S = i
|
|
if(!istype(S))
|
|
continue
|
|
. += S.amount
|
|
|
|
/datum/component/storage/concrete/stack/proc/remaining_space()
|
|
return max(0, max_combined_stack_amount - total_stack_amount())
|
|
|
|
//emptying procs do not need modification as stacks automatically merge.
|
|
|
|
/datum/component/storage/concrete/stack/_insert_physical_item(obj/item/I, override = FALSE)
|
|
if(!istype(I, /obj/item/stack))
|
|
if(override)
|
|
return ..()
|
|
return FALSE
|
|
var/atom/real_location = real_location()
|
|
var/obj/item/stack/S = I
|
|
var/can_insert = min(S.amount, remaining_space())
|
|
if(!can_insert)
|
|
return FALSE
|
|
for(var/i in real_location) //combine.
|
|
if(QDELETED(I))
|
|
return
|
|
var/obj/item/stack/_S = i
|
|
if(!istype(_S))
|
|
continue
|
|
if(_S.merge_type == S.merge_type)
|
|
_S.add(can_insert)
|
|
S.use(can_insert, TRUE)
|
|
return TRUE
|
|
I = S.split_stack(null, can_insert)
|
|
return ..()
|
|
|
|
/datum/component/storage/concrete/stack/remove_from_storage(obj/item/I, atom/new_location)
|
|
var/atom/real_location = real_location()
|
|
var/obj/item/stack/S = I
|
|
if(!istype(S))
|
|
return ..()
|
|
if(S.amount > S.max_amount)
|
|
var/overrun = S.amount - S.max_amount
|
|
S.amount = S.max_amount
|
|
var/obj/item/stack/temp = new S.type(real_location, overrun)
|
|
handle_item_insertion(temp)
|
|
return ..(S, new_location)
|
|
|
|
/datum/component/storage/concrete/stack/_process_numerical_display()
|
|
var/atom/real_location = real_location()
|
|
. = list()
|
|
for(var/i in real_location)
|
|
var/obj/item/stack/I = i
|
|
if(!istype(I) || QDELETED(I)) //We're specialized stack storage, just ignore non stacks.
|
|
continue
|
|
if(!.[I.merge_type])
|
|
.[I.merge_type] = new /datum/numbered_display(I, I.amount)
|
|
else
|
|
var/datum/numbered_display/ND = .[I.merge_type]
|
|
ND.number += I.amount
|