Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ResourceSupply.js
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | ResourceSupply.prototype.Change = function(change) | ||||
// Remove entities that have been exhausted. | // Remove entities that have been exhausted. | ||||
if (this.amount == 0) | if (this.amount == 0) | ||||
Engine.DestroyEntity(this.entity); | Engine.DestroyEntity(this.entity); | ||||
let actualChange = this.amount - oldAmount; | let actualChange = this.amount - oldAmount; | ||||
if (actualChange != 0) | if (actualChange != 0) | ||||
{ | { | ||||
Engine.PostMessage(this.entity, MT_ResourceSupplyChanged, { | Engine.PostMessage(this.entity, MT_ResourceSupplyChanged, { | ||||
"from": oldAmount, | "from": oldAmount, | ||||
"to": this.amount | "to": this.amount | ||||
}); | }); | ||||
wraitii: Note that this message & the one above could still be interesting to have (need to check if… | |||||
Not Done Inline ActionsStatusBars use it. Freagarach: StatusBars use it. | |||||
this.CheckTimers(); | this.CheckTimers(); | ||||
} | } | ||||
return actualChange; | return actualChange; | ||||
}; | }; | ||||
/** | /** | ||||
* @param {number} newValue - The value to set the current amount to. | * @param {number} newValue - The value to set the current amount to. | ||||
*/ | */ | ||||
Show All 11 Lines | |||||
{ | { | ||||
if (!this.IsAvailable()) | if (!this.IsAvailable()) | ||||
return false; | return false; | ||||
if (this.IsGatheringUs(gathererID)) | if (this.IsGatheringUs(gathererID)) | ||||
return true; | return true; | ||||
this.gatherers.push(gathererID); | this.gatherers.push(gathererID); | ||||
Engine.PostMessage(this.entity, MT_ResourceSupplyNumGatherersChanged, { "to": this.GetNumGatherers() }); | |||||
return true; | return true; | ||||
}; | }; | ||||
/** | /** | ||||
* @param {number} player - The playerID owning the gatherer. | * @param {number} player - The playerID owning the gatherer. | ||||
* @param {number} entity - The entityID gathering. | * @param {number} entity - The entityID gathering. | ||||
* | * | ||||
Show All 16 Lines | |||||
/** | /** | ||||
* @param {number} gathererID - The gatherer's entity id. | * @param {number} gathererID - The gatherer's entity id. | ||||
* @todo: Should this return false if the gatherer didn't gather from said resource? | * @todo: Should this return false if the gatherer didn't gather from said resource? | ||||
*/ | */ | ||||
ResourceSupply.prototype.RemoveGatherer = function(gathererID) | ResourceSupply.prototype.RemoveGatherer = function(gathererID) | ||||
{ | { | ||||
let index = this.gatherers.indexOf(gathererID); | let index = this.gatherers.indexOf(gathererID); | ||||
if (index != -1) | if (index != -1) | ||||
{ | |||||
this.gatherers.splice(index, 1); | this.gatherers.splice(index, 1); | ||||
Engine.PostMessage(this.entity, MT_ResourceSupplyNumGatherersChanged, { "to": this.GetNumGatherers() }); | |||||
} | |||||
index = this.activeGatherers.indexOf(gathererID); | index = this.activeGatherers.indexOf(gathererID); | ||||
if (index == -1) | if (index == -1) | ||||
return; | return; | ||||
this.activeGatherers.splice(index, 1); | this.activeGatherers.splice(index, 1); | ||||
this.CheckTimers(); | this.CheckTimers(); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 183 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Note that this message & the one above could still be interesting to have (need to check if stats/triggers use them too), simply removing the AIProxy already speeds things up quite a bit.