Ticket #4085: sharing.patch
File sharing.patch, 5.7 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/ai/common-api/entity.js
623 623 decaying: function() { return this._entity.decaying !== undefined ? this._entity.decaying : undefined; }, 624 624 capturePoints: function() {return this._entity.capturePoints !== undefined ? this._entity.capturePoints : undefined; }, 625 625 626 "isSharedDropsite": function() { return this._entity.sharedDropsite === true; }, 627 626 628 /** 627 629 * Returns the current training queue state, of the form 628 630 * [ { "id": 0, "template": "...", "count": 1, "progress": 0.5, "metadata": ... }, ... ] -
binaries/data/mods/public/simulation/ai/common-api/gamestate.js
595 595 m.GameState.prototype.getOwnDropsites = function(resource) 596 596 { 597 597 if (resource !== undefined) 598 return this.updatingCollection(" dropsite-" + resource, m.Filters.isDropsite(resource), this.getOwnEntities());599 return this.updatingCollection(" dropsite-all", m.Filters.isDropsite(), this.getOwnEntities());598 return this.updatingCollection("ownDropsite-" + resource, m.Filters.isDropsite(resource), this.getOwnEntities()); 599 return this.updatingCollection("ownDropsite-all", m.Filters.isDropsite(), this.getOwnEntities()); 600 600 }; 601 601 602 m.GameState.prototype.getAnyDropsites = function(resource) 603 { 604 if (resource !== undefined) 605 return this.updatingGlobalCollection("anyDropsite-" + resource, m.Filters.isDropsite(resource), this.getEntities()); 606 return this.updatingGlobalCollection("anyDropsite-all", m.Filters.isDropsite(), this.getEntities()); 607 }; 608 602 609 m.GameState.prototype.getResourceSupplies = function(resource) 603 610 { 604 611 return this.updatingGlobalCollection("resource-" + resource, m.Filters.byResource(resource), this.getEntities()); -
binaries/data/mods/public/simulation/ai/petra/entityExtend.js
99 99 let closestDropsite; 100 100 let distmin = Math.min(); 101 101 let access = gameState.ai.accessibility.getAccessValue(ent.position()); 102 gameState.getOwnDropsites(resource).forEach(function(dropsite) { 103 if (!dropsite.position() || dropsite.getMetadata(PlayerID, "access") !== access) 102 let hasSharedDropsites = gameState.playerData.hasSharedDropsites; 103 let dropsiteCollection = hasSharedDropsites ? gameState.getAnyDropsites(resource) : gameState.getOwnDropsites(resource); 104 dropsiteCollection.forEach(function(dropsite) { 105 if (!dropsite.position()) 104 106 return; 107 if (hasSharedDropsites && !gameState.isPlayerMutualAlly(dropsite.owner())) 108 return; 109 let dropsiteAccess = dropsite.getMetadata(PlayerID, "access"); 110 if (!dropsiteAccess) 111 { 112 dropsiteAccess = gameState.ai.accessibility.getAccessValue(dropsite.position()); 113 dropsite.setMetadata(PlayerID, "access", dropsiteAccess); 114 } 115 if (dropsiteAccess !== access) 116 return; 105 117 let dist = API3.SquareVectorDistance(ent.position(), dropsite.position()); 106 118 if (dist > distmin) 107 119 return; -
binaries/data/mods/public/simulation/components/AIProxy.js
193 193 this.changes.foundationBuilders = msg.to; 194 194 }; 195 195 196 AIProxy.prototype.OnDropsiteSharingChanged = function(msg) 197 { 198 if (!this.NotifyChange()) 199 return; 200 this.changes.sharedDropsite = msg.shared; 201 }; 202 196 203 AIProxy.prototype.OnTerritoryDecayChanged = function(msg) 197 204 { 198 205 if (!this.NotifyChange()) … … 286 293 ret.resourceCarrying = cmpResourceGatherer.GetCarryingStatus(); 287 294 } 288 295 296 let cmpResourceDropsite = Engine.QueryInterface(this.entity, IID_ResourceDropsite); 297 if (cmpResourceDropsite) 298 { 299 // Updated by OnDropsiteSharingChanged 300 ret.sharedDropsite = cmpResourceDropsite.IsShared(); 301 } 302 289 303 let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); 290 304 if (cmpGarrisonHolder) 291 305 { -
binaries/data/mods/public/simulation/components/ResourceDropsite.js
52 52 53 53 ResourceDropsite.prototype.SetSharing = function(value) 54 54 { 55 if (this.sharable) 56 this.shared = value; 55 if (!this.sharable) 56 return; 57 this.shared = value; 58 Engine.PostMessage(this.entity, MT_DropsiteSharingChanged, { "shared": this.shared }); 57 59 }; 58 60 59 61 Engine.RegisterComponentType(IID_ResourceDropsite, "ResourceDropsite", ResourceDropsite); -
binaries/data/mods/public/simulation/components/interfaces/ResourceDropsite.js
1 1 Engine.RegisterInterface("ResourceDropsite"); 2 3 // Message of the form { "shared": true }, 4 Engine.RegisterMessageType("DropsiteSharingChanged");