Skip to content

Commit

Permalink
[MIRROR] turns martial arts gloves into a component (#2039) (#2943)
Browse files Browse the repository at this point in the history
* turns martial arts gloves into a component

* Update krav_maga.dm

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: jimmyl <[email protected]>
Co-authored-by: Mal <[email protected]>
  • Loading branch information
4 people authored Apr 18, 2024
1 parent 799e1ae commit 67ee118
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 66 deletions.
45 changes: 45 additions & 0 deletions code/datums/components/martial_art_giver.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/// when equipped and unequipped this item gives a martial art
/datum/component/martial_art_giver
/// the style we give
var/datum/martial_art/style

/datum/component/martial_art_giver/Initialize(style_type)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE

style = new style_type()
style.allow_temp_override = FALSE

/datum/component/martial_art_giver/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(equipped))
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(dropped))

/datum/component/martial_art_giver/UnregisterFromParent(datum/source)
UnregisterSignal(parent, list(COMSIG_ITEM_POST_EQUIPPED, COMSIG_ITEM_POST_UNEQUIP))
var/obj/item/parent_item = parent
if(ismob(parent_item?.loc))
UnregisterSignal(parent, list(COMSIG_MOB_MIND_TRANSFERRED_INTO, COMSIG_MOB_MIND_INITIALIZED, COMSIG_MOB_MIND_TRANSFERRED_OUT_OF))
QDEL_NULL(style)

/datum/component/martial_art_giver/proc/equipped(obj/item/source, mob/user, slot)
SIGNAL_HANDLER
if(!(source.slot_flags & slot))
return
RegisterSignals(user, list(COMSIG_MOB_MIND_TRANSFERRED_INTO, COMSIG_MOB_MIND_INITIALIZED), PROC_REF(teach))
RegisterSignal(user, COMSIG_MOB_MIND_TRANSFERRED_OUT_OF, PROC_REF(forget))
teach(user)

/datum/component/martial_art_giver/proc/dropped(obj/item/source, mob/user)
SIGNAL_HANDLER
forget(user)
UnregisterSignal(user, list(COMSIG_MOB_MIND_TRANSFERRED_INTO, COMSIG_MOB_MIND_INITIALIZED, COMSIG_MOB_MIND_TRANSFERRED_OUT_OF))

/datum/component/martial_art_giver/proc/teach(mob/source)
if(isnull(style))
return
style.teach(source, TRUE)

/datum/component/martial_art_giver/proc/forget(mob/source)
if(isnull(style))
return
style.fully_remove(source)
17 changes: 1 addition & 16 deletions code/datums/martial/boxing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
return ..()

/obj/item/clothing/gloves/boxing
var/datum/martial_art/boxing/style

/obj/item/clothing/gloves/boxing/Initialize(mapload)
. = ..()
Expand All @@ -85,18 +84,4 @@
slapcraft_recipes = slapcraft_recipe_list,\
)

style = new()
style.allow_temp_override = FALSE

/obj/item/clothing/gloves/boxing/Destroy()
QDEL_NULL(style)
return ..()

/obj/item/clothing/gloves/boxing/equipped(mob/user, slot)
. = ..()
if(slot & ITEM_SLOT_GLOVES)
style.teach(user, TRUE)

/obj/item/clothing/gloves/boxing/dropped(mob/user)
. = ..()
style.fully_remove(user)
AddComponent(/datum/component/martial_art_giver, /datum/martial_art/boxing)
17 changes: 1 addition & 16 deletions code/datums/martial/krav_maga.dm
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,11 @@
//Krav Maga Gloves

/obj/item/clothing/gloves/krav_maga
var/datum/martial_art/krav_maga/style
clothing_traits = list(TRAIT_FAST_CUFFING)

/obj/item/clothing/gloves/krav_maga/Initialize(mapload)
. = ..()
style = new()
style.allow_temp_override = FALSE

/obj/item/clothing/gloves/krav_maga/Destroy()
QDEL_NULL(style)
return ..()

/obj/item/clothing/gloves/krav_maga/equipped(mob/user, slot)
. = ..()
if(slot & ITEM_SLOT_GLOVES)
style.teach(user, TRUE)

/obj/item/clothing/gloves/krav_maga/dropped(mob/user)
. = ..()
style.fully_remove(user)
AddComponent(/datum/component/martial_art_giver, /datum/martial_art/krav_maga)

/obj/item/clothing/gloves/krav_maga/sec//more obviously named, given to sec
name = "krav maga gloves"
Expand Down
20 changes: 2 additions & 18 deletions code/datums/martial/sleeping_carp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -325,34 +325,18 @@

/obj/item/clothing/gloves/the_sleeping_carp
name = "carp gloves"
desc = "This gloves are capable of making people use The Sleeping Carp."
desc = "These gloves are capable of making people use The Sleeping Carp."
icon_state = "black"
greyscale_colors = COLOR_BLACK
cold_protection = HANDS
min_cold_protection_temperature = GLOVES_MIN_TEMP_PROTECT
heat_protection = HANDS
max_heat_protection_temperature = GLOVES_MAX_TEMP_PROTECT
resistance_flags = NONE
var/datum/martial_art/the_sleeping_carp/style

/obj/item/clothing/gloves/the_sleeping_carp/Initialize(mapload)
. = ..()
style = new()
style.allow_temp_override = FALSE

/obj/item/clothing/gloves/the_sleeping_carp/Destroy()
QDEL_NULL(style)
return ..()

/obj/item/clothing/gloves/the_sleeping_carp/equipped(mob/user, slot)
. = ..()
if(slot & ITEM_SLOT_GLOVES)
style.teach(user, TRUE)

/obj/item/clothing/gloves/the_sleeping_carp/dropped(mob/user)
. = ..()
if(!isnull(style))
style.fully_remove(user)
AddComponent(/datum/component/martial_art_giver, /datum/martial_art/the_sleeping_carp)

#undef STRONG_PUNCH_COMBO
#undef LAUNCH_KICK_COMBO
Expand Down
17 changes: 1 addition & 16 deletions code/datums/martial/wrestling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -490,22 +490,7 @@ If you make a derivative work from this code, you must include this notification

/obj/item/storage/belt/champion/wrestling
name = "Wrestling Belt"
var/datum/martial_art/wrestling/style

/obj/item/storage/belt/champion/wrestling/Initialize(mapload)
. = ..()
style = new()
style.allow_temp_override = FALSE

/obj/item/storage/belt/champion/wrestling/Destroy()
QDEL_NULL(style)
return ..()

/obj/item/storage/belt/champion/wrestling/equipped(mob/user, slot)
. = ..()
if(slot & ITEM_SLOT_BELT)
style.teach(user, TRUE)

/obj/item/storage/belt/champion/wrestling/dropped(mob/user)
. = ..()
style.fully_remove(user)
AddComponent(/datum/component/martial_art_giver, /datum/martial_art/wrestling)
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@
#include "code\datums\components\manual_breathing.dm"
#include "code\datums\components\manual_heart.dm"
#include "code\datums\components\marionette.dm"
#include "code\datums\components\martial_art_giver.dm"
#include "code\datums\components\mind_linker.dm"
#include "code\datums\components\mirv.dm"
#include "code\datums\components\mob_chain.dm"
Expand Down

0 comments on commit 67ee118

Please sign in to comment.