mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-20 23:33:59 -07:00
Simplify the format a bit. Use less <interleave> in the RNG so that error reports become understandable. Fixes #491. This was SVN commit r7478.
30 lines
714 B
JavaScript
30 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);
|