Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Screeps - determine if the structures and terrain in a square prevent a creep entering.
isEnterable: function (pos) {
var atPos = pos.look();
var SWAMP = "swamp";
var PLAIN = "plain";
for ( var i = 0 ; i < atPos.length ; i++ )
{
switch (atPos[i].type) {
case LOOK_TERRAIN:
if (atPos[i].terrain != PLAIN && atPos[i].terrain != SWAMP)
return false;
break;
case LOOK_STRUCTURES:
if (OBSTACLE_OBJECT_TYPES.includes(atPos[i].structure.structureType))
return false;
break;
case LOOK_CREEPS:
case LOOK_SOURCES:
case LOOK_MINERALS:
case LOOK_NUKES:
case LOOK_ENERGY:
case LOOK_RESOURCES:
case LOOK_FLAGS:
case LOOK_CONSTRUCTION_SITES:
default:
}
}
return true;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.