mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 14:08:31 +01:00
Refactor, improve, and rename canUseTopic to be can_perform_action (#73434)
This builds on what #69790 did and improved the code even further. Notable things: - `Topic()` is a deprecated proc in our codebase (replaced with Javascript tgui) so it makes sense to rename `canUseTopic` to `can_perform_action` which is more straightforward in what it does. - Positional and named arguments have been converted into a easier to use `action_bitflag` - The bitflags adds some new checks you can use like: `NEED_GRAVITY | NEED_LITERACY | NEED_LIGHT` when you want to perform an action. - Redundant, duplicate, or dead code has been removed. - Fixes several runtimes where `canUseTopic` was being called without a proper target (IV drips, gibber, food processor) - Better documentation for the proc and bitflags with examples
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
if(locked)
|
||||
to_chat(user, span_notice("The crate is locked with a Deca-code lock."))
|
||||
var/input = input(usr, "Enter [codelen] digits. All digits must be unique.", "Deca-Code Lock", "") as text|null
|
||||
if(user.canUseTopic(src, be_close = TRUE) && locked)
|
||||
if(user.can_perform_action(src) && locked)
|
||||
var/list/sanitised = list()
|
||||
var/sanitycheck = TRUE
|
||||
var/char = ""
|
||||
@@ -60,7 +60,7 @@
|
||||
return ..()
|
||||
|
||||
/obj/structure/closet/crate/secure/loot/AltClick(mob/living/user)
|
||||
if(!user.canUseTopic(src, be_close = TRUE))
|
||||
if(!user.can_perform_action(src))
|
||||
return
|
||||
return attack_hand(user) //this helps you not blow up so easily by overriding unlocking which results in an immediate boom.
|
||||
|
||||
|
||||
@@ -60,12 +60,12 @@ GLOBAL_LIST_INIT(marker_beacon_colors, sort_list(list(
|
||||
transfer_fingerprints_to(M)
|
||||
|
||||
/obj/item/stack/marker_beacon/AltClick(mob/living/user)
|
||||
if(!istype(user) || !user.canUseTopic(src, be_close = TRUE))
|
||||
if(!istype(user) || !user.can_perform_action(src))
|
||||
return
|
||||
var/input_color = tgui_input_list(user, "Choose a color", "Beacon Color", GLOB.marker_beacon_colors)
|
||||
if(isnull(input_color))
|
||||
return
|
||||
if(!istype(user) || !user.canUseTopic(src, be_close = TRUE))
|
||||
if(!istype(user) || !user.can_perform_action(src))
|
||||
return
|
||||
picked_color = input_color
|
||||
update_appearance()
|
||||
@@ -158,12 +158,12 @@ GLOBAL_LIST_INIT(marker_beacon_colors, sort_list(list(
|
||||
|
||||
/obj/structure/marker_beacon/AltClick(mob/living/user)
|
||||
..()
|
||||
if(!istype(user) || !user.canUseTopic(src, be_close = TRUE))
|
||||
if(!istype(user) || !user.can_perform_action(src))
|
||||
return
|
||||
var/input_color = tgui_input_list(user, "Choose a color", "Beacon Color", GLOB.marker_beacon_colors)
|
||||
if(isnull(input_color))
|
||||
return
|
||||
if(!istype(user) || !user.canUseTopic(src, be_close = TRUE))
|
||||
if(!istype(user) || !user.can_perform_action(src))
|
||||
return
|
||||
picked_color = input_color
|
||||
update_appearance()
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
return . | AFTERATTACK_PROCESSED_ITEM
|
||||
|
||||
/obj/item/organ/internal/monster_core/attack_self(mob/user)
|
||||
if (!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
|
||||
if (!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
|
||||
return
|
||||
try_apply(user, user)
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
|
||||
/obj/machinery/mineral/ore_redemption/AltClick(mob/living/user)
|
||||
. = ..()
|
||||
if(!user.canUseTopic(src, be_close = TRUE))
|
||||
if(!user.can_perform_action(src))
|
||||
return
|
||||
if(panel_open)
|
||||
input_dir = turn(input_dir, -90)
|
||||
|
||||
Reference in New Issue
Block a user