Ticket #2342: patch_alert_autogarrison.patch

File patch_alert_autogarrison.patch, 2.8 KB (added by Itms, 10 years ago)
  • binaries/data/mods/public/simulation/components/AlertRaiser.js

     
    3434    PlaySound(alertString, this.entity);
    3535};
    3636
    37 AlertRaiser.prototype.IncreaseAlertLevel = function()
     37AlertRaiser.prototype.UpdateUnits = function()
    3838{
    39     if(!this.CanIncreaseLevel())
    40         return false;
    41    
    4239    // Find units owned by this unit's player
    4340    var players = [];
    4441    var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
    4542    if (cmpOwnership)
    4643        players = [cmpOwnership.GetOwner()];
    47        
    48     this.level++;
    49     this.SoundAlert();
    5044   
    5145    // Select units to put under alert, ignoring domestic animals (NB : war dogs are not domestic)
    5246    var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     
    6256        cmpUnitAI.ReplaceOrder("Alert", {"raiser": this.entity, "force": true});
    6357        this.walkingUnits.push(unit);
    6458    }
     59}
     60
     61AlertRaiser.prototype.IncreaseAlertLevel = function()
     62{
     63    if(!this.CanIncreaseLevel())
     64        return false;
     65       
     66    this.level++;
     67    this.SoundAlert();
    6568   
     69    this.UpdateUnits();
     70   
    6671    return true;
    6772};
    6873
     
    7277   
    7378    var index = this.walkingUnits.indexOf(msg.unit);
    7479    if (index != -1)
    75         this.walkingUnits.splice(index, 1);
    76    
     80        this.walkingUnits.splice(index, 1);
    7781}
    7882
     83AlertRaiser.prototype.OnGlobalTrainingFinished = function(msg)
     84{
     85    this.UpdateUnits();
     86}
     87
    7988AlertRaiser.prototype.EndOfAlert = function()
    8089{
    8190    this.level = 0;
  • binaries/data/mods/public/simulation/components/interfaces/ProductionQueue.js

     
    77// Message of the form { entities: [id, ...], metadata: ... }
    88// sent to the current entity whenever a unit has been trained.
    99Engine.RegisterMessageType("TrainingFinished");
     10
     11// Message of the form { } broadcasted whenever a unit has been trained.
     12Engine.RegisterMessageType("GlobalTrainingFinished");
  • binaries/data/mods/public/simulation/components/ProductionQueue.js

     
    592592            "owner": cmpOwnership.GetOwner(),
    593593            "metadata": metadata,
    594594        });
     595       
     596        Engine.BroadcastMessage(MT_GlobalTrainingFinished, {});
    595597    }
    596598   
    597599    return createdEnts.length;