Ticket #1807: garrison-v4.diff
File garrison-v4.diff, 23.0 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/gui/session/selection.js
59 59 continue; 60 60 61 61 var templateName = entState.template; 62 var template = GetTemplateData(templateName); 63 var key = template.selectionGroupName || templateName; 64 62 if (templateName && templateName.indexOf("&") != -1) 63 { 64 var key = templateName; // Garrisoned units have an extended template 65 } 66 else 67 { 68 var template = GetTemplateData(templateName); 69 var key = template.selectionGroupName || templateName; 70 } 71 65 72 if (this.groups[key]) 66 73 this.groups[key] += 1; 67 74 else -
binaries/data/mods/public/gui/session/utility_functions.js
62 62 "teamsLocked": playerState.teamsLocked, 63 63 "state": playerState.state, 64 64 "isAlly": playerState.isAlly, 65 "isMutualAlly": playerState.isMutualAlly, 65 66 "isNeutral": playerState.isNeutral, 66 67 "isEnemy": playerState.isEnemy, 67 68 "guid": undefined, // network guid for players controlled by hosts -
binaries/data/mods/public/gui/session/input.js
217 217 var playerState = simState.players[entState.player]; 218 218 var playerOwned = (targetState.player == entState.player); 219 219 var allyOwned = playerState.isAlly[targetState.player]; 220 var mutualAllyOwned = playerState.isMutualAlly[targetState.player]; 220 221 var enemyOwned = playerState.isEnemy[targetState.player]; 221 222 var gaiaOwned = (targetState.player == 0); 222 223 … … 225 226 226 227 // default to walking there 227 228 var data = {command: "walk"}; 228 if (targetState.garrisonHolder && playerOwned)229 if (targetState.garrisonHolder && (playerOwned || mutualAllyOwned)) 229 230 { 230 231 data.command = "garrison"; 231 232 data.target = target; … … 297 298 var playerState = simState.players[entState.player]; 298 299 var playerOwned = (targetState.player == entState.player); 299 300 var allyOwned = playerState.isAlly[targetState.player]; 301 var mutualAllyOwned = playerState.isMutualAlly[targetState.player]; 300 302 var neutralOwned = playerState.isNeutral[targetState.player]; 301 303 var enemyOwned = playerState.isEnemy[targetState.player]; 302 304 var gaiaOwned = (targetState.player == 0); … … 308 310 switch (action) 309 311 { 310 312 case "garrison": 311 if (hasClass(entState, "Unit") && targetState.garrisonHolder && playerOwned)313 if (hasClass(entState, "Unit") && targetState.garrisonHolder && (playerOwned || mutualAllyOwned)) 312 314 { 313 315 var allowedClasses = targetState.garrisonHolder.allowedClasses; 314 316 for each (var unitClass in entState.identity.classes) … … 1732 1734 var unitName = getEntityName(template); 1733 1735 1734 1736 var playerID = Engine.GetPlayerID(); 1737 var simState = Engine.GuiInterfaceCall("GetSimulationState"); 1738 1735 1739 if (entState.player == playerID || g_DevSettings.controlAll) 1736 1740 { 1737 1741 switch (commandName) … … 1780 1784 break; 1781 1785 } 1782 1786 } 1787 else if (simState.players[playerID].isMutualAlly[entState.player]) 1788 { 1789 switch (commandName) 1790 { 1791 case "garrison": 1792 inputState = INPUT_PRESELECTEDACTION; 1793 preSelectedAction = ACTION_GARRISON; 1794 break; 1795 default: 1796 break; 1797 } 1798 } 1783 1799 } 1784 1800 } 1785 1801 -
binaries/data/mods/public/gui/session/unit_commands.js
689 689 affordableMask.hidden = false; 690 690 affordableMask.sprite = "colour: 0 0 0 127"; 691 691 } 692 693 if (guiName == GARRISON) 694 { 695 var ents = garrisonGroups.getEntsByName(item); 696 var entplayer = GetEntityState(ents[0]).player; 697 button.sprite = "colour: " + g_Players[entplayer].color.r + " " + g_Players[entplayer].color.g + " " + g_Players[entplayer].color.b; 698 699 var player = Engine.GetPlayerID(); 700 if(player != unitEntState.player && !g_DevSettings.controlAll) 701 { 702 if (entplayer != player) 703 { 704 button.enabled = false; 705 grayscale = "grayscale:"; 706 } 707 } 708 } 692 709 693 710 icon.sprite = "stretched:" + grayscale + "session/portraits/" + template.icon; 694 711 … … 1003 1020 1004 1021 // If the selection is friendly units, add the command panels 1005 1022 var player = Engine.GetPlayerID(); 1023 // Get player state to check some constraints 1024 // e.g. presence of a hero or build limits 1025 var simState = Engine.GuiInterfaceCall("GetSimulationState"); 1026 var playerState = simState.players[player]; 1027 1006 1028 if (entState.player == player || g_DevSettings.controlAll) 1007 1029 { 1008 // Get player state to check some constraints1009 // e.g. presence of a hero or build limits1010 var simState = Engine.GuiInterfaceCall("GetSimulationState");1011 var playerState = simState.players[player];1012 1030 1013 1031 if (selection.length > 1) 1014 1032 setupUnitPanel(SELECTION, usedPanels, entState, playerState, g_Selection.groups.getTemplateNames(), … … 1024 1042 var groups = new EntityGroups(); 1025 1043 for (var i in selection) 1026 1044 { 1027 state = GetEntityState(selection[i]);1045 var state = GetEntityState(selection[i]); 1028 1046 if (state.garrisonHolder) 1029 1047 groups.add(state.garrisonHolder.entities) 1030 1048 } … … 1191 1209 supplementalDetailsPanel.hidden = false; 1192 1210 commandsPanel.hidden = false; 1193 1211 } 1212 else if (playerState.isMutualAlly[entState.player]) // owned by allied player 1213 { 1214 1215 if (entState.garrisonHolder) 1216 { 1217 var groups = new EntityGroups(); 1218 for (var i in selection) 1219 { 1220 var state = GetEntityState(selection[i]); 1221 if (state.garrisonHolder) 1222 groups.add(state.garrisonHolder.entities) 1223 } 1224 1225 setupUnitPanel(GARRISON, usedPanels, entState, playerState, groups.getTemplateNames(), 1226 function (item) { unloadTemplate(item); } ); 1227 1228 supplementalDetailsPanel.hidden = false; 1229 } 1230 else 1231 { 1232 supplementalDetailsPanel.hidden = true; 1233 } 1234 1235 commandsPanel.hidden = true; 1236 } 1194 1237 else // owned by another player 1195 1238 { 1196 1239 supplementalDetailsPanel.hidden = true; -
binaries/data/mods/public/simulation/ai/common-api-v3/entity.js
580 580 unloadAll: function() { 581 581 if (!this._template.GarrisonHolder) 582 582 return undefined; 583 Engine.PostCommand({"type": "unload-all ", "garrisonHolders": [this.id()]});583 Engine.PostCommand({"type": "unload-all-own", "garrisonHolders": [this.id()]}); 584 584 return this; 585 585 }, 586 586 -
binaries/data/mods/public/simulation/helpers/Player.js
214 214 if (cmpOwnership) 215 215 owner = cmpOwnership.GetOwner(); 216 216 217 // Figure out which player controls the foundation being built217 // Figure out which player controls the target entity 218 218 var targetOwner = 0; 219 219 var cmpOwnershipTarget = Engine.QueryInterface(target, IID_Ownership); 220 220 if (cmpOwnershipTarget) … … 231 231 } 232 232 233 233 /** 234 * Returns true if the entity 'target' is owned by a mutual ally of 235 * the owner of 'entity'. 236 */ 237 function IsOwnedByMutualAllyOfEntity(entity, target) 238 { 239 // Figure out which player controls us 240 var owner = 0; 241 var cmpOwnership = Engine.QueryInterface(entity, IID_Ownership); 242 if (cmpOwnership) 243 owner = cmpOwnership.GetOwner(); 244 245 // Figure out which player controls the target entity 246 var targetOwner = 0; 247 var cmpOwnershipTarget = Engine.QueryInterface(target, IID_Ownership); 248 if (cmpOwnershipTarget) 249 targetOwner = cmpOwnershipTarget.GetOwner(); 250 251 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 252 var cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(owner), IID_Player); 253 254 // Check for allied diplomacy status 255 if (cmpPlayer.IsMutualAlly(targetOwner)) 256 return true; 257 258 return false; 259 } 260 261 /** 234 262 * Returns true if the entity 'target' is owned by player 235 263 */ 236 264 function IsOwnedByPlayer(player, target) … … 269 297 } 270 298 271 299 /** 300 * Returns true if the entity 'target' is owned by a mutual ally of player 301 */ 302 function IsOwnedByMutualAllyOfPlayer(player, target) 303 { 304 var targetOwner = 0; 305 var cmpOwnershipTarget = Engine.QueryInterface(target, IID_Ownership); 306 if (cmpOwnershipTarget) 307 targetOwner = cmpOwnershipTarget.GetOwner(); 308 309 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 310 var cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(player), IID_Player); 311 312 // Check for allied diplomacy status 313 if (cmpPlayer.IsMutualAlly(targetOwner)) 314 return true; 315 316 return false; 317 } 318 319 /** 272 320 * Returns true if the entity 'target' is owned by someone neutral to player 273 321 */ 274 322 function IsOwnedByNeutralOfPlayer(player,target) … … 312 360 Engine.RegisterGlobal("QueryOwnerInterface", QueryOwnerInterface); 313 361 Engine.RegisterGlobal("QueryPlayerIDInterface", QueryPlayerIDInterface); 314 362 Engine.RegisterGlobal("IsOwnedByAllyOfEntity", IsOwnedByAllyOfEntity); 363 Engine.RegisterGlobal("IsOwnedByMutualAllyOfEntity", IsOwnedByMutualAllyOfEntity); 315 364 Engine.RegisterGlobal("IsOwnedByPlayer", IsOwnedByPlayer); 316 365 Engine.RegisterGlobal("IsOwnedByGaia", IsOwnedByGaia); 317 366 Engine.RegisterGlobal("IsOwnedByAllyOfPlayer", IsOwnedByAllyOfPlayer); 367 Engine.RegisterGlobal("IsOwnedByMutualAllyOfPlayer", IsOwnedByMutualAllyOfPlayer); 318 368 Engine.RegisterGlobal("IsOwnedByNeutralOfPlayer", IsOwnedByNeutralOfPlayer); 319 369 Engine.RegisterGlobal("IsOwnedByEnemyOfPlayer", IsOwnedByEnemyOfPlayer); -
binaries/data/mods/public/simulation/helpers/Commands.js
314 314 break; 315 315 316 316 case "garrison": 317 // Verify that the building can be controlled by the player 318 if (CanControlUnit (cmd.target, player, controlAllUnits))317 // Verify that the building can be controlled by the player or is mutualAlly 318 if (CanControlUnitOrIsAlly(cmd.target, player, controlAllUnits)) 319 319 { 320 320 var entities = FilterEntityList(cmd.entities, player, controlAllUnits); 321 321 GetFormationUnitAIs(entities, player).forEach(function(cmpUnitAI) { … … 336 336 break; 337 337 338 338 case "unload": 339 // Verify that the building can be controlled by the player 340 if (CanControlUnit (cmd.garrisonHolder, player, controlAllUnits))339 // Verify that the building can be controlled by the player or is mutualAlly 340 if (CanControlUnitOrIsAlly(cmd.garrisonHolder, player, controlAllUnits)) 341 341 { 342 342 var cmpGarrisonHolder = Engine.QueryInterface(cmd.garrisonHolder, IID_GarrisonHolder); 343 343 var notUngarrisoned = 0; 344 for each (ent in cmd.entities) 344 if (IsOwnedByPlayer(player, cmd.garrisonHolder)) 345 var entities = cmd.entities; 346 else 347 var entities = FilterEntityList(cmd.entities, player, controlAllUnits); 348 349 for each (var ent in entities) 345 350 if (!cmpGarrisonHolder || !cmpGarrisonHolder.Unload(ent)) 346 351 notUngarrisoned++; 347 352 … … 355 360 break; 356 361 357 362 case "unload-template": 363 var index = cmd.template.indexOf("&"); // Templates for garrisoned units are extended 364 if (index == -1) 365 break; 366 var selected = FilterEntityListWithAllies(cmd.garrisonHolders, player, controlAllUnits); 367 for each (var garrisonHolder in selected) 368 { 369 var cmpGarrisonHolder = Engine.QueryInterface(garrisonHolder, IID_GarrisonHolder); 370 if (cmpGarrisonHolder) 371 { 372 // Only the owner of the garrisonHolder may unload entities from any owners 373 if (!IsOwnedByPlayer(player, garrisonHolder) && !controlAllUnits) 374 { 375 if (player != +(cmd.template.slice(1,index))) 376 continue; 377 } 378 if (!cmpGarrisonHolder.UnloadTemplate(cmd.template, cmd.all)) 379 notifyUnloadFailure(player, garrisonHolder); 380 } 381 } 382 break; 383 384 case "unload-all-own": 358 385 var selected = FilterEntityList(cmd.garrisonHolders, player, controlAllUnits); 359 386 for each (var garrisonHolder in selected) 360 387 { 361 388 var cmpGarrisonHolder = Engine.QueryInterface(garrisonHolder, IID_GarrisonHolder); 362 if (!cmpGarrisonHolder || !cmpGarrisonHolder.Unload Template(cmd.template, cmd.all))389 if (!cmpGarrisonHolder || !cmpGarrisonHolder.UnloadAllOwn()) 363 390 notifyUnloadFailure(player, garrisonHolder) 364 391 } 365 392 break; … … 1272 1299 1273 1300 /** 1274 1301 * Check if player can control this entity 1275 * returns: true if the entity is valid and owned by the player if1276 * or control all units is activated for the player, else false1302 * returns: true if the entity is valid and owned by the player 1303 * or control all units is activated, else false 1277 1304 */ 1278 1305 function CanControlUnit(entity, player, controlAll) 1279 1306 { … … 1281 1308 } 1282 1309 1283 1310 /** 1311 * Check if player can control this entity 1312 * returns: true if the entity is valid and owned by the player 1313 * or the entity is owned by an mutualAlly 1314 * or control all units is activated, else false 1315 */ 1316 function CanControlUnitOrIsAlly(entity, player, controlAll) 1317 { 1318 return (IsOwnedByPlayer(player, entity) || IsOwnedByMutualAllyOfPlayer(player, entity) || controlAll); 1319 } 1320 1321 /** 1284 1322 * Filter entities which the player can control 1285 1323 */ 1286 1324 function FilterEntityList(entities, player, controlAll) … … 1289 1327 } 1290 1328 1291 1329 /** 1330 * Filter entities which the player can control or are mutualAlly 1331 */ 1332 function FilterEntityListWithAllies(entities, player, controlAll) 1333 { 1334 return entities.filter(function(ent) { return CanControlUnitOrIsAlly(ent, player, controlAll);} ); 1335 } 1336 1337 /** 1292 1338 * Try to transform a wall to a gate 1293 1339 */ 1294 1340 function TryTransformWallToGate(ent, cmpPlayer, template) -
binaries/data/mods/public/simulation/components/GuiInterface.js
64 64 65 65 // store player ally/neutral/enemy data as arrays 66 66 var allies = []; 67 var mutualAllies = []; 67 68 var neutrals = []; 68 69 var enemies = []; 69 70 for (var j = 0; j < n; ++j) 70 71 { 71 72 allies[j] = cmpPlayer.IsAlly(j); 73 mutualAllies[j] = cmpPlayer.IsMutualAlly(j); 72 74 neutrals[j] = cmpPlayer.IsNeutral(j); 73 75 enemies[j] = cmpPlayer.IsEnemy(j); 74 76 } … … 86 88 "teamsLocked": cmpPlayer.GetLockTeams(), 87 89 "phase": phase, 88 90 "isAlly": allies, 91 "isMutualAlly": mutualAllies, 89 92 "isNeutral": neutrals, 90 93 "isEnemy": enemies, 91 94 "entityLimits": cmpPlayerEntityLimits.GetLimits(), … … 313 316 "state": cmpUnitAI.GetCurrentState(), 314 317 "orders": cmpUnitAI.GetOrders(), 315 318 }; 319 // Special extended template for garrisoned units 320 if (cmpUnitAI.isGarrisoned && ret.player) 321 ret.template = "p" + ret.player + "&" + ret.template; 316 322 } 317 323 318 324 var cmpGate = Engine.QueryInterface(ent, IID_Gate); … … 344 350 return ret; 345 351 }; 346 352 347 GuiInterface.prototype.GetTemplateData = function(player, name)353 GuiInterface.prototype.GetTemplateData = function(player, extendedName) 348 354 { 355 var name = extendedName; 356 // Special case for garrisoned units which have a extended template 357 if (extendedName.indexOf("&") != -1) 358 name = extendedName.slice(extendedName.indexOf("&")+1); 359 349 360 var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 350 361 var template = cmpTemplateManager.GetTemplate(name); 351 362 … … 522 533 return ret; 523 534 }; 524 535 525 GuiInterface.prototype.GetTechnologyData = function(player, name)536 GuiInterface.prototype.GetTechnologyData = function(player, extendedName) 526 537 { 538 var name = extendedName; 539 // Special case for garrisoned units which have an extended template 540 // (does not need technology for now, but we never know) 541 if (extendedName.indexOf("&") != -1) 542 name = extendedName.slice(extendedName.indexOf("&")+1); 543 527 544 var cmpTechTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager); 528 545 var template = cmpTechTempMan.GetTemplate(name); 529 546 -
binaries/data/mods/public/simulation/components/UnitAI.js
4247 4247 if (!cmpGarrisonHolder) 4248 4248 return false; 4249 4249 4250 // Verify that the target is owned by this entity's player 4250 // Verify that the target is owned by this entity's player or is mutual allied 4251 4251 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 4252 if (!cmpOwnership || ! IsOwnedByPlayer(cmpOwnership.GetOwner(), target))4252 if (!cmpOwnership || !(IsOwnedByPlayer(cmpOwnership.GetOwner(), target) || IsOwnedByMutualAllyOfPlayer(cmpOwnership.GetOwner(), target))) 4253 4253 return false; 4254 4254 4255 4255 // Don't let animals garrison for now -
binaries/data/mods/public/simulation/components/Player.js
351 351 352 352 var sharedLos = []; 353 353 for (var i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i) 354 if (this.IsAlly(i)) 355 { 356 var cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(i), IID_Player); 357 if (cmpPlayer && cmpPlayer.IsAlly(this.playerID)) 358 sharedLos.push(i); 359 } 354 if (this.IsMutualAlly(i)) 355 sharedLos.push(i); 360 356 361 357 cmpRangeManager.SetSharedLos(this.playerID, sharedLos); 362 358 }; … … 424 420 return this.diplomacy[id] > 0; 425 421 }; 426 422 423 /** 424 * Check if given player is our ally, and we are its ally 425 */ 426 Player.prototype.IsMutualAlly = function(id) 427 { 428 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 429 if (!cmpPlayerManager) 430 return false; 431 var cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(id), IID_Player); 432 return this.IsAlly(id) && cmpPlayer && cmpPlayer.IsAlly(this.playerID); 433 }; 434 427 435 Player.prototype.SetEnemy = function(id) 428 436 { 429 437 this.SetDiplomacyIndex(id, -1); -
binaries/data/mods/public/simulation/components/GarrisonHolder.js
220 220 }; 221 221 222 222 /** 223 * Perform Eject on the selected entities 224 */ 225 GarrisonHolder.prototype.PerformEject = function(entities, forced) 226 { 227 var ejectedEntities = []; 228 var success = true; 229 for each (var entity in entities) 230 { 231 if (this.Eject(entity, forced)) 232 { 233 ejectedEntities.push(entity); 234 } 235 else 236 { 237 success = false; 238 } 239 } 240 241 this.OrderWalkToRallyPoint(ejectedEntities); 242 this.UpdateGarrisonFlag(); 243 244 return success; 245 }; 246 247 /** 223 248 * Unload units from the garrisoning entity and order them 224 249 * to move to the Rally Point 225 250 * Returns true if successful, false if not 226 251 */ 227 252 GarrisonHolder.prototype.Unload = function(entity, forced) 228 253 { 229 if (this.Eject(entity, forced)) 230 { 231 this.OrderWalkToRallyPoint([entity]); 232 this.UpdateGarrisonFlag(); 233 return true; 234 } 235 236 return false; 254 return this.PerformEject([entity], forced); 237 255 }; 238 256 239 257 /** 240 * Unload one or all units that match a template from the258 * Unload one or all units that match a template/owner from the 241 259 * garrisoning entity and order them to move to the Rally Point 242 260 * Returns true if successful, false if not 243 261 */ 244 GarrisonHolder.prototype.UnloadTemplate = function( template, all, forced)262 GarrisonHolder.prototype.UnloadTemplate = function(extendedTemplate, all, forced) 245 263 { 246 var ejectedEntities = []; 247 var success = true; 264 var index = extendedTemplate.indexOf("&"); 265 if (index == -1) 266 return false; 267 var owner = extendedTemplate.slice(1,index); 268 var template = extendedTemplate.slice(index+1); 269 270 var entities = []; 248 271 for (var i = 0; i < this.entities.length; ++i) 249 272 { 250 273 var entity = this.entities[i]; … … 260 283 261 284 if (name != template) 262 285 continue; 286 if (owner != Engine.QueryInterface(entity, IID_Ownership).GetOwner()) 287 continue; 263 288 264 if (this.Eject(entity, forced)) 265 { 266 --i; // Decrement 'i' as Eject() shortens the array. 267 ejectedEntities.push(entity); 289 entities.push(entity); 268 290 269 // If 'all' is false, only ungarrison the first matched unit. 270 if (!all) 271 break; 272 } 273 else 274 success = false; 291 // If 'all' is false, only ungarrison the first matched unit. 292 if (!all) 293 break; 275 294 } 276 295 277 this.OrderWalkToRallyPoint(ejectedEntities); 278 this.UpdateGarrisonFlag(); 279 280 return success; 296 return this.PerformEject(entities, forced); 281 297 }; 282 298 283 299 /** 284 * Unload all units fromthe entity300 * Unload all units with same owner than the entity 285 301 * Returns true if all successful, false if not 286 302 */ 287 GarrisonHolder.prototype.UnloadAll = function(forced)303 GarrisonHolder.prototype.UnloadAllOwn = function(forced) 288 304 { 305 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 306 if (!cmpOwnership) 307 return false; 308 var owner = cmpOwnership.GetOwner(); 309 289 310 // Make copy of entity list 290 311 var entities = []; 291 312 for each (var entity in this.entities) 292 313 { 293 entities.push(entity); 314 var cmpOwnership = Engine.QueryInterface(entity, IID_Ownership); 315 if (cmpOwnership && cmpOwnership.GetOwner() == owner) 316 entities.push(entity); 294 317 } 295 318 296 var ejectedEntities = []; 297 var success = true; 298 for each (var entity in entities) 299 { 300 if (this.Eject(entity, forced)) 301 { 302 ejectedEntities.push(entity); 303 } 304 else 305 { 306 success = false; 307 } 308 } 309 310 this.OrderWalkToRallyPoint(ejectedEntities); 311 this.UpdateGarrisonFlag(); 312 313 return success; 319 return this.PerformEject(entities, forced); 314 320 }; 315 321 316 322 /** 323 * Unload all units from the entity 324 * Returns true if all successful, false if not 325 */ 326 GarrisonHolder.prototype.UnloadAll = function(forced) 327 { 328 var entities = this.entities.slice(0); 329 return this.PerformEject(entities, forced); 330 }; 331 332 /** 317 333 * Used to check if the garrisoning entity's health has fallen below 318 334 * a certain limit after which all garrisoned units are unloaded 319 335 */ … … 469 485 } 470 486 }; 471 487 488 489 /** 490 * Eject all foreign garrisoned entities which are no more allied 491 */ 492 GarrisonHolder.prototype.OnDiplomacyChanged = function() 493 { 494 for (var i = this.entities.length; i > 0; --i) 495 { 496 if (!IsOwnedByMutualAllyOfEntity(this.entity, this.entities[i-1])) 497 this.Eject(this.entities[i-1], true); 498 } 499 this.UpdateGarrisonFlag(); 500 }; 501 472 502 Engine.RegisterComponentType(IID_GarrisonHolder, "GarrisonHolder", GarrisonHolder); 473 503