refactor: fit world time state into ushort

This commit is contained in:
cha0s 2019-04-20 01:55:47 -05:00
parent 9513ac6e1a
commit 49ed30ab60

View File

@ -1,5 +1,7 @@
import {Ticker} from '@avocado/timing';
const MAGIC_TO_FIT_HOUR_INTO_USHORT = 2730;
export class WorldTime {
constructor() {
@ -7,7 +9,7 @@ export class WorldTime {
this.ticker = new Ticker(1);
this._state = 0;
this.ticker.on('tick', () => {
this._state = this._hour;
this._state = (this._hour * MAGIC_TO_FIT_HOUR_INTO_USHORT) >> 0;
});
}
@ -36,7 +38,7 @@ export class WorldTime {
for (const step of steps) {
const {path, value} = step;
if ('/' === path) {
this._hour = value;
this._hour = value / MAGIC_TO_FIT_HOUR_INTO_USHORT;
}
}
}