Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/AIInterface.js
Show First 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | for (let valName of msg.valueNames) | ||||
} | } | ||||
if (!ended) | if (!ended) | ||||
continue; | continue; | ||||
// item now contains the template value for this. | // item now contains the template value for this. | ||||
let oldValue = +item == item ? +item : item; | let oldValue = +item == item ? +item : item; | ||||
let newValue = ApplyValueModificationsToTemplate(valName, oldValue, msg.player, template); | let newValue = ApplyValueModificationsToTemplate(valName, oldValue, msg.player, template); | ||||
// Apply the same roundings as in the components | // Apply the same roundings as in the components | ||||
if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | ||||
valName === "Cost/PopulationBonus") | valName === "Population/Bonus") | ||||
newValue = Math.round(newValue); | newValue = Math.round(newValue); | ||||
// TODO in some cases, we can have two opposite changes which bring us to the old value, | // TODO in some cases, we can have two opposite changes which bring us to the old value, | ||||
// and we should keep it. But how to distinguish it ? | // and we should keep it. But how to distinguish it ? | ||||
if(newValue == oldValue) | if(newValue == oldValue) | ||||
continue; | continue; | ||||
if (!this.changedTemplateInfo[msg.player]) | if (!this.changedTemplateInfo[msg.player]) | ||||
this.changedTemplateInfo[msg.player] = {}; | this.changedTemplateInfo[msg.player] = {}; | ||||
if (!this.changedTemplateInfo[msg.player][name]) | if (!this.changedTemplateInfo[msg.player][name]) | ||||
Show All 32 Lines | for (let valName of msg.valueNames) | ||||
} | } | ||||
if (!ended) | if (!ended) | ||||
continue; | continue; | ||||
// "item" now contains the unmodified template value for this. | // "item" now contains the unmodified template value for this. | ||||
let oldValue = +item == item ? +item : item; | let oldValue = +item == item ? +item : item; | ||||
let newValue = ApplyValueModificationsToEntity(valName, oldValue, ent); | let newValue = ApplyValueModificationsToEntity(valName, oldValue, ent); | ||||
// Apply the same roundings as in the components | // Apply the same roundings as in the components | ||||
if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | if (valName === "Player/MaxPopulation" || valName === "Cost/Population" || | ||||
valName === "Cost/PopulationBonus") | valName === "Population/Bonus") | ||||
newValue = Math.round(newValue); | newValue = Math.round(newValue); | ||||
// TODO in some cases, we can have two opposite changes which bring us to the old value, | // TODO in some cases, we can have two opposite changes which bring us to the old value, | ||||
// and we should keep it. But how to distinguish it ? | // and we should keep it. But how to distinguish it ? | ||||
if (newValue == oldValue) | if (newValue == oldValue) | ||||
continue; | continue; | ||||
if (!this.changedEntityTemplateInfo[ent]) | if (!this.changedEntityTemplateInfo[ent]) | ||||
this.changedEntityTemplateInfo[ent] = [{ "variable": valName, "value": newValue }]; | this.changedEntityTemplateInfo[ent] = [{ "variable": valName, "value": newValue }]; | ||||
else | else | ||||
this.changedEntityTemplateInfo[ent].push({ "variable": valName, "value": newValue }); | this.changedEntityTemplateInfo[ent].push({ "variable": valName, "value": newValue }); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
Engine.RegisterSystemComponentType(IID_AIInterface, "AIInterface", AIInterface); | Engine.RegisterSystemComponentType(IID_AIInterface, "AIInterface", AIInterface); |
Wildfire Games · Phabricator