1
0
forked from 0ad/0ad
0ad/binaries/data/mods/public/simulation/components/PlayerManager.js
Ykkrosh dd809f83e8 # Add documentation of the entity template XML file format.
Simplify the format a bit.
Use less <interleave> in the RNG so that error reports become
understandable.
Fixes #491.

This was SVN commit r7478.
2010-04-23 16:09:03 +00:00

31 lines
714 B
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;
};
PlayerManager.prototype.GetPlayerByID = function(id)
{
return this.playerEntities[id];
// TODO: report error message if invalid id
};
PlayerManager.prototype.GetNumPlayers = function()
{
return this.playerEntities.length;
};
Engine.RegisterComponentType(IID_PlayerManager, "PlayerManager", PlayerManager);