Adds an item scaling element to growns

This commit is contained in:
DragonTrance
2022-06-07 16:51:49 -04:00
parent 7fc9020cee
commit 62a7984206
5 changed files with 51 additions and 9 deletions
+35
View File
@@ -0,0 +1,35 @@
/**
* Element for making items change scaling depending on if they appear in the world or in a storage container.
*
* For context, overworld items are anything on a turf, storage scaling includes anywhere that the item is used as a UI element.
* Scaling should affect the target's icon and any affecting overlays
*/
/datum/element/item_scaling
element_flags = ELEMENT_BESPOKE
id_arg_index = 2
/// Value to scale the target by when it's in the overworld (on a turf)
var/overworld_scaling = 1
/// Value to scale the target by when it's in a storage component or inventory slot
var/storage_scaling = 1
/datum/element/item_scaling/Attach(datum/target, overworld_scaling = 1, storage_scaling = 1)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE
scale(target, overworld_scaling)
RegisterSignal(target, list(COMSIG_ITEM_DROPPED, COMSIG_STORAGE_EXITED), .proc/scale_overworld)
RegisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_STORAGE_ENTERED), .proc/scale_storage)
/datum/element/item_scaling/proc/scale(atom/source, scaling)
var/matrix/M = matrix()
source.transform = M.Scale(scaling)
/// Signal handler for when the item is dropped
/datum/element/item_scaling/proc/scale_overworld(datum/source)
scale(source, overworld_scaling)
/// Signal handler for when the item is picked up
/datum/element/item_scaling/proc/scale_storage(datum/source)
scale(source, storage_scaling)