Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/mapModule.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
/** map functions */ | /** map functions */ | ||||
m.TERRITORY_PLAYER_MASK = 0x1F; | m.TERRITORY_PLAYER_MASK = 0x1F; | ||||
m.TERRITORY_BLINKING_MASK = 0x40; | m.TERRITORY_BLINKING_MASK = 0x40; | ||||
m.createObstructionMap = function(gameState, accessIndex, template) | m.createObstructionMap = function(gameState, accessIndex, template) | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | for (let j = 0; j < map.length; ++j) | ||||
continue; | continue; | ||||
map.map[j] = m.border_Mask; | map.map[j] = m.border_Mask; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// map.dumpIm("border.png", 5); | // map.dumpIm("border.png", 5); | ||||
return map; | return map; | ||||
}; | }; | ||||
m.debugMap = function(gameState, map) | m.debugMap = function(gameState, map) | ||||
{ | { | ||||
let width = map.width; | let width = map.width; | ||||
let cell = map.cellSize; | let cell = map.cellSize; | ||||
gameState.getEntities().forEach(ent => { | gameState.getEntities().forEach(ent => { | ||||
let pos = ent.position(); | let pos = ent.position(); | ||||
if (!pos) | if (!pos) | ||||
return; | return; | ||||
let x = Math.round(pos[0] / cell); | let x = Math.round(pos[0] / cell); | ||||
let z = Math.round(pos[1] / cell); | let z = Math.round(pos[1] / cell); | ||||
let id = x + width*z; | let id = x + width*z; | ||||
if (map.map[id] == 1) | if (map.map[id] == 1) | ||||
Engine.PostCommand(PlayerID, { "type": "set-shading-color", "entities": [ent.id()], "rgb": [2, 0, 0] }); | Engine.PostCommand(PlayerID, { "type": "set-shading-color", "entities": [ent.id()], "rgb": [2, 0, 0] }); | ||||
else if (map.map[id] == 2) | else if (map.map[id] == 2) | ||||
Engine.PostCommand(PlayerID, { "type": "set-shading-color", "entities": [ent.id()], "rgb": [0, 2, 0] }); | Engine.PostCommand(PlayerID, { "type": "set-shading-color", "entities": [ent.id()], "rgb": [0, 2, 0] }); | ||||
else if (map.map[id] == 3) | else if (map.map[id] == 3) | ||||
Engine.PostCommand(PlayerID, { "type": "set-shading-color", "entities": [ent.id()], "rgb": [0, 0, 2] }); | Engine.PostCommand(PlayerID, { "type": "set-shading-color", "entities": [ent.id()], "rgb": [0, 0, 2] }); | ||||
}); | }); | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator