public TranslationTestCommand(
            IPositionScaleTranslation positionScaleTranslation)
        {
            this.IsCommand("test-position-translation", "Output various translations");

            this.m_PositionScaleTranslation = positionScaleTranslation;
        }
        public ClientChunkStateManager(
            IChunkOctreeFactory chunkOctreeFactory,
            IPositionScaleTranslation positionScaleTranslation,
            IPredeterminedChunkPositions predeterminedChunkPositions,
            MxClient client)
        {
            this.m_PositionScaleTranslation = positionScaleTranslation;
            this.m_PredeterminedChunkPositions = predeterminedChunkPositions;

            this.m_ClientHasChunkOctree = chunkOctreeFactory.CreateChunkOctree<ServerChunk>();
        }
Beispiel #3
0
        public TychaiaServerWorld(
            IServerEntityFactory serverEntityFactory,
            IServerFactory serverFactory,
            IPositionScaleTranslation positionScaleTranslation,
            IPredeterminedChunkPositions predeterminedChunkPositions,
            TychaiaServer server,
            ServerChunkManager serverChunkManager)
        {
            this.m_ServerEntityFactory = serverEntityFactory;
            this.m_ServerFactory = serverFactory;
            this.m_PositionScaleTranslation = positionScaleTranslation;
            this.m_PredeterminedChunkPositions = predeterminedChunkPositions;
            this.m_Server = server;
            this.m_ConnectedClients = new Dictionary<MxClient, ServerClientManager>();

            this.m_UniqueIDIncrementer = 1;

            // TODO: Move server chunk manager into entities list.
            this.m_ServerChunkManager = serverChunkManager;

            this.m_Server.ListenForMessage("user input", this.OnUserInput);

            this.m_Server.ListenForMessage(
                "join",
                (client, playerName) =>
                {
                    // The client will repeatedly send join messages until we confirm.
                    if (this.m_ConnectedClients.ContainsKey(client))
                    {
                        return;
                    }

                    var uniqueID = this.m_UniqueIDIncrementer++;

                    Console.WriteLine("Detected \"" + Encoding.ASCII.GetString(playerName) + "\" has joined");
                    this.m_Server.SendMessage("join confirm", BitConverter.GetBytes(uniqueID));
                    var manager = this.m_ServerFactory.CreateServerClientManager(
                        this,
                        this.m_Server,
                        uniqueID,
                        Encoding.ASCII.GetString(playerName),
                        client);
                    this.m_ConnectedClients.Add(
                        client,
                        manager);
                    this.AddPlayer(client, Encoding.ASCII.GetString(playerName));
                });

            server.ListenForMessage(
                "change name",
                (client, newPlayerName) =>
                {
                    // Check to make sure this client is joined.
                    if (!this.m_ConnectedClients.ContainsKey(client))
                    {
                        return;
                    }

                    var existingName = this.m_ConnectedClients[client].PlayerName;
                    var newName = Encoding.ASCII.GetString(newPlayerName);

                    this.m_ConnectedClients[client].PlayerName = newName;
                    Console.WriteLine("\"" + existingName + "\" has changed their name to \"" + newName + "\"");
                    this.ChangePlayerName(client, newName);
                });
        }