Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/Commands.js
Show First 20 Lines • Show All 1,119 Lines • ▼ Show 20 Lines | if (cmpTechnologyManager && !cmpTechnologyManager.CanProduce(cmd.template)) | ||||
Engine.DestroyEntity(ent); | Engine.DestroyEntity(ent); | ||||
} | } | ||||
// We need the cost after tech and aura modifications | // We need the cost after tech and aura modifications | ||||
// To calculate this with an entity requires ownership, so use the template instead | // To calculate this with an entity requires ownership, so use the template instead | ||||
let cmpCost = Engine.QueryInterface(ent, IID_Cost); | let cmpCost = Engine.QueryInterface(ent, IID_Cost); | ||||
let costs = cmpCost.GetResourceCosts(player); | let costs = cmpCost.GetResourceCosts(player); | ||||
if (!cmpPlayer.TrySubtractResources(costs)) | // GetPopulationCount already includes the building population | ||||
if (cmpPlayer.GetPopulationLimit() < cmpPlayer.GetPopulationCount() || !cmpPlayer.TrySubtractResources(costs)) | |||||
{ | { | ||||
if (g_DebugCommands) | if (g_DebugCommands) | ||||
warn("Invalid command: building cost check failed for player "+player+": "+uneval(cmd)); | warn("Invalid command: building cost check failed for player "+player+": "+uneval(cmd)); | ||||
Engine.DestroyEntity(ent); | Engine.DestroyEntity(ent); | ||||
cmpPosition.MoveOutOfWorld(); | cmpPosition.MoveOutOfWorld(); | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 591 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator