Exemplo n.º 1
0
 public ControlPlaneServerController(
     ILogger logger,
     PlayerConnectionManager playerConnections,
     OutgoingServerChannel channelOutgoing,
     GameWorlds worlds)
 {
     this._logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     this._playerConnections = playerConnections ?? throw new ArgumentNullException(nameof(playerConnections));
     this._channelOutgoing   = channelOutgoing ?? throw new ArgumentNullException(nameof(channelOutgoing));
     this._worlds            = worlds ?? throw new ArgumentNullException(nameof(worlds));
 }
Exemplo n.º 2
0
        public GameWorlds(
            ILogger logger,
            IServerConfig serverConfig,
            OutgoingServerChannel channelManager,
            int capacity)
        {
            this._logger       = logger ?? throw new ArgumentNullException(nameof(logger));
            this._serverConfig = serverConfig ?? throw new ArgumentNullException(nameof(serverConfig));

            this._worldInstances = new List <GameWorldThread>(capacity);
            this._nextInstanceId = 1;
        }
Exemplo n.º 3
0
 public GameWorldFactory(
     WorldType worldType,
     ILogger logger,
     IServerConfig serverConfig,
     OutgoingServerChannel channelManager,
     IGameWorldLoader loader)
 {
     this._worldType      = worldType;
     this._logger         = logger ?? throw new ArgumentNullException(nameof(logger));
     this._serverConfig   = serverConfig ?? throw new ArgumentNullException(nameof(serverConfig));
     this._channelManager = channelManager ?? throw new ArgumentNullException(nameof(channelManager));
     this._worldLoader    = loader ?? throw new ArgumentNullException(nameof(loader));
 }
Exemplo n.º 4
0
        public GameWorld(
            WorldType worldType,
            WorldInstanceId id,
            ILogger logger,
            IServerConfig config,
            OutgoingServerChannel channelManager,
            IGameWorldLoader gameWorldLoader)
        {
            this.WorldType  = worldType;
            this.InstanceId = id;
            this._logger    = logger ?? throw new ArgumentNullException(nameof(logger));
            this._isStopped = false;
            this._world     = new World(config.Ecs);

            this._fixedTick = config.Simulation.FixedTick;

            this._channelManager = channelManager ?? throw new ArgumentNullException(nameof(channelManager));

            this._simulationSynchronizer = new SimulationSynchronizer(this._world);
            this._entityGridMap          = new EntityGridMap(config.Replication.GridSize);

            this._players = new WorldPlayers(
                config.Replication,
                config.PlayerInput,
                config.PlayerConnection.Capacity.InitialConnectionsCapacity);

            this._replicationManager = new WorldReplicationManager(config.Replication, this._players, this._entityGridMap);

            this._physicsWorld = new VolatilePhysicsWorld(config.Replication.PhysicsHistoryCount);

            this._systems =
                new Systems(this._world)
                .Add(new PhysicsSystem())
                .Add(new ServerEntityReplicationSystem())
                .Add(new JiggleSystem())
                .Inject(this._physicsWorld)
                .Inject(new ReplicationDataBroker(config.Replication.Capacity, this._replicationManager))
                .Inject(this._entityGridMap);

            this._simulation = new ServerSimulation <InputComponent>(
                config.Simulation,
                this._world,
                this._systems);

            this._simulation.Create();

            gameWorldLoader.LoadWorld(this.WorldType, this._world, this._physicsWorld);
        }
Exemplo n.º 5
0
        public GameServer(
            IServerConfig serverConfig,
            ILogger logger)
        {
            this._serverConfig = serverConfig ?? throw new ArgumentNullException(nameof(serverConfig));
            this._logger       = logger ?? throw new ArgumentNullException(nameof(logger));

            this.Commander = new GameServerCommander(this);

            this._udpTransport = new ServerUdpPacketTransport(
                this._logger,
                serverConfig.NetworkTransport.PacketEncryptor,
                serverConfig.NetworkTransport,
                serverConfig.UdpServer);
            this._outgoingChannel = new OutgoingServerChannel(
                serverConfig.NetworkTransport,
                this._udpTransport,
                serverConfig.NetworkTransport.PacketEncryptor,
                this._logger);

            this._playerConnectionManager = new PlayerConnectionManager(
                this._logger,
                this._serverConfig.PlayerConnection);

            this._gameWorlds = new GameWorlds(
                this._logger,
                this._serverConfig,
                this._outgoingChannel,
                serverConfig.Server.WorldsCapacity);

            this._incomingChannel = new IncomingServerChannel(
                this._udpTransport,
                serverConfig.NetworkTransport.PacketEncryptor,
                new ControlPlaneServerController(
                    this._logger,
                    this._playerConnectionManager,
                    this._outgoingChannel,
                    this._gameWorlds),
                new SimulationServerController(
                    this._logger,
                    this._playerConnectionManager,
                    this._gameWorlds),
                this._logger);

            this._worldLoader = new GameWorldLoader();
        }