mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-25 08:34:23 +00:00
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
45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
/obj/item/beacon
|
|
name = "\improper tracking beacon"
|
|
desc = "A beacon used by a teleporter."
|
|
icon = 'icons/obj/device.dmi'
|
|
icon_state = "beacon"
|
|
inhand_icon_state = "beacon"
|
|
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
|
|
var/enabled = TRUE
|
|
var/renamed = FALSE
|
|
|
|
/obj/item/beacon/Initialize(mapload)
|
|
. = ..()
|
|
if (enabled)
|
|
GLOB.teleportbeacons += src
|
|
else
|
|
icon_state = "beacon-off"
|
|
|
|
/obj/item/beacon/Destroy()
|
|
GLOB.teleportbeacons -= src
|
|
return ..()
|
|
|
|
/obj/item/beacon/attack_self(mob/user)
|
|
enabled = !enabled
|
|
if (enabled)
|
|
icon_state = "beacon"
|
|
GLOB.teleportbeacons += src
|
|
else
|
|
icon_state = "beacon-off"
|
|
GLOB.teleportbeacons -= src
|
|
to_chat(user, span_notice("You [enabled ? "enable" : "disable"] the beacon."))
|
|
return
|
|
|
|
/obj/item/beacon/attackby(obj/item/W, mob/user)
|
|
if(istype(W, /obj/item/pen)) // needed for things that use custom names like the locator
|
|
var/new_name = tgui_input_text(user, "What would you like the name to be?", "Beacon", max_length = MAX_NAME_LEN)
|
|
if(!user.can_perform_action(src))
|
|
return
|
|
if(new_name)
|
|
name = new_name
|
|
renamed = TRUE
|
|
return
|
|
else
|
|
return ..()
|