-
-
Save Dessix/260308e3f0a5d9cb8ec4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Creep.prototype.findNearestStorage: function() { | |
var pref = undefined; | |
if (this.room.storage != undefined) { | |
pref = this.room.storage; | |
} | |
for (var link in this.room.memory.energy.linkSources) { | |
var l = Game.getObjectById(link); | |
if (l != null && this.pos.getRangeTo(pref) > this.pos.getRangeTo(l)) { | |
pref = l; | |
} | |
} | |
if (pref == undefined || pref == null) { | |
return this.findClosestByRange(this.room.memory.structs.spawns, true); | |
} else { | |
return pref.id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment