From db998502f991b911fa6eded797c6befb5dc685c6 Mon Sep 17 00:00:00 2001 From: Runa Dacino Date: Fri, 15 Mar 2024 19:50:03 +0100 Subject: [PATCH] add(atom/movable): Makes it possible for mappers to change scale/rotation of objs (#15835) * Removes update_transform() from mob/ * Adds new file to _defines to hold default scales * Tweaks atom/movable to use new defines * Tweaks mob, living, human, species to use new defines for comparisons * On atom/movable, we check if it is rotated or otherwise scaled and then call update_transform() * It is now possible --- code/__defines/atoms_movable.dm | 7 +++++++ code/game/atoms_movable.dm | 10 ++++++---- code/modules/mob/living/carbon/human/human.dm | 2 +- .../modules/mob/living/carbon/human/species/species.dm | 4 ++-- code/modules/mob/living/living.dm | 2 +- code/modules/mob/mob.dm | 1 - vorestation.dme | 1 + 7 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 code/__defines/atoms_movable.dm diff --git a/code/__defines/atoms_movable.dm b/code/__defines/atoms_movable.dm new file mode 100644 index 00000000000..bbcf1eb6d16 --- /dev/null +++ b/code/__defines/atoms_movable.dm @@ -0,0 +1,7 @@ +/* +** Holds defines for code\game\atoms_movable.dm to avoid magic numbers and potential unexpected overwrites down the line +*/ + +#define DEFAULT_ICON_SCALE_X 1 +#define DEFAULT_ICON_SCALE_Y 1 +#define DEFAULT_ICON_ROTATION 0 diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 757283f00fa..e4643c0bb21 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -16,9 +16,9 @@ var/moved_recently = 0 var/mob/pulledby = null var/item_state = null // Used to specify the item state for the on-mob overlays. - var/icon_scale_x = 1 // Used to scale icons up or down horizonally in update_transform(). - var/icon_scale_y = 1 // Used to scale icons up or down vertically in update_transform(). - var/icon_rotation = 0 // Used to rotate icons in update_transform() + var/icon_scale_x = DEFAULT_ICON_SCALE_X // Used to scale icons up or down horizonally in update_transform(). + var/icon_scale_y = DEFAULT_ICON_SCALE_Y // Used to scale icons up or down vertically in update_transform(). + var/icon_rotation = DEFAULT_ICON_ROTATION // Used to rotate icons in update_transform() var/icon_expected_height = 32 var/icon_expected_width = 32 var/old_x = 0 @@ -45,6 +45,8 @@ add_overlay(list(em_block), TRUE) if(opacity) AddElement(/datum/element/light_blocking) + if(icon_scale_x != DEFAULT_ICON_SCALE_X || icon_scale_y != DEFAULT_ICON_SCALE_Y || icon_rotation != DEFAULT_ICON_ROTATION) + update_transform() switch(light_system) if(STATIC_LIGHT) update_light() @@ -637,4 +639,4 @@ return selfimage /atom/movable/proc/get_cell() - return \ No newline at end of file + return diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 308d2479ef0..d0ac3ead9af 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1211,7 +1211,7 @@ if(species.default_language) add_language(species.default_language) - if(species.icon_scale_x != 1 || species.icon_scale_y != 1) + if(species.icon_scale_x != DEFAULT_ICON_SCALE_X || species.icon_scale_y != DEFAULT_ICON_SCALE_Y) update_transform() if(example) //VOREStation Edit begin diff --git a/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm index 4bdd1cbf0e5..9f68957ceeb 100644 --- a/code/modules/mob/living/carbon/human/species/species.dm +++ b/code/modules/mob/living/carbon/human/species/species.dm @@ -32,8 +32,8 @@ var/tail_animation // If set, the icon to obtain tail animation states from. var/tail_hair - var/icon_scale_x = 1 // Makes the icon wider/thinner. - var/icon_scale_y = 1 // Makes the icon taller/shorter. + var/icon_scale_x = DEFAULT_ICON_SCALE_X // Makes the icon wider/thinner. + var/icon_scale_y = DEFAULT_ICON_SCALE_Y // Makes the icon taller/shorter. var/race_key = 0 // Used for mob icon cache string. var/icon/icon_template // Used for mob icon generation for non-32x32 species. diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 7abf8601aa1..ce7fc6d13e4 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1307,5 +1307,5 @@ /mob/living/set_dir(var/new_dir) . = ..() - if(size_multiplier != 1 || icon_scale_x != 1 && center_offset > 0) + if(size_multiplier != 1 || icon_scale_x != DEFAULT_ICON_SCALE_X && center_offset > 0) update_transform(TRUE) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index ea52bc47604..a27d6b396e0 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -42,7 +42,6 @@ lastarea = get_area(src) set_focus(src) // VOREStation Add - Key Handling hook_vr("mob_new",list(src)) //VOREStation Code - update_transform() // Some mobs may start bigger or smaller than normal. return ..() /mob/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2) diff --git a/vorestation.dme b/vorestation.dme index 05c0ef663e5..9a6c3310a0b 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -33,6 +33,7 @@ #include "code\__defines\admin_vr.dm" #include "code\__defines\appearance.dm" #include "code\__defines\atmos.dm" +#include "code\__defines\atoms_movable.dm" #include "code\__defines\belly_modes_vr.dm" #include "code\__defines\callbacks.dm" #include "code\__defines\chat.dm"