Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Upgrade.js
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
Upgrade.prototype.Upgrade = function(template) | Upgrade.prototype.Upgrade = function(template) | ||||
{ | { | ||||
if (this.IsUpgrading() || !this.upgradeTemplates[template]) | if (this.IsUpgrading() || !this.upgradeTemplates[template]) | ||||
return false; | return false; | ||||
let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); | let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); | ||||
if (!cmpPlayer) | |||||
return false; | |||||
let cmpProductionQueue = Engine.QueryInterface(this.entity, IID_ProductionQueue); | |||||
if (cmpProductionQueue && cmpProductionQueue.HasQueuedProduction()) | |||||
{ | |||||
let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | |||||
cmpGUIInterface.PushNotification({ | |||||
"players": [cmpPlayer.GetPlayerID()], | |||||
"message": markForTranslation("Entity is producing. Cannot start upgrading."), | |||||
"translateMessage": true | |||||
}); | |||||
return false; | |||||
} | |||||
this.expendedResources = this.GetResourceCosts(template); | this.expendedResources = this.GetResourceCosts(template); | ||||
if (!cmpPlayer || !cmpPlayer.TrySubtractResources(this.expendedResources)) | if (!cmpPlayer || !cmpPlayer.TrySubtractResources(this.expendedResources)) | ||||
{ | { | ||||
this.expendedResources = {}; | this.expendedResources = {}; | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator