delay the ownerShip only after the entity is spawned, fix #3422

This was SVN commit r17027.
This commit is contained in:
mimo 2015-09-16 09:33:38 +00:00
parent 21619a4705
commit fc45777793

View File

@ -570,12 +570,12 @@ ProductionQueue.prototype.SpawnUnits = function(templateName, count, metadata)
for (var i = 0; i < count; ++i)
{
var ent = this.entityCache[0];
var cmpNewOwnership = Engine.QueryInterface(ent, IID_Ownership);
cmpNewOwnership.SetOwner(cmpOwnership.GetOwner());
if (cmpAutoGarrison && cmpAutoGarrison.PerformGarrison(ent))
{
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
let cmpNewOwnership = Engine.QueryInterface(ent, IID_Ownership);
cmpNewOwnership.SetOwner(cmpOwnership.GetOwner());
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
cmpUnitAI.Autogarrison(this.entity);
}
else
@ -589,7 +589,9 @@ ProductionQueue.prototype.SpawnUnits = function(templateName, count, metadata)
else
{
// Successfully spawned
var cmpNewPosition = Engine.QueryInterface(ent, IID_Position);
let cmpNewOwnership = Engine.QueryInterface(ent, IID_Ownership);
cmpNewOwnership.SetOwner(cmpOwnership.GetOwner());
let cmpNewPosition = Engine.QueryInterface(ent, IID_Position);
cmpNewPosition.JumpTo(pos.x, pos.z);
// TODO: what direction should they face in?
spawnedEnts.push(ent);