Skip to content

Commit

Permalink
Transform code cleanup (#1163)
Browse files Browse the repository at this point in the history
* make it work

* ghommie stuff

* macro these numbers
  • Loading branch information
Kapu1178 authored Dec 22, 2024
1 parent c87fb7b commit 587dcf6
Show file tree
Hide file tree
Showing 30 changed files with 237 additions and 153 deletions.
6 changes: 3 additions & 3 deletions _maps/RandomRuins/SpaceRuins/bigderelict1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
health = 25;
maxHealth = 25;
name = "hatchling";
resize = 0.85

},
/turf/open/floor/iron,
/area/ruin/space/has_grav/derelictoutpost)
Expand All @@ -646,7 +646,7 @@
health = 25;
maxHealth = 25;
name = "hatchling";
resize = 0.85

},
/turf/open/floor/iron,
/area/ruin/space/has_grav/derelictoutpost)
Expand Down Expand Up @@ -1489,7 +1489,7 @@
health = 25;
maxHealth = 25;
name = "hatchling";
resize = 0.85

},
/turf/open/misc/asteroid,
/area/ruin/space/has_grav/derelictoutpost)
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/// Called on the organ when it is removed from someone (mob/living/carbon/old_owner)
#define COMSIG_ORGAN_REMOVED "comsig_organ_removed"

///from base of mob/update_transform()
#define COMSIG_LIVING_POST_UPDATE_TRANSFORM "living_post_update_transform"
///from base of mob/living/update_transform()
#define COMSIG_MOB_POST_UPDATE_TRANSFORM "mob_post_update_transform"

///from /obj/structure/door/crush(): (mob/living/crushed, /obj/machinery/door/crushing_door)
#define COMSIG_LIVING_DOORCRUSHED "living_doorcrush"
Expand Down
2 changes: 0 additions & 2 deletions code/__DEFINES/dcs/signals/signals_movetype.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// /datum/element/movetype_handler signals
/// Called when the floating anim has to be temporarily stopped and restarted later: (timer)
#define COMSIG_PAUSE_FLOATING_ANIM "pause_floating_anim"
/// From base of datum/element/movetype_handler/on_movement_type_trait_gain: (flag, old_movement_type)
#define COMSIG_MOVETYPE_FLAG_ENABLED "movetype_flag_enabled"
/// From base of datum/element/movetype_handler/on_movement_type_trait_loss: (flag, old_movement_type)
Expand Down
4 changes: 4 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@
/// The default mob sprite size (used for shrinking or enlarging the mob sprite to regular size)
#define RESIZE_DEFAULT_SIZE 1

//Lying angles, which way your head points
#define LYING_ANGLE_EAST 90
#define LYING_ANGLE_WEST 270

/// Get the client from the var
#define CLIENT_FROM_VAR(I) (ismob(I) ? I:client : (istype(I, /client) ? I : (istype(I, /datum/mind) ? I:current?:client : null)))

Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1010,3 +1010,6 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai

#define TRAIT_FLOCKPHASE "TRAIT_FLOCKPHASE"
#define TRAIT_FLOCK_THING "TRAIT_FLOCK_THING"

/// Trait from mob/living/update_transform()
#define UPDATE_TRANSFORM_TRAIT "update_transform"
4 changes: 2 additions & 2 deletions code/datums/components/clickbox.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if(dead_state && isliving(parent))
var/mob/living/living_parent = parent
src.dead_state = dead_state
RegisterSignal(living_parent, COMSIG_LIVING_POST_UPDATE_TRANSFORM, PROC_REF(on_modify_or_update_transform))
RegisterSignal(living_parent, COMSIG_MOB_POST_UPDATE_TRANSFORM, PROC_REF(on_modify_or_update_transform))
RegisterSignal(living_parent, COMSIG_LIVING_DEATH, PROC_REF(on_death))
RegisterSignal(living_parent, COMSIG_LIVING_REVIVE, PROC_REF(on_revive))
if(living_parent.stat == DEAD)
Expand All @@ -48,7 +48,7 @@

/datum/component/clickbox/UnregisterFromParent()
var/atom/movable/mov_parent = parent
UnregisterSignal(mov_parent, list(COMSIG_ATOM_VV_MODIFY_TRANSFORM, COMSIG_LIVING_POST_UPDATE_TRANSFORM, COMSIG_LIVING_DEATH, COMSIG_LIVING_REVIVE))
UnregisterSignal(mov_parent, list(COMSIG_ATOM_VV_MODIFY_TRANSFORM, COMSIG_MOB_POST_UPDATE_TRANSFORM, COMSIG_LIVING_DEATH, COMSIG_LIVING_REVIVE))
mov_parent.underlays -= clickbox_undelay

/// Removes the old underlay and adds a new one if conditions are met. The underlay is scaled up/down if necessary
Expand Down
27 changes: 2 additions & 25 deletions code/datums/elements/movetype_handler.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
element_flags = ELEMENT_DETACH

