Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ProductionQueue.js
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | ProductionQueue.prototype.Init = function() | ||||
// "timeRemaining": 10000, // msecs | // "timeRemaining": 10000, // msecs | ||||
// } | // } | ||||
this.timer = undefined; // g_ProgressInterval msec timer, active while the queue is non-empty | this.timer = undefined; // g_ProgressInterval msec timer, active while the queue is non-empty | ||||
this.paused = false; | this.paused = false; | ||||
this.entityCache = []; | this.entityCache = []; | ||||
this.spawnNotified = false; | this.spawnNotified = false; | ||||
this.alertRaiser = undefined; | |||||
}; | |||||
ProductionQueue.prototype.PutUnderAlert = function(raiser) | |||||
{ | |||||
this.alertRaiser = raiser; | |||||
}; | |||||
ProductionQueue.prototype.ResetAlert = function() | |||||
{ | |||||
this.alertRaiser = undefined; | |||||
}; | }; | ||||
/* | /* | ||||
* Returns list of entities that can be trained by this building. | * Returns list of entities that can be trained by this building. | ||||
*/ | */ | ||||
ProductionQueue.prototype.GetEntitiesList = function() | ProductionQueue.prototype.GetEntitiesList = function() | ||||
{ | { | ||||
return this.entitiesList; | return this.entitiesList; | ||||
▲ Show 20 Lines • Show All 457 Lines • ▼ Show 20 Lines | if (msg.to != -1) | ||||
this.CalculateEntitiesList(); | this.CalculateEntitiesList(); | ||||
// Reset the production queue whenever the owner changes. | // Reset the production queue whenever the owner changes. | ||||
// (This should prevent players getting surprised when they capture | // (This should prevent players getting surprised when they capture | ||||
// an enemy building, and then loads of the enemy's civ's soldiers get | // an enemy building, and then loads of the enemy's civ's soldiers get | ||||
// created from it. Also it means we don't have to worry about | // created from it. Also it means we don't have to worry about | ||||
// updating the reserved pop slots.) | // updating the reserved pop slots.) | ||||
this.ResetQueue(); | this.ResetQueue(); | ||||
this.ResetAlert(); | |||||
}; | }; | ||||
ProductionQueue.prototype.OnCivChanged = function() | ProductionQueue.prototype.OnCivChanged = function() | ||||
{ | { | ||||
this.CalculateEntitiesList(); | this.CalculateEntitiesList(); | ||||
}; | }; | ||||
ProductionQueue.prototype.OnDestroy = function() | ProductionQueue.prototype.OnDestroy = function() | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | if (cmpRallyPoint) | ||||
var commands = GetRallyPointCommands(cmpRallyPoint, spawnedEnts); | var commands = GetRallyPointCommands(cmpRallyPoint, spawnedEnts); | ||||
for (var com of commands) | for (var com of commands) | ||||
ProcessCommand(cmpOwnership.GetOwner(), com); | ProcessCommand(cmpOwnership.GetOwner(), com); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (createdEnts.length > 0) | if (createdEnts.length > 0) | ||||
{ | |||||
Engine.PostMessage(this.entity, MT_TrainingFinished, { | Engine.PostMessage(this.entity, MT_TrainingFinished, { | ||||
"entities": createdEnts, | "entities": createdEnts, | ||||
"owner": cmpOwnership.GetOwner(), | "owner": cmpOwnership.GetOwner(), | ||||
"metadata": metadata, | "metadata": metadata, | ||||
}); | }); | ||||
if (this.alertRaiser && spawnedEnts.length > 0) | |||||
{ | |||||
var cmpAlertRaiser = Engine.QueryInterface(this.alertRaiser, IID_AlertRaiser); | |||||
if (cmpAlertRaiser) | |||||
cmpAlertRaiser.UpdateUnits(spawnedEnts); | |||||
} | |||||
} | |||||
return createdEnts.length; | return createdEnts.length; | ||||
}; | }; | ||||
/* | /* | ||||
* Increments progress on the first batch in the production queue, and blocks the | * Increments progress on the first batch in the production queue, and blocks the | ||||
* queue if population limit is reached or some units failed to spawn. | * queue if population limit is reached or some units failed to spawn. | ||||
*/ | */ | ||||
ProductionQueue.prototype.ProgressTimeout = function(data) | ProductionQueue.prototype.ProgressTimeout = function(data) | ||||
▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator