mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
* Partial port of @PsiOmegaDelta's https://github.com/Baystation12/Baystation12/pull/16820 * Only ports the StonedMC changes, not the garbage collector (forthcoming in future)
39 lines
934 B
Plaintext
39 lines
934 B
Plaintext
var/global/datum/controller/process/ticker/tickerProcess
|
|
|
|
/datum/controller/process/ticker
|
|
var/lastTickerTimeDuration
|
|
var/lastTickerTime
|
|
|
|
/datum/controller/process/ticker/setup()
|
|
name = "ticker"
|
|
schedule_interval = 20 // every 2 seconds
|
|
|
|
lastTickerTime = world.timeofday
|
|
|
|
if(!ticker)
|
|
ticker = new
|
|
|
|
tickerProcess = src
|
|
|
|
spawn(0)
|
|
if(ticker)
|
|
ticker.pregame()
|
|
|
|
/datum/controller/process/ticker/doWork()
|
|
var/currentTime = world.timeofday
|
|
|
|
if(currentTime < lastTickerTime) // check for midnight rollover
|
|
lastTickerTimeDuration = (currentTime - (lastTickerTime - TICKS_IN_DAY)) / TICKS_IN_SECOND
|
|
else
|
|
lastTickerTimeDuration = (currentTime - lastTickerTime) / TICKS_IN_SECOND
|
|
|
|
lastTickerTime = currentTime
|
|
|
|
ticker.process()
|
|
|
|
/datum/controller/process/ticker/proc/getLastTickerTimeDuration()
|
|
return lastTickerTimeDuration
|
|
|
|
/world/proc/has_round_started()
|
|
return (ticker && ticker.current_state >= GAME_STATE_PLAYING)
|