public void verifyClient(ClientConnection clientConnection) { if (clientExists(clientConnection.uniqueName)) { removePending(clientConnection); clientConnection.remove = true; println("Client \"" + clientConnection.uniqueName + "\" Already Connected, Denying New Client"); } else { println("Client Verified as \"" + clientConnection.uniqueName + "\""); pendingClients.Remove(clientConnection); println("Sending World to Client..."); clientConnection.entityId = nextEntityId; ServerEntity e = new ServerEntity(clientConnection.entityId, new Player(clientConnection.uniqueName, clientConnection.entityId)); worldManager.worlds[clientConnection.worldId].addNewEntity(e); ServerWorld w = worldManager.worlds[clientConnection.worldId]; PacketNewWorld pnw = new PacketNewWorld(new WorldData(clientConnection.worldId, w.width, w.height), w.wallGrid); sendPacket(clientConnection, pnw); PacketNewPlayer pnp = new PacketNewPlayer(clientConnection.uniqueName, clientConnection.worldId, e.X, e.Z, clientConnection.entityId); sendPacketToAll(pnp); sendPacket(clientConnection, pnp); foreach (ClientConnection cc in connectedClients.Values) { if (cc.entityId != clientConnection.entityId) { ServerEntity ee = worldManager.worlds[clientConnection.worldId].entityList[cc.entityId]; PacketNewPlayer p = new PacketNewPlayer(cc.uniqueName, cc.worldId, ee.X, ee.Z, cc.entityId); sendPacket(clientConnection, p); } } println("World and Player Sent to Client"); connectedClients.Add(clientConnection.uniqueName, clientConnection); clientConnection.verified = true; } }
public void addNewEntity(ServerEntity entity) { entityAddList.Add(entity); }