2024-11-03 23:20:58 +08:00
|
|
|
export function FindCapacity(creep: Creep): AnyStructure[] {
|
2024-11-03 22:04:05 +08:00
|
|
|
return creep.room.find(FIND_STRUCTURES, {
|
|
|
|
filter: (structure: StructureSpawn | StructureExtension) => {
|
|
|
|
let type = structure.structureType;
|
|
|
|
return (
|
|
|
|
(type == STRUCTURE_EXTENSION ||
|
2024-11-04 00:02:42 +08:00
|
|
|
type == STRUCTURE_SPAWN||
|
|
|
|
type == STRUCTURE_CONTAINER) &&
|
2024-11-03 23:20:58 +08:00
|
|
|
structure.store.getFreeCapacity(RESOURCE_ENERGY) as number > 0
|
2024-11-03 22:04:05 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
2024-11-03 23:20:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function GetSource(sourceId: Id<Source> | null): Source {
|
|
|
|
return Game.getObjectById(sourceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function GetConstructureSet(creep: Creep, structureType: string | null = null): ConstructionSite<BuildableStructureConstant>[] {
|
|
|
|
return creep.room.find(FIND_CONSTRUCTION_SITES, {
|
|
|
|
filter: (structure: Structure) => {
|
|
|
|
if (structureType == null) return true;
|
|
|
|
return structure.structureType == structureType;
|
|
|
|
}
|
|
|
|
})
|
2024-11-04 00:02:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function GetConstructure(creep: Creep, structureType: string, ){
|
|
|
|
return creep.room.find(FIND_STRUCTURES, {filter:(structure: AnyStructure)=>{
|
|
|
|
return structure.structureType == structureType;
|
|
|
|
}})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function GetContainer(creep: Creep): StructureContainer[]{
|
|
|
|
let target = GetConstructure(creep, STRUCTURE_CONTAINER) as StructureContainer[];
|
|
|
|
return target
|
2024-11-03 22:04:05 +08:00
|
|
|
}
|