Refactor card scaling into an element for general item scaling (#56102)

The current TCG code had some code for scaling its cards down when they're on the ground and then scaling them back in hand/inventory. This element aims to preserve this functionality and to allow it work for other items.

While the TCG makes the cards smaller on the ground, this element allows for items to be scaled up OR down when on the floor or in inventory.

While this particular element has to do with scaling, I am looking at ways to expand this sort of icon change functionality to icon_state as well, but there are additional issues with blood decals needing to be redrawn and possibly vis_contents.
This commit is contained in:
Koshenko
2021-01-21 09:49:33 -03:00
committed by GitHub
parent 5f5d841b7e
commit 51819e5a52
4 changed files with 107 additions and 75 deletions
@@ -12,12 +12,6 @@
. = ..()
set_holdable(list(/obj/item/tcgcard))
/datum/component/storage/concrete/tcg/can_be_inserted(obj/item/I, stop_messages, mob/M)
if(istype(I, /obj/item/tcgcard))
var/obj/item/tcgcard/nu_card = I
nu_card.zoom_out()
return ..()
/datum/component/storage/concrete/tcg/PostTransfer()
. = ..()
handle_empty_deck()
@@ -39,13 +33,6 @@
card_contents = shuffle(card_contents)
/datum/component/storage/concrete/tcg/mass_remove_from_storage(atom/target, list/things, datum/progressbar/progress, trigger_on_found)
for(var/item in 1 to things.len)
if(istype(things[item], /obj/item/tcgcard))
var/obj/item/tcgcard/card = things[item]
if(isturf(target))
card.zoom_out()
else
card.zoom_in()
. = ..()
if(!things.len)
qdel(parent)
@@ -53,14 +40,10 @@
/datum/component/storage/concrete/tcg/proc/handle_empty_deck()
var/list/contents = contents()
//You can't have a deck of one card!
if(contents.len <= 1)
if(contents.len == 1)
var/obj/item/tcgcard_deck/deck = parent
var/obj/item/tcgcard/card = contents[1]
card.forceMove(card.drop_location())
remove_from_storage(card, card.drop_location())
card.flipped = deck.flipped
card.update_icon_state()
if(isturf(card.drop_location()))
card.zoom_out()
else
card.zoom_in()
qdel(parent)