Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Population.js
Show All 40 Lines | if (msg.to != INVALID_PLAYER) | ||||
let cmpPlayer = QueryPlayerIDInterface(msg.to); | let cmpPlayer = QueryPlayerIDInterface(msg.to); | ||||
if (cmpPlayer) | if (cmpPlayer) | ||||
cmpPlayer.AddPopulationBonuses(this.bonus); | cmpPlayer.AddPopulationBonuses(this.bonus); | ||||
} | } | ||||
}; | }; | ||||
Population.prototype.OnValueModification = function(msg) | Population.prototype.OnValueModification = function(msg) | ||||
{ | { | ||||
if (msg.component != "Population") | |||||
return; | |||||
// Foundations shouldn't give a pop bonus. | // Foundations shouldn't give a pop bonus. | ||||
if (Engine.QueryInterface(this.entity, IID_Foundation)) | if (Engine.QueryInterface(this.entity, IID_Foundation)) | ||||
return; | return; | ||||
let oldPopBonus = this.bonus; | let oldPopBonus = this.bonus; | ||||
this.RecalculateValues(); | this.RecalculateValues(); | ||||
let popDifference = this.bonus - oldPopBonus; | let popDifference = this.bonus - oldPopBonus; | ||||
if (!popDifference) | if (!popDifference) | ||||
return; | return; | ||||
let cmpPlayer = QueryOwnerInterface(this.entity); | let cmpPlayer = QueryOwnerInterface(this.entity); | ||||
if (cmpPlayer) | if (cmpPlayer) | ||||
cmpPlayer.AddPopulationBonuses(popDifference); | cmpPlayer.AddPopulationBonuses(popDifference); | ||||
}; | }; | ||||
Engine.RegisterComponentType(IID_Population, "Population", Population); | Engine.RegisterComponentType(IID_Population, "Population", Population); |
Wildfire Games · Phabricator