Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Trainer.js
Show First 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | |||||
Trainer.prototype.Item.prototype.Finish = function() | Trainer.prototype.Item.prototype.Finish = function() | ||||
{ | { | ||||
this.Spawn(); | this.Spawn(); | ||||
if (!this.count) | if (!this.count) | ||||
this.finished = true; | this.finished = true; | ||||
}; | }; | ||||
/** | |||||
* @return {boolean} - | |||||
*/ | |||||
Trainer.prototype.Item.prototype.IsFinished = function() | |||||
{ | |||||
return !!this.finished; | |||||
}; | |||||
/* | /* | ||||
* This function creates the entities and places them in world if possible | * This function creates the entities and places them in world if possible | ||||
* (some of these entities may be garrisoned directly if autogarrison, the others are spawned). | * (some of these entities may be garrisoned directly if autogarrison, the others are spawned). | ||||
*/ | */ | ||||
Trainer.prototype.Item.prototype.Spawn = function() | Trainer.prototype.Item.prototype.Spawn = function() | ||||
{ | { | ||||
const createdEnts = []; | const createdEnts = []; | ||||
const spawnedEnts = []; | const spawnedEnts = []; | ||||
▲ Show 20 Lines • Show All 467 Lines • ▼ Show 20 Lines | |||||
* @param {number} id - The ID of the item we spent time on. | * @param {number} id - The ID of the item we spent time on. | ||||
* @param {number} allocatedTime - The time we spent on the given item. | * @param {number} allocatedTime - The time we spent on the given item. | ||||
* @return {number} - The time we've actually used. | * @return {number} - The time we've actually used. | ||||
*/ | */ | ||||
Trainer.prototype.Progress = function(id, allocatedTime) | Trainer.prototype.Progress = function(id, allocatedTime) | ||||
{ | { | ||||
const item = this.queue.get(id); | const item = this.queue.get(id); | ||||
const usedTime = item.Progress(allocatedTime); | const usedTime = item.Progress(allocatedTime); | ||||
if (item.finished) | if (item.IsFinished()) | ||||
this.queue.delete(id); | this.queue.delete(id); | ||||
return usedTime; | return usedTime; | ||||
}; | }; | ||||
Trainer.prototype.OnOwnershipChanged = function(msg) | Trainer.prototype.OnOwnershipChanged = function(msg) | ||||
{ | { | ||||
if (msg.to != INVALID_PLAYER) | if (msg.to != INVALID_PLAYER) | ||||
this.CalculateEntitiesMap(); | this.CalculateEntitiesMap(); | ||||
Show All 31 Lines |
Wildfire Games · Phabricator