mirror of
https://github.com/quotefox/Hyper-Station-13.git
synced 2026-08-26 14:16:18 +01:00
Adds an item scaling element to growns
This commit is contained in:
@@ -705,6 +705,11 @@
|
||||
///(obj/item/insertion_candidate, mob/user, silent) - returns bool
|
||||
#define COMSIG_TRY_STORAGE_CAN_INSERT "storage_can_equip"
|
||||
|
||||
//from base of atom/movable/on_enter_storage(): (datum/component/storage/concrete/master_storage)
|
||||
#define COMSIG_STORAGE_ENTERED "storage_entered"
|
||||
//from base of atom/movable/on_exit_storage(): (datum/component/storage/concrete/master_storage)
|
||||
#define COMSIG_STORAGE_EXITED "storage_exited"
|
||||
|
||||
// /datum/component/two_handed signals
|
||||
|
||||
///from base of datum/component/two_handed/proc/wield(mob/living/carbon/user): (/mob/user)
|
||||
|
||||
@@ -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)
|
||||
@@ -699,11 +699,11 @@
|
||||
|
||||
// called when this atom is removed from a storage item, which is passed on as S. The loc variable is already set to the new destination before this is called.
|
||||
/atom/movable/proc/on_exit_storage(datum/component/storage/concrete/S)
|
||||
return
|
||||
SEND_SIGNAL(src, COMSIG_STORAGE_EXITED, S)
|
||||
|
||||
// called when this atom is added into a storage item, which is passed on as S. The loc variable is already set to the storage item.
|
||||
/atom/movable/proc/on_enter_storage(datum/component/storage/concrete/S)
|
||||
return
|
||||
SEND_SIGNAL(src, COMSIG_STORAGE_ENTERED, S)
|
||||
|
||||
/atom/movable/proc/get_spacemove_backup()
|
||||
var/atom/movable/dense_object_backup
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
// This is for adminspawn or map-placed growns. They get the default stats of their seed type.
|
||||
seed = new seed()
|
||||
seed.adjust_potency(50-seed.potency)
|
||||
else if(!seed)
|
||||
stack_trace("Grown initialized without seed. Okay.")
|
||||
return INITIALIZE_HINT_QDEL
|
||||
|
||||
pixel_x = rand(-5, 5)
|
||||
pixel_y = rand(-5, 5)
|
||||
@@ -40,13 +43,11 @@
|
||||
if(dried_type == -1)
|
||||
dried_type = src.type
|
||||
|
||||
if(seed)
|
||||
for(var/datum/plant_gene/trait/T in seed.genes)
|
||||
T.on_new(src, loc)
|
||||
seed.prepare_result(src)
|
||||
transform *= TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5 //Makes the resulting produce's sprite larger or smaller based on potency!
|
||||
add_juice()
|
||||
|
||||
for(var/datum/plant_gene/trait/T in seed.genes)
|
||||
T.on_new(src, loc)
|
||||
seed.prepare_result(src)
|
||||
AddElement(/datum/element/item_scaling, TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5, 1) //Makes the resulting produce's sprite larger or smaller based on potency!
|
||||
add_juice()
|
||||
|
||||
|
||||
/obj/item/reagent_containers/food/snacks/grown/proc/add_juice()
|
||||
|
||||
Reference in New Issue
Block a user