示例#1
0
        public Server(Configuration configuration, GameCore game, bool openOnInit = true, ILogger logger = null)
        {
            if (configuration.Port == 0)
            {
                configuration.Port = 33132;
            }
            MessageProcessor = new ServerNetworkProcessor(this);
            MessageProcessor.OnMessageSentOrDiscarded += (a, b) => MessagePool.Release(b);
            GameInstance = new NetworkedGame(FullGameState.Create(game), logger, game.Settings);
            HookEvents();
            SetGame(game);

            Logger        = logger != null ? (ILogger) new ModuleLogger(logger, "Server") : new NullLogger();
            Login         = new LoginManager(this);
            Connections   = new ConnectionManager(this);
            Configuration = new InitializedConfiguration(configuration);
            Timers        = new Engine.Core.Timing.Timer.Factory();
            ChatHandler   = new Chat.ChatServer(this);

            Logger.Info($"Server Created.");
            if (openOnInit)
            {
                Open();
            }
        }
示例#2
0
        public void SetGame(GameCore game)
        {
            GameStartRemainingTimeout     = ServerSettings.Instance.TimeToWaitForPlayersReady;
            _disablePropertyNotifications = true;
            foreach (var player in Players)
            {
                player.Player.Tank        = null;
                player.Player.IsSpectator = false;
                //Clear existing attributes from the player object
                player.Player.SelectedTankReflectionName = null;
                player.Player.SpawnPoint       = Vector2.Zero;
                player.Player.Team             = null;
                player.Player.AllowedTankTypes = null;

                player.Player.IsReady = false;
                game.AddPlayer(player.Player);
            }
            _disablePropertyNotifications = false;
            GameInstance.FullGameState    = FullGameState.Create(game);
            Game.Authoritative            = true;
        }
 public FullGameStateSentAction(GameCore game)
 {
     State = FullGameState.Create(game); EngineSettings = game.Settings;
 }