Refactoring
This commit is contained in:
parent
cb840bc312
commit
92b5249df4
@ -1,8 +1,8 @@
|
|||||||
/** @param {Creep} creep **/
|
|
||||||
export function runAsHarvester(creep: Creep) {
|
export function runAsHarvester(creep: Creep) {
|
||||||
if (creep.store.getFreeCapacity() > 0) {
|
if (creep.store.getFreeCapacity() > 0) {
|
||||||
let sources = creep.room.find(FIND_SOURCES);
|
let sources = creep.room.find(FIND_SOURCES);
|
||||||
if (creep.harvest(sources[0]) === ERR_NOT_IN_RANGE) {
|
if (creep.harvest(sources[0]) === ERR_NOT_IN_RANGE) {
|
||||||
|
creep.say('to source');
|
||||||
creep.moveTo(sources[0], { visualizePathStyle: { stroke: '#ffaa00' } });
|
creep.moveTo(sources[0], { visualizePathStyle: { stroke: '#ffaa00' } });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -19,6 +19,7 @@ export function runAsHarvester(creep: Creep) {
|
|||||||
|
|
||||||
if (targets.length > 0) {
|
if (targets.length > 0) {
|
||||||
if (creep.transfer(targets[0], RESOURCE_ENERGY) === ERR_NOT_IN_RANGE) {
|
if (creep.transfer(targets[0], RESOURCE_ENERGY) === ERR_NOT_IN_RANGE) {
|
||||||
|
creep.say('to target');
|
||||||
creep.moveTo(targets[0], { visualizePathStyle: { stroke: '#ffffff' } });
|
creep.moveTo(targets[0], { visualizePathStyle: { stroke: '#ffffff' } });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -31,7 +32,6 @@ export function runAsHarvester(creep: Creep) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {Creep} creep **/
|
|
||||||
export function runAsBuilder(creep: Creep) {
|
export function runAsBuilder(creep: Creep) {
|
||||||
const memory = creep.memory as CreepMemory & { building: boolean | undefined };
|
const memory = creep.memory as CreepMemory & { building: boolean | undefined };
|
||||||
|
|
||||||
@ -66,7 +66,6 @@ export function runAsBuilder(creep: Creep) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {Creep} creep **/
|
|
||||||
export function runAsUpgrader(creep: Creep) {
|
export function runAsUpgrader(creep: Creep) {
|
||||||
const memory = creep.memory as CreepMemory & { upgrading: boolean | undefined };
|
const memory = creep.memory as CreepMemory & { upgrading: boolean | undefined };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user