Ticket #3488: 3488.patch
File 3488.patch, 2.9 KB (added by , 9 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='VisibleGarrisonRestrictedClasses'>" + 50 "<text/>" + 51 "</element>" + 52 "</optional>" + 48 53 "</interleave>" + 49 54 "</element>" + 50 55 "</zeroOrMore>" + … … 72 77 o.x = +offset.X; 73 78 o.y = +offset.Y; 74 79 o.z = +offset.Z; 75 this.visibleGarrisonPoints.push({"offset":o, "entity": null });80 this.visibleGarrisonPoints.push({"offset":o, "entity": null,"restrictedClass" : offset.VisibleGarrisonRestrictedClasses}); 76 81 } 77 82 } 78 83 }; 79 84 80 85 /** 86 * Returns an array of restricted classes from the original string. 87 */ 88 GarrisonHolder.prototype.GetVisibleGarrisonRestrictedClasses = function(classList) 89 { 90 if (classList) 91 return classList.split(/\s+/); 92 return []; 93 }; 94 95 /** 81 96 * Return range at which entities can garrison here 82 97 */ 83 98 GarrisonHolder.prototype.GetLoadingRange = function() … … 100 115 return IsOwnedByPlayer(player, ent); 101 116 }; 102 117 103 104 118 /** 105 119 * Return the list of entities garrisoned inside 106 120 */ … … 221 235 }; 222 236 223 237 /** 238 * Returns true if the unit is allowed be visible on that garrison point, false otherwise. 239 */ 240 GarrisonHolder.prototype.AllowedToVisibleGarrisoning = function(visibleGarrisonPoint) 241 { 242 var restrictedClassesList = this.GetVisibleGarrisonRestrictedClasses(visibleGarrisonPoint.restrictedClass); 243 if (!allowedClasses) 244 return false; 245 246 for (let entityClasses of (Engine.QueryInterface(visibleGarrisonPoint.entity, IID_Identity)).GetClassesList()) 247 for (let restrictedClasses of restrictedClassesList) 248 if (entityClasses == restrictedClasses) 249 return false; 250 251 return true; 252 } 253 254 /** 224 255 * Garrison a unit inside. 225 256 * Returns true if successful, false if not 226 257 * The timer for AutoHeal is started here … … 249 280 250 281 if (visibleGarrisonPoint) 251 282 { 283 let IsAllowed = this.AllowedToVisibleGarrisoning(visibleGarrisonPoint); 252 284 visibleGarrisonPoint.entity = entity; 253 cmpPosition.SetTurretParent(this.entity, visibleGarrisonPoint.offset); 254 let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); 255 if (cmpUnitAI) 256 cmpUnitAI.SetTurretStance(); 285 286 if (IsAllowed) 287 { 288 cmpPosition.SetTurretParent(this.entity, visibleGarrisonPoint.offset); 289 let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI); 290 if (cmpUnitAI) 291 cmpUnitAI.SetTurretStance(); 292 } 293 else 294 { 295 cmpPosition.MoveOutOfWorld(); 296 } 257 297 } 258 298 else 259 299 cmpPosition.MoveOutOfWorld(); … … 713 753 } 714 754 }; 715 755 716 717 756 /** 718 757 * Eject all foreign garrisoned entities which are no more allied 719 758 */