Changeset View
Standalone View
binaries/data/mods/public/simulation/components/ProductionQueue.js
Show First 20 Lines • Show All 318 Lines • ▼ Show 20 Lines | ||||||||||||||
*/ | */ | |||||||||||||
ProductionQueue.prototype.AddBatch = function(templateName, type, count, metadata) | ProductionQueue.prototype.AddBatch = function(templateName, type, count, metadata) | |||||||||||||
{ | { | |||||||||||||
// 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 (!this.queue.length) | ||||||||||||||
{ | ||||||||||||||
Stan: Does upgrade cancel the queue? | ||||||||||||||
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()], | ||||||||||||||
Not Done Inline ActionsCheck for cmpPlayer? Freagarach: Check for cmpPlayer? | ||||||||||||||
"message": markForTranslation("Entity is being upgraded. Cannot start production."), | ||||||||||||||
"translateMessage": true | ||||||||||||||
Not Done Inline Actionstrailing , bb: trailing `,` | ||||||||||||||
}); | ||||||||||||||
return; | ||||||||||||||
Not Done Inline Actions
Freagarach: | ||||||||||||||
Done Inline Actionsnot sure about that, Silier: not sure about that,
jenkins is not complaining right now, he would if it would be wrong | ||||||||||||||
Not Done Inline ActionsBut you mix spaced and tabs for no apparent reason? Freagarach: But you mix spaced and tabs for no apparent reason? | ||||||||||||||
Done Inline Actions(For any alignment within a line of code (as opposed to indentation at the start), use spaces, not tabs.) Silier: (For any alignment within a line of code (as opposed to indentation at the start), use spaces… | ||||||||||||||
Not Done Inline ActionsAFAIK it can't complain and we can't enforce it with ESLint which is one of the reasons @Itms wanted to know whether we should use the same style in C++ and JS as for the former it is normal Stan: AFAIK it can't complain and we can't enforce it with ESLint which is one of the reasons @Itms… | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
if (this.queue.length < this.MaxQueueSize) | if (this.queue.length < this.MaxQueueSize) | |||||||||||||
Not Done Inline ActionsMight not need to check for that if !queue.length so could be moved in the block above ? Could maybe be refactored with an early return with the guinterface call Stan: Might not need to check for that if !queue.length so could be moved in the block above ?
Could… | ||||||||||||||
{ | { | |||||||||||||
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); | |||||||||||||
return; | return; | |||||||||||||
▲ Show 20 Lines • Show All 606 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() | ||||||||||||||
Not Done Inline ActionsFunction name is a bit weird. Stan: Function name is a bit weird. | ||||||||||||||
{ | ||||||||||||||
return this.queue.length > 0; | ||||||||||||||
Not Done Inline Actionsthis.queue.length? since it shouldn't be negative anyway? Stan: this.queue.length? since it shouldn't be negative anyway? | ||||||||||||||
Done Inline Actionsthen it does not return true / false what was pointed at another diff with similar line Silier: then it does not return true / false what was pointed at another diff with similar line | ||||||||||||||
Done Inline ActionsOh right. Stan: Oh right. | ||||||||||||||
Not Done Inline ActionsI guess we dont use it above for alledged perf ? Stan: I guess we dont use it above for alledged perf ? | ||||||||||||||
Not Done Inline Actions(!!this.queue.length?) Freagarach: (`!!this.queue.length`?) | ||||||||||||||
} | ||||||||||||||
Lint: JSHintBear Missing semicolon. Lint: JSHintBear: `Missing semicolon.` | ||||||||||||||
Lint: ESLintBear (semi) Missing semicolon. Lint: ESLintBear (semi): `Missing semicolon.` | ||||||||||||||
bbUnsubmitted Not Done Inline Actionsfix linter bb: fix linter | ||||||||||||||
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); |
Does upgrade cancel the queue?