Ticket #1999: destroy.diff

File destroy.diff, 1.0 KB (added by mimo, 11 years ago)
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    25642564
    25652565UnitAI.prototype.OnDestroy = function()
    25662566{
    2567     // Clean up any timers that are now obsolete
    2568     this.StopTimer();
    2569 
    2570     // clear up the ResourceSupply gatherer count.
    2571     if (this.gatheringTarget)
    2572     {
    2573         var cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply);
    2574         if (cmpSupply)
    2575             cmpSupply.RemoveGatherer(this.entity);
    2576         delete this.gatheringTarget;
    2577     }
     2567    // Go to an "empty" state to properly close the present state (e.g. call its leave function)
     2568    var nextState = this.GetCurrentState();
     2569    if (nextState.indexOf(".") != -1)
     2570        UnitFsm.SwitchToNextState(this, nextState.slice(0, nextState.indexOf(".")));
    25782571   
    25792572    // Clean up range queries
    25802573    var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);