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:
Tim
2023-02-16 20:22:14 -05:00
committed by GitHub
parent 3c22292ce1
commit a1ada2c9ef
181 changed files with 353 additions and 294 deletions
@@ -28,7 +28,7 @@
if(!user.can_write(used_item))
return
var/new_name = tgui_input_text(user, "What would you like the label to be?", name, max_length = MAX_NAME_LEN)
if((user.get_active_held_item() != used_item) || !user.canUseTopic(src, be_close = TRUE))
if((user.get_active_held_item() != used_item) || !user.can_perform_action(src))
return
if(new_name)
name = "implant case - '[new_name]'"
@@ -53,7 +53,7 @@
var/new_name = tgui_input_text(user, "What would you like the label to be?", name, max_length = MAX_NAME_LEN)
if(user.get_active_held_item() != I)
return
if(!user.canUseTopic(src, be_close = TRUE))
if(!user.can_perform_action(src))
return
if(new_name)
name = "implanter ([new_name])"
@@ -34,7 +34,7 @@
/obj/item/implantpad/AltClick(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
if(!case)
to_chat(user, span_warning("There's no implant to remove from [src]."))
@@ -60,7 +60,7 @@
return ..()
/obj/item/implantpad/ui_interact(mob/user)
if(!user.canUseTopic(src, be_close = TRUE, no_dexterity = FALSE, no_tk = TRUE))
if(!user.can_perform_action(src, FORBID_TELEKINESIS_REACH))
user.unset_machine(src)
user << browse(null, "window=implantpad")
return