Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/baseManager.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
/** | /** | ||||
* Base Manager | * Base Manager | ||||
* Handles lower level economic stuffs. | * Handles lower level economic stuffs. | ||||
* Some tasks: | * Some tasks: | ||||
* -tasking workers: gathering/hunting/building/repairing?/scouting/plans. | * -tasking workers: gathering/hunting/building/repairing?/scouting/plans. | ||||
* -giving feedback/estimates on GR | * -giving feedback/estimates on GR | ||||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | resources.forEach(function(supply) | ||||
faraway.push({ "dropsite": dropsiteId, "id": supply.id(), "ent": supply, "dist": dist }); | faraway.push({ "dropsite": dropsiteId, "id": supply.id(), "ent": supply, "dist": dist }); | ||||
} | } | ||||
}); | }); | ||||
nearby.sort((r1, r2) => r1.dist - r2.dist); | nearby.sort((r1, r2) => r1.dist - r2.dist); | ||||
medium.sort((r1, r2) => r1.dist - r2.dist); | medium.sort((r1, r2) => r1.dist - r2.dist); | ||||
faraway.sort((r1, r2) => r1.dist - r2.dist); | faraway.sort((r1, r2) => r1.dist - r2.dist); | ||||
/* let debug = false; | /* | ||||
let debug = false; | |||||
if (debug) | if (debug) | ||||
{ | { | ||||
faraway.forEach(function(res){ | faraway.forEach(function(res){ | ||||
Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [res.ent.id()], "rgb": [2,0,0]}); | Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [res.ent.id()], "rgb": [2,0,0]}); | ||||
}); | }); | ||||
medium.forEach(function(res){ | medium.forEach(function(res){ | ||||
Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [res.ent.id()], "rgb": [0,2,0]}); | Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [res.ent.id()], "rgb": [0,2,0]}); | ||||
}); | }); | ||||
nearby.forEach(function(res){ | nearby.forEach(function(res){ | ||||
Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [res.ent.id()], "rgb": [0,0,2]}); | Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [res.ent.id()], "rgb": [0,0,2]}); | ||||
}); | }); | ||||
} */ | } | ||||
*/ | |||||
} | } | ||||
// Allows all allies to use this dropsite except if base anchor to be sure to keep | // Allows all allies to use this dropsite except if base anchor to be sure to keep | ||||
// a minimum of resources for this base | // a minimum of resources for this base | ||||
Engine.PostCommand(PlayerID, { | Engine.PostCommand(PlayerID, { | ||||
"type": "set-dropsite-sharing", | "type": "set-dropsite-sharing", | ||||
"entities": [dropsiteId], | "entities": [dropsiteId], | ||||
"shared": dropsiteId != this.anchorId | "shared": dropsiteId != this.anchorId | ||||
▲ Show 20 Lines • Show All 882 Lines • ▼ Show 20 Lines | |||||
m.BaseManager.prototype.Deserialize = function(gameState, data) | m.BaseManager.prototype.Deserialize = function(gameState, data) | ||||
{ | { | ||||
for (let key in data) | for (let key in data) | ||||
this[key] = data[key]; | this[key] = data[key]; | ||||
this.anchor = this.anchorId !== undefined ? gameState.getEntityById(this.anchorId) : undefined; | this.anchor = this.anchorId !== undefined ? gameState.getEntityById(this.anchorId) : undefined; | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator