Ticket #2984: garrison.diff
File garrison.diff, 3.5 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/components/GarrisonHolder.js
296 296 */ 297 297 GarrisonHolder.prototype.Eject = function(entity, forced) 298 298 { 299 300 299 var entityIndex = this.entities.indexOf(entity); 301 300 // Error: invalid entity ID, usually it's already been ejected 302 301 if (entityIndex == -1) … … 632 631 this.Eject(msg.entity); 633 632 this.Garrison(msg.newentity); 634 633 } 634 635 if (!this.initGarrison) 636 return; 637 638 // update the pre-game garrison because of SkirmishReplacement 639 if (msg.entity == this.entity) 640 { 641 let cmpGarrisonHolder = Engine.QueryInterface(msg.newentity, IID_GarrisonHolder); 642 if (cmpGarrisonHolder) 643 cmpGarrisonHolder.initGarrison = this.initGarrison; 644 } 645 else 646 { 647 let entityIndex = this.initGarrison.indexOf(msg.entity); 648 if (entityIndex != -1) 649 this.initGarrison[entityIndex] = msg.newentity; 650 } 635 651 }; 636 652 637 653 … … 697 713 return false; 698 714 }; 699 715 716 /** 717 * Initialise the garrisoned units 718 */ 719 GarrisonHolder.prototype.OnGlobalInitGame = function(msg) 720 { 721 if (!this.initGarrison) 722 return; 723 724 for (let ent of this.initGarrison) 725 { 726 var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 727 if (!cmpUnitAI || !cmpUnitAI.CanGarrison(this.entity)) 728 continue; 729 this.Garrison(ent); 730 } 731 this.initGarrison = undefined; 732 }; 733 700 734 Engine.RegisterComponentType(IID_GarrisonHolder, "GarrisonHolder", GarrisonHolder); 701 735 -
binaries/data/mods/public/simulation/components/interfaces/GarrisonHolder.js
7 7 // Message of the form { "holder": this.entity, "unit" : unit } sent to the AlertRaiser 8 8 // which ordered the unit "unit" to garrison. 9 9 Engine.RegisterMessageType("UnitGarrisonedAfterAlert"); 10 11 // Message sent by InitGame for component map-dependent initialization 12 Engine.RegisterMessageType("InitGame"); -
binaries/data/mods/public/simulation/helpers/InitGame.js
18 18 19 19 function InitGame(settings) 20 20 { 21 // Map dependent initialisations of components (i.e. garrisoned units) 22 Engine.BroadcastMessage(MT_InitGame, {}); 23 21 24 // No settings when loading a map in Atlas, so do nothing 22 25 if (!settings) 23 26 return; -
binaries/data/mods/public/simulation/templates/skirmish/units/default_ship_trireme.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <Entity parent="template_unit_mechanical_ship_trireme"> 3 <Identity> 4 <Civ>skirm</Civ> 5 </Identity> 6 <SkirmishReplacer> 7 <general>units/{civ}_ship_trireme</general> 8 </SkirmishReplacer> 9 <VisualActor> 10 <Actor>structures/athenians/trireme.xml</Actor> 11 </VisualActor> 12 </Entity>