Ticket #3277: Trader_js.patch

File Trader_js.patch, 1.7 KB (added by otero, 8 years ago)
  • binaries/data/mods/public/simulation/components/Trader.js

     
    1 // See helpers/TraderGain.js for the CalculateTaderGain() function which works out how many 
    2 // resources a trader gets 
     1// See helpers/TraderGain.js for the CalculateTaderGain() function which works out how many
     2// resources a trader gets
    33
    44// Additional gain for ships for each garrisoned trader, in percents
    55const GARRISONED_TRADER_ADDITION = 20;
     
    6363                gain.market2Gain = Math.round(garrisonMultiplier * gain.market2Gain);
    6464        }
    6565    }
    66    
     66
    6767    return gain;
    6868};
    6969
     
    255255
    256256Trader.prototype.StopTrading = function()
    257257{
    258     // Drop carried goods
    259     this.goods.amount = null;
    260258    // Reset markets
    261259    this.firstMarket = INVALID_ENTITY;
    262260    this.secondMarket = INVALID_ENTITY;
     
    280278        this.gain = this.CalculateGain(this.firstMarket, this.secondMarket);
    281279};
    282280
     281Trader.prototype.InvalidateFirstMarket = function()
     282{
     283    this.firstMarket = INVALID_ENTITY;
     284}
     285
     286Trader.prototype.InvalidateSecondMarket = function()
     287{
     288    this.secondMarket = INVALID_ENTITY;
     289}
     290
     291Trader.prototype.MoveToFirstMarket = function() {
     292    let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI);
     293    cmpUnitAI.MoveToMarket(this.firstMarket);
     294}
     295
     296Trader.prototype.MoveToSecondMarket = function() {
     297    let cmpUnitAI = Engine.QueryInterface(this.enitity, IID_UnitAI);
     298    cmpUnitAI.MoveToMarket(this.secondMarket);
     299}
     300
    283301Engine.RegisterComponentType(IID_Trader, "Trader", Trader);