/// <summary> /// Adds a PlayerEntity to the PlayersByid, and PlayersByUid dictionary, also adds to the GridCell according to its position /// </summary> /// <param name="player">The PlayerEntity thats going to be added</param> public void Add(PlayerEntity player) { //player.SetId((ushort)(PlayersById.Count + 10000)); GetGridCellByPosition(player.Position).Add(player); PlayersByUid.TryAdd(player.Uid, player); PlayersById.TryAdd(player.Id, player); }
/// <summary> /// Sets the ID of the PlayerEntity based on the last added entity ID. /// Adds a PlayerEntity to the PlayersByid, and PlayersByUid dictionary, also adds to the GridCell according to its position /// </summary> /// <param name="player"></param> /// <param name="position"></param> public void Add(PlayerEntity player, Vector3 position) { player.SetId((ushort)(PlayersById.Count + 20000)); player.SetPositionWithoutGridCellCheck(position); GetGridCellByPosition(player.Position).Add(player); PlayersByUid.TryAdd(player.Uid, player); PlayersById.TryAdd(player.Id, player); }