Add Logistics and Extension support

This commit is contained in:
uwap 2022-12-23 09:06:15 +01:00
parent 18ff62a97b
commit f7f39bc90a
3 changed files with 4 additions and 4 deletions

View file

@ -6,7 +6,7 @@ import { withdrawEnergy } from "../Actions/withdrawEnergy";
import { WorkerDefinition } from "./worker";
export const Constructor: WorkerDefinition = {
runAction: (creep: Creep) => runAction(creep, withdrawEnergy(<StructureContainer | null> creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_CONTAINER }})))
runAction: (creep: Creep) => runAction(creep, withdrawEnergy(creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_CONTAINER }}) as StructureContainer | null))
.or(harvestFromClosestActiveSource())
.andThen(buildConstructionSite())
.or(creep.room.controller ? upgradeController(creep.room.controller) : Fail)

View file

@ -5,7 +5,7 @@ import { WorkerDefinition } from "./worker";
export const Miner: WorkerDefinition = {
runAction: (creep: Creep) => runAction(creep, harvestFromClosestActiveSource())
.andThen(transferEnergy(<StructureContainer | null> creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_CONTAINER }})))
.andThen(transferEnergy(creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_CONTAINER }}) as StructureContainer | null))
.repeat(),
name: 'miner',
requiredCreeps: (room: Room) => room.find(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_CONTAINER }}).length > 0 ? 4 : 0,

View file

@ -6,10 +6,10 @@ import { withdrawEnergy } from "../Actions/withdrawEnergy";
import { WorkerDefinition } from "./worker";
export const Upgrader: WorkerDefinition = {
runAction: (creep: Creep, spawn: StructureSpawn) => runAction(creep, withdrawEnergy(<StructureContainer | null> creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_CONTAINER }})))
runAction: (creep: Creep, spawn: StructureSpawn) => runAction(creep, withdrawEnergy(creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_CONTAINER }}) as StructureContainer | null))
.or(harvestFromClosestActiveSource())
.andThen(transferEnergy(spawn))
.or(transferEnergy(<StructureExtension | null> creep.pos.findClosestByRange(FIND_MY_STRUCTURES, { filter: (structure: StructureExtension) => structure.structureType === STRUCTURE_EXTENSION && structure.store.getFreeCapacity(RESOURCE_ENERGY) > 0})))
.or(transferEnergy(creep.pos.findClosestByRange(FIND_MY_STRUCTURES, { filter: (structure: AnyOwnedStructure) => structure.structureType === STRUCTURE_EXTENSION && structure.store.getFreeCapacity(RESOURCE_ENERGY) > 0}) as StructureExtension | null))
.or(creep.room.controller ? upgradeController(creep.room.controller) : Fail)
.repeat(),
name: 'upgrader',