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
+7 -7
View File
@@ -3,20 +3,20 @@ import type { General } from "./General.js";
import type { IResourceController } from "./ResourceController.js";
import type { ITroopEntity } from "./TroopEntity.js";
import type { GeneralID } from "./defs.js";
import { LazyEntityUpdater } from "./LazyEntityUpdater.js";
export class Troop {
private _raw: ITroopEntity
export class Troop extends LazyEntityUpdater<ITroopEntity> {
protected readonly _indirectNames: (keyof ITroopEntity)[] = ["id"];
protected readonly _entityType = "Troop";
protected readonly _raw: ITroopEntity;
private _leader: WeakRef<General>;
private _members: Map<GeneralID, WeakRef<General>>;
public get raw(): Readonly<ITroopEntity> {
return this._raw;
}
constructor(
raw: ITroopEntity,
private resourceController: IResourceController
protected resourceController: IResourceController
){
super();
this._raw = raw;
const members = resourceController.findGeneralByTroop(raw.id);