type StructureWithPos = { id : string ; pos : RoomPosition ; } ; export class POSCache { constructor ( ) { if ( ! Memory . arcos . posCache ) { Memory . arcos . posCache = { } ; } } param id get ( id ) { if ( Memory . arcos . posCache [ id ] ) { return new RoomPosition ( Memory . arcos . posCache [ id ] . x , Memory . arcos . posCache [ id ] . y , Memory . arcos . posCache [ id ] . roomName ) ; } else { let obj = Game . getObjectById < StructureWithPos > ( id ) ; if ( obj ) { this . set ( obj ) ; return obj . pos ; } else { return false ; } } } param object set ( object ) { let pos = { x : object . pos . x , y : object . pos . y , roomName : object . pos . roomName } ; Memory . arcos . posCache [ object . id ] = pos ; } }