Ticket #3741: terrainFarm.patch
File terrainFarm.patch, 6.0 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Foundation.js
296 296 } 297 297 298 298 // ---------------------------------------------------------------------- 299 300 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 299 300 var owner; 301 var cmpTerritoryDecay = Engine.QueryInterface(building, IID_TerritoryDecay); 302 if (cmpTerritoryDecay && cmpTerritoryDecay.HasTerritoryOwnership()) 303 { 304 let cmpTerritoryManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryManager); 305 owner = cmpTerritoryManager.GetOwner(pos.x, pos.z); 306 } 307 else 308 { 309 let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 310 owner = cmpOwnership.GetOwner(); 311 } 301 312 var cmpBuildingOwnership = Engine.QueryInterface(building, IID_Ownership); 302 cmpBuildingOwnership.SetOwner( cmpOwnership.GetOwner());313 cmpBuildingOwnership.SetOwner(owner); 303 314 304 315 // ---------------------------------------------------------------------- 305 316 -
binaries/data/mods/public/simulation/components/TerritoryDecay.js
2 2 3 3 TerritoryDecay.prototype.Schema = 4 4 "<element name='DecayRate' a:help='Decay rate in capture points per second'>" + 5 "< ref name='positiveDecimal'/>" +5 "<choice><ref name='positiveDecimal'/><value>Infinity</value></choice>" + 6 6 "</element>"; 7 7 8 8 TerritoryDecay.prototype.Init = function() … … 9 9 { 10 10 this.decaying = false; 11 11 this.connectedNeighbours = []; 12 this.territoryOwnership = !isFinite(+this.template.DecayRate); 12 13 }; 13 14 14 15 TerritoryDecay.prototype.IsConnected = function() … … 84 85 Engine.PostMessage(this.entity, MT_TerritoryDecayChanged, { "entity": this.entity, "to": decaying, "rate": this.GetDecayRate() }); 85 86 }; 86 87 88 TerritoryDecay.prototype.UpdateOwner = function() 89 { 90 let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 91 let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); 92 if (!cmpOwnership || !cmpPosition || !cmpPosition.IsInWorld()) 93 return; 94 let cmpTerritoryManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryManager); 95 let pos = cmpPosition.GetPosition2D(); 96 let tileOwner = cmpTerritoryManager.GetOwner(pos.x, pos.y); 97 if (tileOwner != cmpOwnership.GetOwner()) 98 cmpOwnership.SetOwner(tileOwner); 99 }; 100 87 101 TerritoryDecay.prototype.OnTerritoriesChanged = function(msg) 88 102 { 89 this.UpdateDecayState(); 103 if (this.territoryOwnership) 104 this.UpdateOwner(); 105 else 106 this.UpdateDecayState(); 90 107 }; 91 108 92 109 TerritoryDecay.prototype.OnTerritoryPositionChanged = function(msg) 93 110 { 94 this.UpdateDecayState(); 111 if (this.territoryOwnership) 112 this.UpdateOwner(); 113 else 114 this.UpdateDecayState(); 95 115 }; 96 116 97 117 TerritoryDecay.prototype.OnOwnershipChanged = function(msg) 98 118 { 99 // if it influences the territory, wait until we get a TerritoriesChanged message 100 if (!Engine.QueryInterface(this.entity, IID_TerritoryInfluence)) 101 this.UpdateDecayState(); 119 if (this.territoryOwnership) 120 if (msg.to != -1) 121 this.UpdateOwner(); 122 else 123 { 124 // if it influences the territory, wait until we get a TerritoriesChanged message 125 if (!Engine.QueryInterface(this.entity, IID_TerritoryInfluence)) 126 this.UpdateDecayState(); 127 } 102 128 }; 103 129 130 TerritoryDecay.prototype.HasTerritoryOwnership = function() 131 { 132 return this.territoryOwnership; 133 }; 134 104 135 Engine.RegisterComponentType(IID_TerritoryDecay, "TerritoryDecay", TerritoryDecay); -
binaries/data/mods/public/simulation/templates/other/generic_field.xml
9 9 <SpecificName>Wheat Field</SpecificName> 10 10 <History>A farmer's field.</History> 11 11 </Identity> 12 <TerritoryDecay disable=""/>13 12 <VisualActor> 14 13 <Actor>structures/plot_field_new.xml</Actor> 15 14 <FoundationActor>structures/plot_field_new.xml</FoundationActor> -
binaries/data/mods/public/simulation/templates/template_structure_resource_field.xml
9 9 <Category>Field</Category> 10 10 </BuildRestrictions> 11 11 <Capturable disable=""/> 12 <TerritoryDecay> 13 <DecayRate>Infinity</DecayRate> 14 </TerritoryDecay> 12 15 <Cost> 13 16 <BuildTime>50</BuildTime> 14 17 <Resources> … … 25 28 </Health> 26 29 <Identity> 27 30 <GenericName>Field</GenericName> 28 31 <VisibleClasses datatype="tokens">Field</VisibleClasses> 29 32 <Tooltip>Harvest vegetables for food. Max gatherers: 5.</Tooltip> 30 33 <History>Farming originated around 9500 BC in India and the Middle East. The history of agriculture is a central element of human history, as agricultural progress has been a crucial factor in worldwide socio-economic change. Wealth-building and militaristic specializations rarely seen in hunter-gatherer cultures are commonplace in agricultural and agro-industrial societies - when farmers became capable of producing food beyond the needs of their own families, others in the tribe/nation/empire were freed to devote themselves to projects other than food acquisition.</History> 31 34 <Icon>structures/field.png</Icon> … … 65 68 <StatusBars> 66 69 <HeightOffset>8.0</HeightOffset> 67 70 </StatusBars> 68 <TerritoryDecay disable=""/>69 71 <Vision> 70 72 <Range>0</Range> 71 73 </Vision>