watch 01:36
We're Getting Mutants in the MCU - The Loop
Do you like this video?
Play Sound
function (target) {
if (!this.my) {
return C.ERR_NOT_OWNER;
}
if (data(this.id).spawning) {
return C.ERR_BUSY;
}
if (this.getActiveBodyparts(C.WORK) == 0) {
return C.ERR_NO_BODYPART;
}
if (!this.energy) {
return C.ERR_NOT_ENOUGH_ENERGY;
}
if (!target || !target.id || !register.constructionSites[target.id] || !(target instanceof globals.ConstructionSite)) {
return C.ERR_INVALID_TARGET;
}
if (!target.pos.isNearTo(this.pos)) {
return C.ERR_NOT_IN_RANGE;
}
if (_.contains(['spawn', 'extension', 'constructedWall'], target.structureType) && _.any(register.objectsByRoom[data(this.id).room], (function(i) {
return i.x == target.pos.x && i.y == target.pos.y && _.contains(C.OBSTACLE_OBJECT_TYPES, i.type);
}))) {
return C.ERR_INVALID_TARGET;
}
var buildPower = this.getActiveBodyparts(C.WORK) * C.BUILD_POWER,
buildRemaining = target.progressTotal - target.progress,
buildEffect = Math.min(buildPower, buildRemaining, this.energy);
if (target.progress + buildEffect >= target.progressTotal && target.room.mode == C.MODE_WORLD && !utils.checkControllerAvailability(target.structureType, register.objectsByRoom[data(this.id).room], this.room.controller)) {
return C.ERR_RCL_NOT_ENOUGH;
}
intents[this.id] = intents[this.id] || {};
intents[this.id].build = {
id: target.id,
x: target.pos.x,
y: target.pos.y
};
return C.OK;
}