Files
Bubberstation/code/game/objects/items/hourglass.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
Makes the code compatible with 515.1594+

Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword

And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.

@tgstation/commit-access Since the .proc/stuff is pretty big change.

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-11-15 03:50:11 +00:00

81 lines
2.2 KiB
Plaintext

#define HOURGLASS_STATES 7 //Remember to update if you change the sprite
/obj/item/hourglass
name = "hourglass"
desc = "Nanotrasen patented gravity invariant hourglass. Guaranteed to flow perfectly under any conditions."
var/obj/effect/countdown/hourglass/countdown
var/time = 1 MINUTES
var/finish_time //So countdown doesn't need to fiddle with timers
var/timing_id //if present we're timing
var/hand_activated = TRUE
icon = 'icons/obj/toys/hourglass.dmi'
icon_state = "hourglass_idle"
/obj/item/hourglass/Initialize(mapload)
. = ..()
countdown = new(src)
/obj/item/hourglass/attack_self(mob/user)
. = ..()
if(hand_activated)
toggle(user)
/obj/item/hourglass/proc/toggle(mob/user)
if(!timing_id)
to_chat(user,span_notice("You flip the [src]."))
start()
flick("hourglass_flip",src)
else
to_chat(user,span_notice("You stop the [src].")) //Sand magically flows back because that's more convinient to use.
stop()
/obj/item/hourglass/update_icon_state()
icon_state = "hourglass_[timing_id ? "active" : "idle"]"
return ..()
/obj/item/hourglass/proc/start()
finish_time = world.time + time
timing_id = addtimer(CALLBACK(src, PROC_REF(finish)), time, TIMER_STOPPABLE)
countdown.start()
timing_animation()
/obj/item/hourglass/proc/timing_animation()
var/step_time = time / HOURGLASS_STATES
animate(src, time = step_time, icon_state = "hourglass_1")
for(var/i in 2 to HOURGLASS_STATES)
animate(time = step_time, icon_state = "hourglass_[i]")
/obj/item/hourglass/proc/stop()
if(timing_id)
deltimer(timing_id)
timing_id = null
countdown.stop()
finish_time = null
animate(src)
update_appearance()
/obj/item/hourglass/proc/finish()
visible_message(span_notice("[src] stops."))
stop()
/obj/item/hourglass/Destroy()
QDEL_NULL(countdown)
. = ..()
//Admin events zone.
/obj/item/hourglass/admin
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
anchored = TRUE
hand_activated = FALSE
/obj/item/hourglass/admin/attack_hand(mob/user, list/modifiers)
. = ..()
if(user.client && user.client.holder)
toggle(user)
/obj/item/hourglass/admin/attack_ghost(mob/user)
if(user.client && user.client.holder)
toggle(user)
#undef HOURGLASS_STATES