Create an interface that requests a .Get() method for all implementations. This method accepts arguments for flags, uses those flags to route to the correct method
Each class contains methods that implement the flags passed in above, required per above interface
each method above is cached individually in a per class, per room cache --- Should be able to expire different flags at different times
Caching of Cost Matrices should be done by introducing a variable at the top of each class file:
export class CostMatrixExample{
public static cache: CostMatrixCache = {};
}
The expire time on a CostMatrixCache will signify the maximum Game.time that a matrix can be used. Once the Game.time is greater than the expireTime, the matrix is invalid and should be regenerated.
export class CostMatrixExample{
Get(params): CostMatrix {
if(params.ignoreCreep) { // for the sake of example, the only options are ignoreCreep and ignoreStructure
return this.ExampleMatrix_ignoreCreep(params.roomName);
}
}
ExampleMatrix_ignoreCreep(roomName: string): CostMatrix {
if(cache[roomName] !== undefined &&
cache[roomName].ignoreCreep !== undefined &&
cache[roomname].ignoreCreep.expireTime >= Game.time()) {
return cache[roomName].ignoreCreep.cm;
}
// else generate the matrix and store it into the cache structure,
// setting the expireTime = Game.time() + #ticks to cache the matrix
return matrix;
}
}
PARENT TICKET, Closed once all child tickets are closed
Caching of Cost Matrices should be done by introducing a variable at the top of each class file:
The expire time on a CostMatrixCache will signify the maximum Game.time that a matrix can be used. Once the Game.time is greater than the expireTime, the matrix is invalid and should be regenerated.
PARENT TICKET, Closed once all child tickets are closed