From e0824114db475bc8a2d9bd12e8f7178a7553ba2b Mon Sep 17 00:00:00 2001 From: AnturK Date: Mon, 10 Jun 2019 00:31:24 +0200 Subject: [PATCH] Adds hourglass (#44384) * Adds hourglass * Proper icon and animation. * Makes throwing not break animate. * Adds hourglass to library game vendor. --- code/__HELPERS/matrices.dm | 2 +- code/game/objects/effects/countdown.dm | 20 ++++-- code/game/objects/items/hourglass.dm | 82 +++++++++++++++++++++++++ code/modules/vending/games.dm | 3 +- icons/obj/hourglass.dmi | Bin 0 -> 1434 bytes tgstation.dme | 1 + 6 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 code/game/objects/items/hourglass.dm create mode 100644 icons/obj/hourglass.dmi diff --git a/code/__HELPERS/matrices.dm b/code/__HELPERS/matrices.dm index 44c5315dbf4..9f07ed53117 100644 --- a/code/__HELPERS/matrices.dm +++ b/code/__HELPERS/matrices.dm @@ -18,7 +18,7 @@ speed /= segments - animate(src, transform = matrices[1], time = speed, loops) + animate(src, transform = matrices[1], time = speed, loops , flags = ANIMATION_PARALLEL) for(var/i in 2 to segments) //2 because 1 is covered above animate(transform = matrices[i], time = speed) //doesn't have an object argument because this is "Stacking" with the animate call above diff --git a/code/game/objects/effects/countdown.dm b/code/game/objects/effects/countdown.dm index eea6b6ba39f..db5414e33d3 100644 --- a/code/game/objects/effects/countdown.dm +++ b/code/game/objects/effects/countdown.dm @@ -63,6 +63,12 @@ /obj/effect/countdown/ex_act(severity, target) //immune to explosions return +/obj/effect/countdown/singularity_pull() + return + +/obj/effect/countdown/singularity_act() + return + /obj/effect/countdown/syndicatebomb name = "syndicate bomb countdown" @@ -154,8 +160,14 @@ var/time_left = max(0, (A.death_time - world.time) / 10) return round(time_left) -/obj/effect/countdown/singularity_pull() - return +/obj/effect/countdown/hourglass + name = "hourglass countdown" + +/obj/effect/countdown/hourglass/get_value() + var/obj/item/hourglass/H = attached_to + if(!istype(H)) + return + else + var/time_left = max(0, (H.finish_time - world.time) / 10) + return round(time_left) -/obj/effect/countdown/singularity_act() - return diff --git a/code/game/objects/items/hourglass.dm b/code/game/objects/items/hourglass.dm new file mode 100644 index 00000000000..2c5c69eb170 --- /dev/null +++ b/code/game/objects/items/hourglass.dm @@ -0,0 +1,82 @@ +#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/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,"You flip the [src]") + start() + flick("hourglass_flip",src) + else + to_chat(user,"You stop the [src].") //Sand magically flows back because that's more convinient to use. + stop() + +/obj/item/hourglass/update_icon() + if(timing_id) + icon_state = "hourglass_active" + else + icon_state = "hourglass_idle" + +/obj/item/hourglass/proc/start() + finish_time = world.time + time + timing_id = addtimer(CALLBACK(src, .proc/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_icon() + +/obj/item/hourglass/proc/finish() + visible_message("[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) + . = ..() + 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 \ No newline at end of file diff --git a/code/modules/vending/games.dm b/code/modules/vending/games.dm index f4f1b419f91..1f5eca4cb88 100644 --- a/code/modules/vending/games.dm +++ b/code/modules/vending/games.dm @@ -6,7 +6,8 @@ products = list(/obj/item/toy/cards/deck = 5, /obj/item/storage/pill_bottle/dice = 10, /obj/item/toy/cards/deck/cas = 3, - /obj/item/toy/cards/deck/cas/black = 3) + /obj/item/toy/cards/deck/cas/black = 3, + /obj/item/hourglass = 2) contraband = list(/obj/item/dice/fudge = 9) refill_canister = /obj/item/vending_refill/games default_price = 10 diff --git a/icons/obj/hourglass.dmi b/icons/obj/hourglass.dmi new file mode 100644 index 0000000000000000000000000000000000000000..537079f14090c5aa22c1ac1bc22b0a093c1c5b51 GIT binary patch literal 1434 zcmV;L1!ek)P)P(LU#|NsBkc0}Z(fJ5AXm;e9(0d!JMQvg8b*k%9#0JVBlSad{Xb7OL8aCB*J zZU6vyoKseCa&`CgQ*iP1dVM2ltCX^dtO1Tkcln19d ziAE?Zxca$(lQ01N$ix0R(;x`|00eSLL_t(|ob6jncB3#56hE&6cJ?OD?1Q-g&V#Hy z?^!pP`=4Q?BnGKlmeM0&GM=u5{mQ6Ss0ES=VIda7!;E#MhnG;1wweU1ZL84KU#=eo zB=w>7O14c^O)RPFvaG7FHyH;U>vDTra@&@>{$TuY%=^AO+$!z>3OM%tsj5DjoJ=S7 z@m1D!-(Rfaoe&p~AWESQ$c=zZH8y|!Jf4m%zh*Igmhzk!31~!L$n9+bltLAt5@ibJ zop}AMF*&q4yQ+q31=){Y7M9?-lcpdNfGKQ5XAACh)Mt%ZrJ~!WET66=vd2M+lPNez zc`@RV08C+{xf$?a3hukStM|PaYsemTN{!-J5DI`4Lcv63bmZA?5P6yl(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