Allow garrisoned entities to upgrade.
Since its introduction inb2f4b0f494
garrisoned entities were not allowed to upgrade (b2f4b0f494#inline-4821) but that is not needed (at least since4fadd75ace
). Changing templates to anything not being able to garrison will still fail (#5906) but that can also be done with this code. Differential revision: D3251 Comment by: @bb This was SVN commit r24958.
This commit is contained in:
parent
f4c9305eee
commit
41a5650a62
@ -710,16 +710,6 @@ var g_Commands = {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CanGarrisonedChangeTemplate(ent, cmd.template))
|
||||
{
|
||||
var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
|
||||
cmpGUIInterface.PushNotification({
|
||||
"players": [player],
|
||||
"message": markForTranslation("Cannot upgrade a garrisoned entity.")
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check entity limits
|
||||
var cmpEntityLimits = QueryPlayerIDInterface(player, IID_EntityLimits);
|
||||
if (cmpEntityLimits && !cmpEntityLimits.AllowedToReplace(ent, cmd.template))
|
||||
|
@ -140,19 +140,6 @@ function ChangeEntityTemplate(oldEnt, newTemplate)
|
||||
return newEnt;
|
||||
}
|
||||
|
||||
function CanGarrisonedChangeTemplate(ent, template)
|
||||
{
|
||||
var cmpPosition = Engine.QueryInterface(ent, IID_Position);
|
||||
var unitAI = Engine.QueryInterface(ent, IID_UnitAI);
|
||||
if (cmpPosition && !cmpPosition.IsInWorld() && unitAI && unitAI.IsGarrisoned())
|
||||
{
|
||||
// We're a garrisoned unit, assume impossibility as I've been unable to find a way to get the holder ID.
|
||||
// TODO: change this if that ever becomes possibles
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function CopyControlGroups(oldEnt, newEnt)
|
||||
{
|
||||
let cmpObstruction = Engine.QueryInterface(oldEnt, IID_Obstruction);
|
||||
@ -277,5 +264,4 @@ function TransferGarrisonedUnits(oldEnt, newEnt)
|
||||
}
|
||||
|
||||
Engine.RegisterGlobal("ChangeEntityTemplate", ChangeEntityTemplate);
|
||||
Engine.RegisterGlobal("CanGarrisonedChangeTemplate", CanGarrisonedChangeTemplate);
|
||||
Engine.RegisterGlobal("ObstructionsBlockingTemplateChange", ObstructionsBlockingTemplateChange);
|
||||
|
Loading…
Reference in New Issue
Block a user