/// <summary>This is called when a player joins</summary> public void OnPlayerJoin(int id) { foreach (var item in Server.entities.Values) { ServerSend.SpawnEntity(item, id); } }
/// <summary>Needs to be called by the entity in order to be registered</summary> /// <param name="e">The entity to register</param> public void RegisterEntity(Entity e) { List <uint> keys = new List <uint>(Server.entities.Keys); //Get first free ID uint i; for (i = 0; i < keys.Count + 1; i++) { if (!keys.Contains(i)) { break; } } //Send an EntitySpawn packet to all e.id = i; ServerSend.SpawnEntity(e); //Add it to the server registry Server.entities.Add(i, e); }