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 19:22:14 -06:00
committed by GitHub
parent 3c22292ce1
commit a1ada2c9ef
181 changed files with 353 additions and 294 deletions
+1 -1
View File
@@ -115,7 +115,7 @@
updateDialog(usr) // make sure updates when complete
/datum/song/Topic(href, href_list)
if(!usr.canUseTopic(parent, be_close = TRUE, no_dexterity = FALSE, no_tk = FALSE, need_hands = FALSE, floor_okay = TRUE))
if(!usr.can_perform_action(parent, ALLOW_RESTING))
usr << browse(null, "window=instrument")
usr.unset_machine()
return
+3 -1
View File
@@ -20,7 +20,9 @@
if(!(anchored || can_play_unanchored) || !ismob(music_player))
return STOP_PLAYING
var/mob/user = music_player
if(!user.canUseTopic(src, FALSE, TRUE, FALSE, FALSE)) //can play with TK and while resting because fun.
if(!ISADVANCEDTOOLUSER(user))
to_chat(src, span_warning("You don't have the dexterity to do this!"))
return STOP_PLAYING
/obj/structure/musician/ui_interact(mob/user)