Differential D2652 Diff 13601 ps/trunk/binaries/data/mods/public/simulation/components/ProductionQueue.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/ProductionQueue.js
Show First 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
// TODO: there should probably be a limit on the number of queued batches. | // TODO: there should probably be a limit on the number of queued batches. | ||||
// TODO: there should be a way for the GUI to determine whether it's going | // TODO: there should be a way for the GUI to determine whether it's going | ||||
// to be possible to add a batch (based on resource costs and length limits). | // to be possible to add a batch (based on resource costs and length limits). | ||||
let cmpPlayer = QueryOwnerInterface(this.entity); | let cmpPlayer = QueryOwnerInterface(this.entity); | ||||
if (!cmpPlayer) | if (!cmpPlayer) | ||||
return; | return; | ||||
if (!this.queue.length) | |||||
{ | |||||
let cmpUpgrade = Engine.QueryInterface(this.entity, IID_Upgrade); | |||||
if (cmpUpgrade && cmpUpgrade.IsUpgrading()) | |||||
{ | |||||
let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | |||||
cmpGUIInterface.PushNotification({ | |||||
"players": [cmpPlayer.GetPlayerID()], | |||||
"message": markForTranslation("Entity is being upgraded. Cannot start production."), | |||||
"translateMessage": true | |||||
}); | |||||
return; | |||||
} | |||||
} | |||||
if (this.queue.length < this.MaxQueueSize) | if (this.queue.length < this.MaxQueueSize) | ||||
{ | { | ||||
if (type == "unit") | if (type == "unit") | ||||
{ | { | ||||
if (!Number.isInteger(count) || count <= 0) | if (!Number.isInteger(count) || count <= 0) | ||||
{ | { | ||||
error("Invalid batch count " + count); | error("Invalid batch count " + count); | ||||
▲ Show 20 Lines • Show All 622 Lines • ▼ Show 20 Lines | ProductionQueue.prototype.OnValueModification = function(msg) | ||||
// Inform the GUI that it'll need to recompute the selection panel. | // Inform the GUI that it'll need to recompute the selection panel. | ||||
// TODO: it would be better to only send the message if something actually changing | // TODO: it would be better to only send the message if something actually changing | ||||
// for the current production queue. | // for the current production queue. | ||||
let cmpPlayer = QueryOwnerInterface(this.entity); | let cmpPlayer = QueryOwnerInterface(this.entity); | ||||
if (cmpPlayer) | if (cmpPlayer) | ||||
Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface).SetSelectionDirty(cmpPlayer.GetPlayerID()); | Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface).SetSelectionDirty(cmpPlayer.GetPlayerID()); | ||||
}; | }; | ||||
ProductionQueue.prototype.HasQueuedProduction = function() | |||||
{ | |||||
return this.queue.length > 0; | |||||
}; | |||||
ProductionQueue.prototype.OnDisabledTemplatesChanged = function(msg) | ProductionQueue.prototype.OnDisabledTemplatesChanged = function(msg) | ||||
{ | { | ||||
// If the disabled templates of the player is changed, | // If the disabled templates of the player is changed, | ||||
// update the entities list so that this is reflected there. | // update the entities list so that this is reflected there. | ||||
this.CalculateEntitiesMap(); | this.CalculateEntitiesMap(); | ||||
}; | }; | ||||
Engine.RegisterComponentType(IID_ProductionQueue, "ProductionQueue", ProductionQueue); | Engine.RegisterComponentType(IID_ProductionQueue, "ProductionQueue", ProductionQueue); |
Wildfire Games · Phabricator