Ticket #3726: gatheringTarget.patch
File gatheringTarget.patch, 2.6 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/UnitAI.js
2143 2143 var cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); 2144 2144 if (cmpSupply) 2145 2145 cmpSupply.RemoveGatherer(this.entity); 2146 delete this.gatheringTarget;2146 this.gatheringTarget = undefined; 2147 2147 }, 2148 2148 }, 2149 2149 … … 2261 2261 var cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); 2262 2262 if (cmpSupply) 2263 2263 cmpSupply.RemoveGatherer(this.entity); 2264 delete this.gatheringTarget;2264 this.gatheringTarget = undefined; 2265 2265 2266 2266 // Show the carried resource, if we've gathered anything. 2267 2267 this.SetGathererAnimationOverride(); … … 2306 2306 { 2307 2307 // (Keep this Gather order on the stack so we'll 2308 2308 // continue gathering after returning) 2309 this.PushOrderFront("ReturnResource", { "target": nearby, "force": false });2309 this.PushOrderFront("ReturnResource", { "target": nearby, "force": false, "supply": this.gatheringTarget }); 2310 2310 return; 2311 2311 } 2312 2312 … … 2542 2542 "APPROACHING": { 2543 2543 "enter": function () { 2544 2544 this.SelectAnimation("move"); 2545 2546 if (this.order.data.supply) 2547 { 2548 let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 2549 let cmpSupply = Engine.QueryInterface(this.order.data.supply, IID_ResourceSupply); 2550 if (cmpSupply) 2551 cmpSupply.AddGatherer(cmpOwnership.GetOwner(), this.entity); 2552 this.gatheringTarget = this.order.data.supply; 2553 } 2545 2554 }, 2546 2555 2547 2556 "MoveCompleted": function() { … … 2580 2589 var nearby = this.FindNearestDropsite(genericType); 2581 2590 if (nearby) 2582 2591 { 2592 let data = { "target": nearby, "force": false }; 2593 if (this.order.data.supply) 2594 data.supply = this.order.data.supply; 2583 2595 this.FinishOrder(); 2584 this.PushOrderFront("ReturnResource", { "target": nearby, "force": false });2596 this.PushOrderFront("ReturnResource", data); 2585 2597 return; 2586 2598 } 2587 2599 … … 2588 2600 // Oh no, couldn't find any drop sites. Give up on returning. 2589 2601 this.FinishOrder(); 2590 2602 }, 2603 2604 "leave": function () { 2605 if (this.gatheringTarget) 2606 { 2607 let cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply); 2608 if (cmpSupply) 2609 cmpSupply.RemoveGatherer(this.entity); 2610 this.gatheringTarget = undefined; 2611 } 2612 }, 2591 2613 }, 2592 2614 }, 2593 2615