Ticket #3277: Trader_js.patch
File Trader_js.patch, 1.7 KB (added by , 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 3 3 4 4 // Additional gain for ships for each garrisoned trader, in percents 5 5 const GARRISONED_TRADER_ADDITION = 20; … … 63 63 gain.market2Gain = Math.round(garrisonMultiplier * gain.market2Gain); 64 64 } 65 65 } 66 66 67 67 return gain; 68 68 }; 69 69 … … 255 255 256 256 Trader.prototype.StopTrading = function() 257 257 { 258 // Drop carried goods259 this.goods.amount = null;260 258 // Reset markets 261 259 this.firstMarket = INVALID_ENTITY; 262 260 this.secondMarket = INVALID_ENTITY; … … 280 278 this.gain = this.CalculateGain(this.firstMarket, this.secondMarket); 281 279 }; 282 280 281 Trader.prototype.InvalidateFirstMarket = function() 282 { 283 this.firstMarket = INVALID_ENTITY; 284 } 285 286 Trader.prototype.InvalidateSecondMarket = function() 287 { 288 this.secondMarket = INVALID_ENTITY; 289 } 290 291 Trader.prototype.MoveToFirstMarket = function() { 292 let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); 293 cmpUnitAI.MoveToMarket(this.firstMarket); 294 } 295 296 Trader.prototype.MoveToSecondMarket = function() { 297 let cmpUnitAI = Engine.QueryInterface(this.enitity, IID_UnitAI); 298 cmpUnitAI.MoveToMarket(this.secondMarket); 299 } 300 283 301 Engine.RegisterComponentType(IID_Trader, "Trader", Trader);