Ticket #1357: farm_supply_tech.patch
File farm_supply_tech.patch, 1.8 KB (added by , 12 years ago) |
---|
-
binaries/data/mods/public/simulation/components/ResourceSupply.js
33 33 34 34 ResourceSupply.prototype.Init = function() 35 35 { 36 // Current resource amount (non-negative; can be a fractional amount)37 this.amount = this. GetMaxAmount();36 this.maxAmount = this.GetMaxAmount(); 37 this.amount = this.maxAmount; 38 38 }; 39 39 40 40 ResourceSupply.prototype.GetKillBeforeGather = function() … … 42 42 return (this.template.KillBeforeGather == "true"); 43 43 }; 44 44 45 ResourceSupply.prototype.GetDefaultAmount = function() 46 { 47 return +this.template.Amount; 48 } 49 50 ResourceSupply.prototype.GetUpgradedAmount = function() 51 { 52 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 53 if (!cmpOwnership || cmpOwnership.GetOwner() === -1) 54 warn('No ownership or player is -1'); 55 return this.GetDefaultAmount(); 56 57 var cmpTechMan = QueryOwnerInterface(this.entity, IID_TechnologyManager); 58 return cmpTechMan.ApplyModifications("ResourceSupply/Amount", this.GetDefaultAmount(), this.entity); 59 } 60 45 61 ResourceSupply.prototype.GetMaxAmount = function() 46 62 { 47 return +this.template.Amount;63 return this.GetUpgradedAmount() || this.GetDefaultAmount(); 48 64 }; 49 65 50 66 ResourceSupply.prototype.GetCurrentAmount = function() … … 82 98 return { "generic": type, "specific": subtype }; 83 99 }; 84 100 101 ResourceSupply.prototype.OnTechnologyModificationChange = function(msg) 102 { 103 var oldAmount = this.maxAmount; 104 this.maxAmount = this.GetMaxAmount(); 105 106 var difference = this.maxAmount - oldAmount; 107 this.amount += difference; 108 } 109 85 110 Engine.RegisterComponentType(IID_ResourceSupply, "ResourceSupply", ResourceSupply);