Ykkrosh
4fed9b8242
Merge from 22b478ffed8d. Pure scripted interface definitions. Entity creation from scripts. Improved messaging system. Messages on entity deletion. Basic player entities. Player ownership. Bug fixes. This was SVN commit r7281.
28 lines
639 B
JavaScript
28 lines
639 B
JavaScript
function PlayerManager() {}
|
|
|
|
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);
|