var/list/attached_atoms = list()
var/list/paused_floating_anim_atoms = list()

/datum/element/movetype_handler/Attach(datum/target)
. = ..()
Expand All @@ -26,7 +25,6 @@
RegisterSignal(movable_target, GLOB.movement_type_removetrait_signals, PROC_REF(on_movement_type_trait_loss))
RegisterSignal(movable_target, SIGNAL_ADDTRAIT(TRAIT_NO_FLOATING_ANIM), PROC_REF(on_no_floating_anim_trait_gain))
RegisterSignal(movable_target, SIGNAL_REMOVETRAIT(TRAIT_NO_FLOATING_ANIM), PROC_REF(on_no_floating_anim_trait_loss))
RegisterSignal(movable_target, COMSIG_PAUSE_FLOATING_ANIM, PROC_REF(pause_floating_anim))
attached_atoms[movable_target] = TRUE

if(movable_target.movement_type & (FLOATING|FLYING) && !HAS_TRAIT(movable_target, TRAIT_NO_FLOATING_ANIM))
Expand All @@ -36,14 +34,12 @@
var/list/signals_to_remove = list(
SIGNAL_ADDTRAIT(TRAIT_NO_FLOATING_ANIM),
SIGNAL_REMOVETRAIT(TRAIT_NO_FLOATING_ANIM),
COMSIG_PAUSE_FLOATING_ANIM
)
signals_to_remove += GLOB.movement_type_addtrait_signals
signals_to_remove += GLOB.movement_type_removetrait_signals
UnregisterSignal(source, signals_to_remove)

attached_atoms -= source
paused_floating_anim_atoms -= source
stop_floating(source)
return ..()

Expand All @@ -55,7 +51,7 @@
return
var/old_state = source.movement_type
source.movement_type |= flag
if(!(old_state & (FLOATING|FLYING)) && (source.movement_type & (FLOATING|FLYING)) && !paused_floating_anim_atoms[source] && !HAS_TRAIT(source, TRAIT_NO_FLOATING_ANIM))
if(!(old_state & (FLOATING|FLYING)) && (source.movement_type & (FLOATING|FLYING)) && !HAS_TRAIT(source, TRAIT_NO_FLOATING_ANIM))
DO_FLOATING_ANIM(source)
SEND_SIGNAL(source, COMSIG_MOVETYPE_FLAG_ENABLED, flag, old_state)

Expand All @@ -80,28 +76,9 @@
/// Called when the TRAIT_NO_FLOATING_ANIM trait is removed from the mob. Restarts the bobbing animation.
/datum/element/movetype_handler/proc/on_no_floating_anim_trait_loss(atom/movable/source, trait)
SIGNAL_HANDLER
if(source.movement_type & (FLOATING|FLYING) && !paused_floating_anim_atoms[source])
if(source.movement_type & (FLOATING|FLYING))
DO_FLOATING_ANIM(source)

///Pauses the floating animation for the duration of the timer... plus [tickrate - (world.time + timer) % tickrate] to be precise.
/datum/element/movetype_handler/proc/pause_floating_anim(atom/movable/source, timer)
SIGNAL_HANDLER
if(paused_floating_anim_atoms[source] < world.time + timer)
stop_floating(source)
if(!length(paused_floating_anim_atoms))
START_PROCESSING(SSdcs, src) //1 second tickrate.
paused_floating_anim_atoms[source] = world.time + timer

/datum/element/movetype_handler/process()
for(var/_paused in paused_floating_anim_atoms)
var/atom/movable/paused = _paused
if(paused_floating_anim_atoms[paused] < world.time)
if(paused.movement_type & (FLOATING|FLYING) && !HAS_TRAIT(paused, TRAIT_NO_FLOATING_ANIM))
DO_FLOATING_ANIM(paused)
paused_floating_anim_atoms -= paused
if(!length(paused_floating_anim_atoms))
STOP_PROCESSING(SSdcs, src)

/// Stops the above. Also not a comsig proc.
/datum/element/movetype_handler/proc/stop_floating(atom/movable/target)
var/final_pixel_y = target.base_pixel_y
Expand Down
6 changes: 2 additions & 4 deletions code/datums/mutations/body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,14 @@
if(..())
return
ADD_TRAIT(owner, TRAIT_GIANT, GENETIC_MUTATION)
owner.resize = 1.25
owner.update_transform()
owner.update_transform(1.25)
owner.visible_message(span_danger("[owner] suddenly grows!"), span_notice("Everything around you seems to shrink.."))

/datum/mutation/human/gigantism/on_losing(mob/living/carbon/human/owner)
if(..())
return
REMOVE_TRAIT(owner, TRAIT_GIANT, GENETIC_MUTATION)
owner.resize = 0.8
owner.update_transform()
owner.update_transform(0.8)
owner.visible_message(span_danger("[owner] suddenly shrinks!"), span_notice("Everything around you seems to grow.."))

/datum/mutation/human/spasms
Expand Down
Loading

0 comments on commit 587dcf6

Please sign in to comment.