mirror of
https://github.com/sortedcord/omnia.git
synced 2026-07-22 12:02:49 +05:30
feat: Implement primitive WorldClock
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@langchain/google-genai": "^2.2.0",
|
||||
"@types/node": "^26.1.0",
|
||||
"better-sqlite3": "^12.11.1"
|
||||
}
|
||||
}
|
||||
|
||||
19
packages/core/src/clock.ts
Normal file
19
packages/core/src/clock.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export class WorldClock {
|
||||
private currentTime: Date;
|
||||
|
||||
constructor(startTime: Date = new Date(1999, 4, 14, 18, 0)) {
|
||||
this.currentTime = startTime;
|
||||
}
|
||||
|
||||
advance(minutes: number): void {
|
||||
this.currentTime = new Date(this.currentTime.getTime() + minutes * 60_000);
|
||||
}
|
||||
|
||||
get(): Date {
|
||||
return this.currentTime;
|
||||
}
|
||||
|
||||
static fromISOString(iso: string): WorldClock {
|
||||
return new WorldClock(new Date(iso));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { AttributableObject } from "./attribute.js";
|
||||
import { Entity } from "./entity.js";
|
||||
import { WorldClock } from "./clock.js";
|
||||
|
||||
export class WorldState extends AttributableObject {
|
||||
/**
|
||||
@@ -7,9 +8,11 @@ export class WorldState extends AttributableObject {
|
||||
* Universe's current state (distinct from how it started)
|
||||
*/
|
||||
readonly entities: Map<string, Entity> = new Map();
|
||||
readonly clock: WorldClock;
|
||||
|
||||
constructor(id?: string) {
|
||||
constructor(id?: string, startTime?: Date) {
|
||||
super(id);
|
||||
this.clock = new WorldClock(startTime);
|
||||
}
|
||||
|
||||
addEntity(entity: Entity): void {
|
||||
|
||||
Reference in New Issue
Block a user