[MIRROR] Refactor, improve, and rename canUseTopic to be can_perform_action [MDB IGNORE] (#19391)

* Refactor, improve, and rename canUseTopic to be can_perform_action

* updoot

* https://github.com/tgstation/tgstation/pull/72876

https://github.com/tgstation/tgstation/pull/72876

---------

Co-authored-by: Tim <timothymtorres@gmail.com>
Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-03-10 04:19:25 +00:00
committed by GitHub
co-authored by Tim Gandalf
parent 7305d12d29
commit f8f2abb11f
209 changed files with 455 additions and 354 deletions
@@ -96,7 +96,7 @@
. = ..()
if(. == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
if(!ishuman(user) || !user.canUseTopic(src, be_close = TRUE))
if(!ishuman(user) || !user.can_perform_action(src))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
if(has_buckled_mobs())
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
@@ -286,7 +286,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/chair/stool, 0)
if(over_object == usr && Adjacent(usr))
if(!item_chair || has_buckled_mobs() || src.flags_1 & NODECONSTRUCT_1)
return
if(!usr.canUseTopic(src, be_close = TRUE, no_dexterity = TRUE, no_tk = FALSE, need_hands = TRUE))
if(!usr.can_perform_action(src, NEED_DEXTERITY|NEED_HANDS))
return
usr.visible_message(span_notice("[usr] grabs \the [src.name]."), span_notice("You grab \the [src.name]."))
var/obj/item/C = new item_chair(loc)
@@ -482,7 +482,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/chair/stool/bar, 0)
/obj/structure/chair/bronze/AltClick(mob/user)
turns = 0
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = TRUE, no_tk = FALSE, need_hands = !iscyborg(user)))
if(!user.can_perform_action(src, NEED_DEXTERITY))
return
if(!(datum_flags & DF_ISPROCESSING))
user.visible_message(span_notice("[user] spins [src] around, and the last vestiges of Ratvarian technology keeps it spinning FOREVER."), \
+1 -1
View File
@@ -135,7 +135,7 @@ LINEN BINS
/obj/item/bedsheet/AltClick(mob/living/user)
// double check the canUseTopic args to make sure it's correct
if(!istype(user) || !user.canUseTopic(src, be_close = TRUE, no_dexterity = TRUE, no_tk = FALSE, need_hands = !iscyborg(user)))
if(!istype(user) || !user.can_perform_action(src, NEED_DEXTERITY))
return
dir = turn(dir, 180)
@@ -614,7 +614,7 @@
set category = "Object"
set name = "Toggle Open"
if(!usr.canUseTopic(src, be_close = TRUE) || !isturf(loc))
if(!usr.can_perform_action(src) || !isturf(loc))
return
if(iscarbon(usr) || issilicon(usr) || isdrone(usr))
@@ -677,7 +677,7 @@
/obj/structure/closet/attack_hand_secondary(mob/user, modifiers)
. = ..()
if(!user.canUseTopic(src, be_close = TRUE) || !isturf(loc))
if(!user.can_perform_action(src) || !isturf(loc))
return
if(!opened && secure)
@@ -49,7 +49,7 @@
var/t = tgui_input_text(user, "What would you like the label to be?", name, max_length = 53)
if(user.get_active_held_item() != interact_tool)
return
if(!user.canUseTopic(src, be_close = TRUE))
if(!user.can_perform_action(src))
return
handle_tag("[t ? t : initial(name)]")
return
@@ -315,7 +315,7 @@
open()
/obj/structure/closet/body_bag/environmental/prisoner/attack_hand_secondary(mob/user, modifiers)
if(!user.canUseTopic(src, be_close = TRUE) || !isturf(loc))
if(!user.can_perform_action(src) || !isturf(loc))
return
togglelock(user)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
+2 -2
View File
@@ -516,7 +516,7 @@
if(!payments_acc)
to_chat(usr, span_notice("[src] hasn't been registered yet."))
return TRUE
if(!usr.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
if(!potential_acc)
to_chat(usr, span_notice("No ID card detected."))
@@ -571,7 +571,7 @@
if(payments_acc != potential_acc.registered_account)
to_chat(usr, span_warning("[src] rejects your new price."))
return
if(!usr.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
to_chat(usr, span_warning("You need to get closer!"))
return
sale_price = new_price_input
+1 -1
View File
@@ -9,7 +9,7 @@
/obj/structure/sacrificealtar/AltClick(mob/living/user)
..()
if(!istype(user) || !user.canUseTopic(src, be_close = TRUE))
if(!istype(user) || !user.can_perform_action(src))
return
if(!has_buckled_mobs())
return
+1 -1
View File
@@ -112,7 +112,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/extinguisher_cabinet, 29)
toggle_cabinet(user)
/obj/structure/extinguisher_cabinet/attack_hand_secondary(mob/living/user)
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = TRUE, no_tk = FALSE, need_hands = TRUE))
if(!user.can_perform_action(src, NEED_DEXTERITY|NEED_HANDS))
return ..()
toggle_cabinet(user)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
+1 -1
View File
@@ -107,7 +107,7 @@
. = ..()
if(.)
return
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return
if(obj_flags & IN_USE)
balloon_alert(user, "wait your turn!")
@@ -167,7 +167,7 @@
playsound(src, 'sound/machines/click.ogg', 10, TRUE)
/obj/item/plunger/AltClick(mob/user)
if(!istype(user) || !user.canUseTopic(src, be_close = TRUE))
if(!istype(user) || !user.can_perform_action(src))
return
var/new_layer = tgui_input_list(user, "Select a layer", "Layer", GLOB.plumbing_layers)
+1 -1
View File
@@ -151,7 +151,7 @@ at the cost of risking a vicious bite.**/
switch(altar_result)
if("Change Color")
var/chosen_color = input(user, "", "Choose Color", pants_color) as color|null
if(!isnull(chosen_color) && user.canUseTopic(src, be_close = TRUE))
if(!isnull(chosen_color) && user.can_perform_action(src))
pants_color = chosen_color
if("Create Artefact")
if(!COOLDOWN_FINISHED(src, use_cooldown) || status != ALTAR_INACTIVE)
+11 -11
View File
@@ -32,7 +32,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
var/new_style = tgui_input_list(user, "Select a facial hairstyle", "Grooming", GLOB.facial_hairstyles_list)
if(isnull(new_style))
return TRUE
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE //no tele-grooming
if(HAS_TRAIT(hairdresser, TRAIT_SHAVED))
to_chat(hairdresser, span_notice("If only growing back facial hair were that easy for you..."))
@@ -44,7 +44,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
var/new_style = tgui_input_list(user, "Select a hairstyle", "Grooming", GLOB.hairstyles_list)
if(isnull(new_style))
return TRUE
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE //no tele-grooming
if(HAS_TRAIT(hairdresser, TRAIT_BALD))
to_chat(hairdresser, span_notice("If only growing back hair were that easy for you..."))
@@ -176,7 +176,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
if(isnull(choice))
return TRUE
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
switch(choice)
@@ -184,7 +184,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
var/newname = sanitize_name(tgui_input_text(amazed_human, "Who are we again?", "Name change", amazed_human.name, MAX_NAME_LEN), allow_numbers = TRUE) //It's magic so whatever.
if(!newname)
return TRUE
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
amazed_human.real_name = newname
amazed_human.name = newname
@@ -199,7 +199,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
return TRUE
if(!selectable_races[racechoice])
return TRUE
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
var/datum/species/newrace = selectable_races[racechoice]
@@ -213,7 +213,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
if(MUTCOLORS in amazed_human.dna.species.species_traits)
var/new_mutantcolor = input(user, "Choose your skin color:", "Race change", amazed_human.dna.features["mcolor"]) as color|null
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
if(new_mutantcolor)
var/temp_hsv = RGBtoHSV(new_mutantcolor)
@@ -234,7 +234,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
return TRUE
if(amazed_human.gender == "male")
if(tgui_alert(amazed_human, "Become a Witch?", "Confirmation", list("Yes", "No")) == "Yes")
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
amazed_human.gender = FEMALE
amazed_human.physique = FEMALE
@@ -244,7 +244,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
else
if(tgui_alert(amazed_human, "Become a Warlock?", "Confirmation", list("Yes", "No")) == "Yes")
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
amazed_human.gender = MALE
amazed_human.physique = MALE
@@ -257,13 +257,13 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
if("hair")
var/hairchoice = tgui_alert(amazed_human, "Hairstyle or hair color?", "Change Hair", list("Style", "Color"))
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
if(hairchoice == "Style") //So you just want to use a mirror then?
return ..()
else
var/new_hair_color = input(amazed_human, "Choose your hair color", "Hair Color",amazed_human.hair_color) as color|null
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
if(new_hair_color)
amazed_human.hair_color = sanitize_hexcolor(new_hair_color)
@@ -278,7 +278,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror, 28)
if(BODY_ZONE_PRECISE_EYES)
var/new_eye_color = input(amazed_human, "Choose your eye color", "Eye Color", amazed_human.eye_color_left) as color|null
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return TRUE
if(new_eye_color)
amazed_human.eye_color_left = sanitize_hexcolor(new_eye_color)
+2 -2
View File
@@ -90,7 +90,7 @@ GLOBAL_LIST_EMPTY(bodycontainers) //Let them act as spawnpoints for revenants an
var/t = tgui_input_text(user, "What would you like the label to be?", text("[]", name), null)
if (user.get_active_held_item() != P)
return
if(!user.canUseTopic(src, be_close = TRUE))
if(!user.can_perform_action(src))
return
if (t)
name = text("[]- '[]'", initial(name), t)
@@ -178,7 +178,7 @@ GLOBAL_LIST_EMPTY(bodycontainers) //Let them act as spawnpoints for revenants an
/obj/structure/bodycontainer/morgue/AltClick(mob/user)
..()
if(!user.canUseTopic(src, !issilicon(user)))
if(!user.can_perform_action(src, ALLOW_SILICON_REACH))
return
beeper = !beeper
to_chat(user, span_notice("You turn the speaker function [beeper ? "on" : "off"]."))
+2 -2
View File
@@ -165,13 +165,13 @@
to_chat(user, span_warning("The rotation is locked!"))
return FALSE
var/new_angle = tgui_input_number(user, "New angle for primary reflection face", "Reflector Angle", rotation_angle, 360)
if(isnull(new_angle) || QDELETED(user) || QDELETED(src) || !usr.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(isnull(new_angle) || QDELETED(user) || QDELETED(src) || !usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return FALSE
set_angle(SIMPLIFY_DEGREES(new_angle))
return TRUE
/obj/structure/reflector/AltClick(mob/user)
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = TRUE, no_tk = FALSE, need_hands = !iscyborg(user)))
if(!user.can_perform_action(src, NEED_DEXTERITY))
return
else if(finished)
rotate(user)
+1 -1
View File
@@ -131,7 +131,7 @@ FLOOR SAFES
if(!ishuman(usr))
return
var/mob/living/carbon/human/user = usr
if(!user.canUseTopic(src, be_close = TRUE))
if(!user.can_perform_action(src))
return
var/canhear = FALSE
@@ -176,7 +176,7 @@
/obj/structure/training_machine/AltClick(mob/user)
. = ..()
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = TRUE, no_tk = TRUE, floor_okay = TRUE))
if(!user.can_perform_action(src, NEED_DEXTERITY|FORBID_TELEKINESIS_REACH|ALLOW_RESTING))
return
if(has_buckled_mobs())
user_unbuckle_mob(buckled_mobs[1], user)