Skip to content

Commit

Permalink
add inversion verb, fix inversion verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Jan 5, 2025
1 parent 9793e79 commit 68c9637
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 2 deletions.
2 changes: 2 additions & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@
#include "code\datums\components\items\wielding.dm"
#include "code\datums\components\mobs\block_frame.dm"
#include "code\datums\components\mobs\mob_self_horizontal_inversion.dm"
#include "code\datums\components\mobs\mob_self_vertical_inversion.dm"
#include "code\datums\components\mobs\parry_frame.dm"
#include "code\datums\components\movable\aquarium.dm"
#include "code\datums\components\movable\spatial_grid.dm"
Expand Down Expand Up @@ -4146,6 +4147,7 @@
#include "code\modules\mob\observer\dead\perspective.dm"
#include "code\modules\mob\observer\dead\say.dm"
#include "code\modules\mob\verbs\horizontal_invert_self.dm"
#include "code\modules\mob\verbs\vertical_invert_self.dm"
#include "code\modules\modular_computers\laptop_vendor.dm"
#include "code\modules\modular_computers\computers\modular_computer\core.dm"
#include "code\modules\modular_computers\computers\modular_computer\damage.dm"
Expand Down
6 changes: 6 additions & 0 deletions code/datums/components/mobs/mob_self_horizontal_inversion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/datum/component/mob_self_horizontal_inversion/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_MOVABLE_BASE_TRANSFORM, PROC_REF(alter_base_transform))
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_move))
var/mob/target = parent
var/matrix/to_apply = target.transform
to_apply.Scale(-1, 1)
Expand All @@ -23,6 +24,7 @@
/datum/component/mob_self_horizontal_inversion/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, COMSIG_MOVABLE_BASE_TRANSFORM)
UnregisterSignal(parent, COMSIG_MOVABLE_MOVED)
var/mob/target = parent
var/matrix/to_apply = target.transform
to_apply.Scale(-1, 1)
Expand All @@ -31,3 +33,7 @@
/datum/component/mob_self_horizontal_inversion/proc/alter_base_transform(datum/source, matrix/applying)
SIGNAL_HANDLER
applying.Scale(-1, 1)

/datum/component/mob_self_horizontal_inversion/proc/on_move(datum/source)
SIGNAL_HANDLER
qdel(src)
40 changes: 40 additions & 0 deletions code/datums/components/mobs/mob_self_vertical_inversion.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

/**
* Component added to a mob by the mob themselves to invert themselves vertically.
*/
/datum/component/mob_self_vertical_inversion
registered_type = /datum/component/mob_self_vertical_inversion

/datum/component/mob_self_vertical_inversion/Initialize()
if(!ismob(parent))
return COMPONENT_INCOMPATIBLE
return ..()

/datum/component/mob_self_vertical_inversion/RegisterWithParent()
. = ..()
// todo: allow it if they're being moved by an external source; MOB_SLEFMOVE?
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_move))
RegisterSignal(parent, COMSIG_MOVABLE_BASE_TRANSFORM, PROC_REF(alter_base_transform))
var/mob/target = parent
var/matrix/to_apply = target.transform
to_apply.Scale(1, -1)
target.set_transform(to_apply)

/datum/component/mob_self_vertical_inversion/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, COMSIG_MOVABLE_BASE_TRANSFORM)
UnregisterSignal(parent, COMSIG_MOVABLE_MOVED)
var/mob/target = parent
var/matrix/to_apply = target.transform
to_apply.Scale(1, -1)
target.set_transform(to_apply)

/datum/component/mob_self_vertical_inversion/proc/alter_base_transform(datum/source, matrix/applying)
SIGNAL_HANDLER
applying.Scale(1, -1)

/datum/component/mob_self_vertical_inversion/proc/on_move(datum/source)
SIGNAL_HANDLER
qdel(src)
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)

/mob/living/carbon/human/apply_transform(matrix/to_apply)
var/anim_time = CHECK_MOBILITY(src, MOBILITY_CAN_STAND)? 3 : 1
animate(src, transform = to_apply, time = anim_time, flags = ANIMATION_PARALLEL)
animate(src, transform = to_apply, time = anim_time, flags = ANIMATION_PARALLEL | ANIMATION_LINEAR_TRANSFORM)
update_icon_special() //May contain transform-altering things
update_ssd_overlay()

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ default behaviour is:
return applying

/mob/living/apply_transform(matrix/to_apply)
animate(src, transform = to_apply, time = 1 SECONDS)
animate(src, transform = to_apply, time = 1 SECONDS, flags = ANIMATION_LINEAR_TRANSFORM | ANIMATION_PARALLEL)
update_ssd_overlay()

// This handles setting the client's color variable, which makes everything look a specific color.
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/verbs/horizontal_invert_self.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

// todo: DECLARE_MOB_VERB
/mob/verb/horizontal_invert_self()
set name = "Invert Yourself (Horizontal)"
set desc = "Mirror your sprite across the N-S axis."
Expand Down
24 changes: 24 additions & 0 deletions code/modules/mob/verbs/vertical_invert_self.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2025 Citadel Station Developers *//

// todo: DECLARE_MOB_VERB
/mob/verb/vertical_invert_self()
set name = "Invert Yourself (Vertical)"
set desc = "Mirror your sprite across the N-S axis."
set category = VERB_CATEGORY_IC

// todo: remote control? mobs that don't allow it?

if(TIMER_COOLDOWN_CHECK(src, CD_INDEX_MOB_VERB_INVERT_SELF))
// todo: don't usr lol
to_chat(usr, SPAN_WARNING("You can't do that yet!"))
return
TIMER_COOLDOWN_START(src, CD_INDEX_MOB_VERB_INVERT_SELF, 0.5 SECONDS)

log_game("[key_name(usr)] invoked vertical_invert_self on [key_name(src)].")

var/datum/component/mob_self_vertical_inversion/inversion = GetComponent(/datum/component/mob_self_vertical_inversion)
if(inversion)
qdel(inversion)
else
AddComponent(/datum/component/mob_self_vertical_inversion)

0 comments on commit 68c9637

Please sign in to comment.