initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { makeGame, ResourceGenerator, ResourceSet } from "@idle-economy/engine";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
|
||||
export class Root {
|
||||
|
||||
private readonly game = makeGame();
|
||||
|
||||
public resources: ResourceSet = new ResourceSet();
|
||||
public generators: ResourceGenerator[] = [];
|
||||
|
||||
constructor() {
|
||||
this.copyGame();
|
||||
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
public tick(deltaTime: number): void {
|
||||
Array.from(this.game.tick(deltaTime));
|
||||
this.copyGame();
|
||||
}
|
||||
|
||||
private copyGame(): void {
|
||||
this.resources = this.game.resources;
|
||||
this.generators = this.game.generators;
|
||||
}
|
||||
}
|
||||
|
||||
export const root = new Root();
|
||||
Reference in New Issue
Block a user