mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-20 19:10:12 +00:00
Add path cache (#763)
Based on #753 Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
This commit is contained in:
co-authored by
Scott Anderson
parent
70745faac4
commit
6517f80f68
@@ -28,6 +28,7 @@ export class UnitImpl implements Unit {
|
||||
private _detonationDst: TileRef | undefined = undefined; // Only for nukes
|
||||
private _warshipTarget: Unit | undefined = undefined;
|
||||
private _cooldownDuration: number | undefined = undefined;
|
||||
private _pathCache: Map<TileRef, TileRef> = new Map();
|
||||
|
||||
constructor(
|
||||
private _type: UnitType,
|
||||
@@ -53,6 +54,13 @@ export class UnitImpl implements Unit {
|
||||
: 0;
|
||||
}
|
||||
|
||||
cachePut(from: TileRef, to: TileRef): void {
|
||||
this._pathCache.set(from, to);
|
||||
}
|
||||
cacheGet(from: TileRef): TileRef | undefined {
|
||||
return this._pathCache.get(from);
|
||||
}
|
||||
|
||||
id() {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user