Ticket #1843: retarget.diff
File retarget.diff, 2.2 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Promotion.js
78 78 cmpPromotedUnitAI.Cheer(); 79 79 var orders = cmpCurrentUnitAI.GetOrders(); 80 80 cmpPromotedUnitAI.AddOrders(orders); 81 // if any orders were targeted to the current unit, retarget them to the promoted one 82 cmpCurrentUnitAI.RetargetOrders(promotedUnitEntity); 81 83 82 84 Engine.BroadcastMessage(MT_EntityRenamed, { entity: this.entity, newentity: promotedUnitEntity }); 83 85 -
binaries/data/mods/public/simulation/components/Pack.js
162 162 if (cmpUnitAI.GetStanceName()) 163 163 cmpNewUnitAI.SwitchToStance(cmpUnitAI.GetStanceName()); 164 164 cmpNewUnitAI.AddOrders(cmpUnitAI.GetOrders()); 165 // if any orders were targeted to this unit, retarget them to the new one 166 cmpUnitAI.RetargetOrders(newEntity); 165 167 } 166 168 167 169 Engine.BroadcastMessage(MT_EntityRenamed, { entity: this.entity, newentity: newEntity }); -
binaries/data/mods/public/simulation/components/UnitAI.js
2701 2701 return orders; 2702 2702 }; 2703 2703 2704 UnitAI.prototype.RetargetOrders = function(newEntity) 2705 { 2706 // We try to retarget orders from this.entity to the new entity 2707 for each (var ent in Engine.GetEntitiesWithInterface(IID_UnitAI)) 2708 { 2709 var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 2710 for (i in cmpUnitAI.orderQueue) 2711 { 2712 if (cmpUnitAI.orderQueue[i].data && cmpUnitAI.orderQueue[i].data.target) 2713 { 2714 if (cmpUnitAI.orderQueue[i].data.target == this.entity) 2715 cmpUnitAI.orderQueue[i].data.target = newEntity; 2716 } 2717 } 2718 } 2719 }; 2720 2704 2721 UnitAI.prototype.TimerHandler = function(data, lateness) 2705 2722 { 2706 2723 // Reset the timer