Ticket #3488: 3488.3.diff
File 3488.3.diff, 3.0 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/GarrisonHolder.js
45 45 "<element name='Z'>" + 46 46 "<data type='decimal'/>" + 47 47 "</element>" + 48 "<optional>" + 49 "<element name='VisibleGarrisonAllowedClasses'>" + 50 "<attribute name='datatype'>" + 51 "<value>tokens</value>" + 52 "</attribute>" + 53 "<text/>" + 54 "</element>" + 55 "</optional>" + 48 56 "</interleave>" + 49 57 "</element>" + 50 58 "</zeroOrMore>" + … … 72 80 o.x = +offset.X; 73 81 o.y = +offset.Y; 74 82 o.z = +offset.Z; 75 this.visibleGarrisonPoints.push({"offset":o, "entity": null });83 this.visibleGarrisonPoints.push({"offset":o, "entity": null,"allowedClass" : offset.VisibleGarrisonAllowedClasses}); 76 84 } 77 85 } 78 86 }; … … 100 108 return IsOwnedByPlayer(player, ent); 101 109 }; 102 110 103 104 111 /** 105 112 * Return the list of entities garrisoned inside 106 113 */ … … 203 210 return MatchesClassList(entityClasses, this.template.List._string); 204 211 }; 205 212 213 206 214 /** 215 * Returns true if the unit is allowed be visible on that garrison point, false otherwise. 216 */ 217 GarrisonHolder.prototype.AllowedToVisibleGarrisoning = function(visibleGarrisonPoint) 218 { 219 var allowedClassesList = visibleGarrisonPoint.allowedClass._string; 220 //If classlist is empty, everybody can garrison. 221 if (!allowedClassesList) 222 return true; 223 224 return MatchesClassList((Engine.QueryInterface(visibleGarrisonPoint.entity, IID_Identity)).GetClassesList(), allowedClassesList); 225 } 226 227 /** 207 228 * Garrison a unit inside. 208 229 * Returns true if successful, false if not 209 230 * The timer for AutoHeal is started here … … 229 250 break; 230 251 } 231 252 } 232 233 253 if (visibleGarrisonPoint) 234 254 { 235 255 visibleGarrisonPoint.entity = entity; 236 cmpPosition.SetTurretParent(this.entity, visibleGarrisonPoint.offset); 237 let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); 238 if (cmpUnitAI) 239 cmpUnitAI.SetTurretStance(); 256 257 if (this.AllowedToVisibleGarrisoning(visibleGarrisonPoint)) 258 { 259 cmpPosition.SetTurretParent(this.entity, visibleGarrisonPoint.offset); 260 let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); 261 if (cmpUnitAI) 262 cmpUnitAI.SetTurretStance(); 263 } 264 else 265 { 266 cmpPosition.MoveOutOfWorld(); 267 } 240 268 } 241 269 else 242 270 cmpPosition.MoveOutOfWorld(); 243 244 271 return true; 245 272 }; 246 273 … … 634 661 635 662 /** 636 663 * Update list of garrisoned entities if one gets renamed (e.g. by promotion) 664 * vgpEntity is only defined in some peculiar case where we want to reuse the same visibleGarrisonPoint, 665 * in case of promotion for example, and thus should always be allowed. 637 666 */ 638 667 GarrisonHolder.prototype.OnGlobalEntityRenamed = function(msg) 639 668 { … … 670 699 } 671 700 }; 672 701 673 674 702 /** 675 703 * Eject all foreign garrisoned entities which are no more allied 676 704 */