Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ProductionQueue.js
Show First 20 Lines • Show All 800 Lines • ▼ Show 20 Lines | if (!item.productionStarted) | ||||
{ | { | ||||
cmpPlayer.BlockTraining(); | cmpPlayer.BlockTraining(); | ||||
return; | return; | ||||
} | } | ||||
this.SetAnimation("training"); | this.SetAnimation("training"); | ||||
cmpPlayer.UnBlockTraining(); | cmpPlayer.UnBlockTraining(); | ||||
// AutoQueue: We add the second batch after starting the first. | |||||
// (As opposed to when the first batch finishes.) | |||||
// This is to make the feature not infinitely better than good micro. | |||||
if (this.autoqueuing) | |||||
this.AddItem(item.unitTemplate, "unit", item.count, item.metadata); | |||||
Engine.PostMessage(this.entity, MT_TrainingStarted, { "entity": this.entity }); | Engine.PostMessage(this.entity, MT_TrainingStarted, { "entity": this.entity }); | ||||
} | } | ||||
if (item.technologyTemplate) | if (item.technologyTemplate) | ||||
{ | { | ||||
let cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); | let cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); | ||||
if (cmpTechnologyManager) | if (cmpTechnologyManager) | ||||
cmpTechnologyManager.StartedResearch(item.technologyTemplate, true); | cmpTechnologyManager.StartedResearch(item.technologyTemplate, true); | ||||
else | else | ||||
Show All 16 Lines | while (this.queue.length) | ||||
{ | { | ||||
let numSpawned = this.SpawnUnits(item); | let numSpawned = this.SpawnUnits(item); | ||||
if (numSpawned) | if (numSpawned) | ||||
cmpPlayer.UnReservePopulationSlots(item.population * numSpawned); | cmpPlayer.UnReservePopulationSlots(item.population * numSpawned); | ||||
if (numSpawned == item.count) | if (numSpawned == item.count) | ||||
{ | { | ||||
cmpPlayer.UnBlockTraining(); | cmpPlayer.UnBlockTraining(); | ||||
delete this.spawnNotified; | delete this.spawnNotified; | ||||
if (this.autoqueuing) | |||||
if (!this.AddItem(item.unitTemplate, "unit", item.count, item.metadata)) | |||||
{ | |||||
this.DisableAutoQueue(); | |||||
const cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | |||||
cmpGUIInterface.PushNotification({ | |||||
"players": [cmpPlayer.GetPlayerID()], | |||||
"message": markForTranslation("Could not autoqueue unit, de-activating."), | |||||
Freagarach: Same about `autoqueue`. | |||||
"translateMessage": true | |||||
}); | |||||
} | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (numSpawned) | if (numSpawned) | ||||
{ | { | ||||
item.count -= numSpawned; | item.count -= numSpawned; | ||||
Engine.PostMessage(this.entity, MT_ProductionQueueChanged, null); | Engine.PostMessage(this.entity, MT_ProductionQueueChanged, null); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Same about autoqueue.