Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/buildManager.js
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | for (let evt of events.OwnershipChanged) // capture events | ||||
else if (evt.to == PlayerID) | else if (evt.to == PlayerID) | ||||
increment = 1; | increment = 1; | ||||
else | else | ||||
continue; | continue; | ||||
let ent = gameState.getEntityById(evt.entity); | let ent = gameState.getEntityById(evt.entity); | ||||
if (ent && ent.hasClass("Unit")) | if (ent && ent.hasClass("Unit")) | ||||
this.incrementBuilderCounters(civ, ent, increment); | this.incrementBuilderCounters(civ, ent, increment); | ||||
} | } | ||||
for (let evt of events.ValueModification) | |||||
{ | |||||
if (evt.component != "Builder" || | |||||
!evt.valueNames.some(val => val.startsWith("Builder/Entities/"))) | |||||
continue; | |||||
// Unfortunately there really is not an easy way to determine the changes | |||||
// at this stage, so we simply have to dump the cache. | |||||
this.builderCounters = new Map(); | |||||
let civ = gameState.getPlayerCiv(); | |||||
for (let ent of gameState.getOwnUnits().values()) | |||||
this.incrementBuilderCounters(civ, ent, 1); | |||||
} | |||||
}; | }; | ||||
/** | /** | ||||
* Get the first buildable structure with a given class | * Get the first buildable structure with a given class | ||||
* TODO when several available, choose the best one | * TODO when several available, choose the best one | ||||
*/ | */ | ||||
PETRA.BuildManager.prototype.findStructureWithClass = function(gameState, classes) | PETRA.BuildManager.prototype.findStructureWithClass = function(gameState, classes) | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator