feat: LazyEntityUpdater

This commit is contained in:
2024-03-09 04:50:55 +00:00
parent a38f72fa46
commit fa29486af6
8 changed files with 126 additions and 42 deletions
@@ -6,6 +6,19 @@ import type { GameEnv } from "./GameEnv.js";
import type { IGeneralEntity } from "./GeneralEntity.js";
import type { Troop } from "./Troop.js";
import type { ITroopEntity } from "./TroopEntity.js";
import type { LazyEntityUpdater } from "./LazyEntityUpdater.js";
import type { ICityEntity } from "./CityEntity.js";
import type { INationEntity } from "./NationEntity.js";
export type ValidEntityList = {
'General': IGeneralEntity;
'City': ICityEntity;
'Nation': INationEntity;
'Troop': ITroopEntity;
};
export type ValidEntity = ValidEntityList[keyof ValidEntityList];
export type ValidEntityType<Entity> = Entity extends ValidEntityList[infer T extends keyof ValidEntityList] ? T : never;
export interface IResourceController{
addCity(city: City): boolean;
@@ -38,6 +51,8 @@ export interface IResourceController{
setDirtyTroop(troop: Troop | TroopID): void;
setDirtyNation(nation: Nation): void;
setDirty(entity: LazyEntityUpdater<any>): void;
createGeneral(raw: IGeneralEntity): General;
createTroop(raw: ITroopEntity): Troop;
//createNation