feat: add getCycleTicks() and getDayNumber() to GameLoop
This commit is contained in:
@@ -339,10 +339,18 @@ export class GameLoop {
|
||||
return this.tick;
|
||||
}
|
||||
|
||||
getGameTime(): number {
|
||||
private getCycleTicks(): number {
|
||||
const dayTicks = 100 / this.runtimeConstants.get('ENERGY_DECAY_PER_TICK');
|
||||
const nightTicks = dayTicks / this.runtimeConstants.get('DAY_NIGHT_RATIO');
|
||||
const cycleTicks = Math.round(dayTicks + nightTicks);
|
||||
return Math.round(dayTicks + nightTicks);
|
||||
}
|
||||
|
||||
getGameTime(): number {
|
||||
const cycleTicks = this.getCycleTicks();
|
||||
return (this.tick % cycleTicks) / cycleTicks;
|
||||
}
|
||||
|
||||
getDayNumber(): number {
|
||||
return Math.floor(this.tick / this.getCycleTicks()) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user