Seamlessly change a player's entities to be Gaia-owned when resigning.
This was SVN commit r12316.
This commit is contained in:
parent
791752c7a4
commit
84305155de
@ -154,7 +154,6 @@ function resignGame()
|
||||
// Tell other players that we have given up and been defeated
|
||||
Engine.PostNetworkCommand({
|
||||
"type": "defeat-player",
|
||||
"destroy": true,
|
||||
"playerId": Engine.GetPlayerID()
|
||||
});
|
||||
|
||||
|
@ -388,31 +388,24 @@ Player.prototype.OnPlayerDefeated = function(msg)
|
||||
{
|
||||
this.state = "defeated";
|
||||
|
||||
// Reassign all player's entities to Gaia
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
var entities = cmpRangeManager.GetEntitiesByPlayer(this.playerID);
|
||||
if (msg.destroy)
|
||||
|
||||
// The ownership change is done in two steps so that entities don't hit idle
|
||||
// (and thus possibly look for "enemies" to attack) before nearby allies get
|
||||
// converted to Gaia as well.
|
||||
for each (var entity in entities)
|
||||
{
|
||||
// Destroy all of the player's entities.
|
||||
for each (var entity in entities)
|
||||
{
|
||||
var cmpHealth = Engine.QueryInterface(entity, IID_Health);
|
||||
if (cmpHealth)
|
||||
cmpHealth.Kill();
|
||||
else
|
||||
Engine.DestroyEntity(entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reassign all player's entities to Gaia
|
||||
for each (var entity in entities)
|
||||
{
|
||||
// Note: maybe we need to reassign units and buildings only?
|
||||
var cmpOwnership = Engine.QueryInterface(entity, IID_Ownership);
|
||||
cmpOwnership.SetOwner(0);
|
||||
}
|
||||
var cmpOwnership = Engine.QueryInterface(entity, IID_Ownership);
|
||||
cmpOwnership.SetOwnerQuiet(0);
|
||||
}
|
||||
|
||||
// With the real ownership change complete, send OwnershipChanged messages.
|
||||
for each (var entity in entities)
|
||||
Engine.PostMessage(entity, MT_OwnershipChanged, { "entity": entity,
|
||||
"from": this.playerID, "to": 0 });
|
||||
|
||||
// Reveal the map for this player.
|
||||
cmpRangeManager.SetLosRevealAll(this.playerID, true);
|
||||
|
||||
|
@ -257,7 +257,7 @@ function ProcessCommand(player, cmd)
|
||||
|
||||
case "defeat-player":
|
||||
// Send "OnPlayerDefeated" message to player
|
||||
Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": player, "destroy": cmd.destroy } );
|
||||
Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": player } );
|
||||
break;
|
||||
|
||||
case "garrison":
|
||||
|
Loading…
Reference in New Issue
Block a user