historic_bruno
27e5581d27
Fixes object panel not being notified of map loading. Fixes bug where opening a new map before using the player panel prevented default player data being displayed for new players. Fixes wxGTK 2.8 bug: wxChoicebook control doesn't update the choice control when adding/removing pages. Notifies player that deleting player in Atlas will delete all their objects (and gives them the option). Changes DeleteObject to DeleteObjects to support multiple selections. Implements undo for map resize (experimental). Removes annoying debug message from attempted undo of map settings. Tweaks a few Atlas UI controls. This was SVN commit r10064.
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
function PlayerManager() {}
|
|
|
|
PlayerManager.prototype.Schema =
|
|
"<a:component type='system'/><empty/>";
|
|
|
|
PlayerManager.prototype.Init = function()
|
|
{
|
|
this.playerEntities = []; // list of player entity IDs
|
|
};
|
|
|
|
PlayerManager.prototype.AddPlayer = function(ent)
|
|
{
|
|
var id = this.playerEntities.length;
|
|
Engine.QueryInterface(ent, IID_Player).SetPlayerID(id);
|
|
this.playerEntities.push(ent);
|
|
return id;
|
|
};
|
|
|
|
/**
|
|
* Returns the player entity ID for the given player ID.
|
|
* The player ID must be valid (else there will be an error message).
|
|
*/
|
|
PlayerManager.prototype.GetPlayerByID = function(id)
|
|
{
|
|
if (id in this.playerEntities)
|
|
return this.playerEntities[id];
|
|
|
|
var stack = new Error().stack.trimRight().replace(/^/mg, ' '); // indent each line
|
|
warn("GetPlayerByID: no player defined for id '"+id+"'\n"+stack);
|
|
|
|
return INVALID_ENTITY;
|
|
};
|
|
|
|
PlayerManager.prototype.GetNumPlayers = function()
|
|
{
|
|
return this.playerEntities.length;
|
|
};
|
|
|
|
PlayerManager.prototype.RemoveAllPlayers = function()
|
|
{
|
|
// Destroy existing player entities
|
|
for each (id in this.playerEntities)
|
|
{
|
|
Engine.DestroyEntity(id);
|
|
}
|
|
this.playerEntities = [];
|
|
};
|
|
|
|
Engine.RegisterComponentType(IID_PlayerManager, "PlayerManager", PlayerManager);
|