Ticket #2180: AIFix_.3.patch
File AIFix_.3.patch, 6.0 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/simulation/ai/aegis/base-manager.js
222 222 if (ent && ent.resourceSupplyAmount() && ent.owner() == 0) 223 223 this.assignResourceToDP(gameState,ent); 224 224 } 225 } else if (events[i].type == "EntityRenamed") 226 { 227 var evt = events[i]; 228 debug (evt); 229 225 230 } 226 231 } 227 232 }; … … 483 488 // for each dropsite, recalculate 484 489 for (i in this.dropsites) 485 490 { 491 warn(uneval(i)); 486 492 for (type in this.dropsites[i]) 487 493 { 488 494 this.updateDropsite(gameState,gameState.getEntityById(i),type); -
binaries/data/mods/public/simulation/ai/common-api-v3/shared.js
180 180 this._techModifications[o] = state.players[o].techModifications; 181 181 182 182 this._entities = {}; 183 this.entities = new EntityCollection(this);184 183 185 /*(var id in state.entities)184 for (var id in state.entities) 186 185 { 187 186 this._entities[id] = new Entity(this, state.entities[id]); 188 187 } 189 188 // entity collection updated on create/destroy event. 190 189 this.entities = new EntityCollection(this, this._entities); 191 */192 190 193 this.ApplyEntitiesDelta(state);194 195 191 // create the terrain analyzer 196 192 this.terrainAnalyzer = new TerrainAnalysis(); 197 193 this.terrainAnalyzer.init(this, state); … … 214 210 // applies entity deltas, and each gamestate. 215 211 SharedScript.prototype.onUpdate = function(state) 216 212 { 217 if (this.turn !== 0) 218 this.ApplyEntitiesDelta(state); 213 this.ApplyEntitiesDelta(state); 219 214 220 215 Engine.ProfileStart("onUpdate"); 221 216 … … 297 292 for (var i in this._players) 298 293 delete this._entityMetadata[this._players[i]][evt.msg.entity]; 299 294 } 295 else if (evt.type == "EntityRenamed") 296 { 297 //combines destroy and create. 298 299 warn(uneval(evt.msg)); 300 301 // Switch the metadata 302 for (var i in this._players) 303 { 304 warn (uneval(this._entityMetadata[this._players[i]][evt.msg.entity])); 305 this._entityMetadata[this._players[i]][evt.msg.newentity] = this._entityMetadata[this._players[i]][evt.msg.entity]; 306 this._entityMetadata[this._players[i]][evt.msg.entity] = {}; 307 } 308 } 300 309 else if (evt.type == "TrainingFinished") 301 310 { 302 311 // Apply metadata stored in training queues -
binaries/data/mods/public/simulation/components/AIInterface.js
37 37 return state; 38 38 }; 39 39 // Intended to be called first, during the map initialization: no caching 40 AIInterface.prototype.GetFullRepresentation = function( )40 AIInterface.prototype.GetFullRepresentation = function(flushEvents) 41 41 { 42 42 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 43 43 … … 46 46 47 47 // Add some extra AI-specific data 48 48 state.events = this.events; 49 if (flushEvents) 50 { 51 state.events = []; 52 this.events = []; 53 } 49 54 50 55 // Add entity representations 51 56 Engine.ProfileStart("proxy representations"); … … 81 86 this.events.push({"type": "PlayerDefeated", "msg": msg}); 82 87 }; 83 88 89 AIInterface.prototype.OnGlobalEntityRenamed = function(msg) 90 { 91 this.events.push({"type": "EntityRenamed", "msg": msg}); 92 }; 93 84 94 Engine.RegisterComponentType(IID_AIInterface, "AIInterface", AIInterface); -
binaries/data/mods/public/simulation/components/SkirmishReplacer.js
55 55 var cmpReplacementOwnership = Engine.QueryInterface(replacement, IID_Ownership); 56 56 cmpReplacementOwnership.SetOwner(cmpCurOwnership.GetOwner()); 57 57 58 Engine.BroadcastMessage(MT_EntityRenamed, { entity: this.entity, newentity: replacement}); 58 59 Engine.DestroyEntity(this.entity); 59 60 }; 60 61 -
source/simulation2/components/CCmpAIManager.cpp
994 994 ENSURE(cmpAIInterface); 995 995 996 996 // Get the game state from AIInterface 997 CScriptVal state = cmpAIInterface->GetFullRepresentation( );997 CScriptVal state = cmpAIInterface->GetFullRepresentation(true); 998 998 999 999 // Get the passability data 1000 1000 Grid<u16> dummyGrid; -
source/simulation2/components/ICmpAIInterface.cpp
34 34 { 35 35 return m_Script.Call<CScriptVal> ("GetRepresentation"); 36 36 } 37 virtual CScriptVal GetFullRepresentation( )37 virtual CScriptVal GetFullRepresentation(bool flushEvents = false) 38 38 { 39 return m_Script.Call<CScriptVal> ("GetFullRepresentation" );39 return m_Script.Call<CScriptVal> ("GetFullRepresentation",flushEvents); 40 40 } 41 41 42 42 }; -
source/simulation2/components/ICmpAIInterface.h
32 32 * Returns a script object that represents the current world state, 33 33 * to be passed to AI scripts. No caching for initialization 34 34 */ 35 virtual CScriptVal GetFullRepresentation( ) = 0;35 virtual CScriptVal GetFullRepresentation(bool flushEvents) = 0; 36 36 37 37 DECLARE_INTERFACE_TYPE(AIInterface) 38 38 };