public void Initialize(Address address, string blowfishKey, Config config) { _logger.LogCoreInfo("Loading Config."); Config = config; _gameScriptTimers = new List <GameScriptTimer>(); _chatCommandManager.LoadCommands(); _server = new Host(); _server.Create(address, 32, 32, 0, 0); var key = Convert.FromBase64String(blowfishKey); if (key.Length <= 0) { throw new InvalidKeyException("Invalid blowfish key supplied"); } Blowfish = new BlowFish(key); PacketHandlerManager = new PacketHandlerManager(_logger, Blowfish, _server, _playerManager, _packetHandlerProvider); ObjectManager = new ObjectManager(this); Map = new Map(this); PacketNotifier = new PacketNotifier(this, _playerManager, _networkIdManager); ApiFunctionManager.SetGame(this); ApiEventManager.SetGame(this); IsRunning = false; disconnectedPlayers = 0; _logger.LogCoreInfo("Loading C# Scripts"); LoadScripts(); Map.Init(); foreach (var p in Config.Players) { _playerManager.AddPlayer(p); } _pauseTimer = new Timer { AutoReset = true, Enabled = false, Interval = 1000 }; _pauseTimer.Elapsed += (sender, args) => PauseTimeLeft--; PauseTimeLeft = 30 * 60; // 30 minutes _logger.LogCoreInfo("Game is ready."); }
public void Initialize(ushort port, string blowfishKey, Config config) { _logger.Info("Loading Config."); Config = config; _gameScriptTimers = new List <GameScriptTimer>(); ChatCommandManager.LoadCommands(); ObjectManager = new ObjectManager(this); Map = new Map(this); ApiFunctionManager.SetGame(this); ApiEventManager.SetGame(this); IsRunning = false; _logger.Info("Loading C# Scripts"); LoadScripts(); Map.Init(); _logger.Info("Add players"); foreach (var p in Config.Players) { ((PlayerManager)PlayerManager).AddPlayer(p); } _pauseTimer = new Timer { AutoReset = true, Enabled = false, Interval = 1000 }; _pauseTimer.Elapsed += (sender, args) => PauseTimeLeft--; PauseTimeLeft = 30 * 60; // 30 minutes _packetServer = new PacketServer(); _packetServer.InitServer(port, blowfishKey, this); PacketNotifier = new PacketNotifier(_packetServer.PacketHandlerManager, Map.NavGrid); // TODO: make lib to only get API types and not byte[], start from removing this line PacketReader = new PacketReader(); _logger.Info("Game is ready."); }
public void Initialize(Config config, PacketServer server) { _logger.Info("Loading Config."); Config = config; _gameScriptTimers = new List <GameScriptTimer>(); ChatCommandManager.LoadCommands(); ObjectManager = new ObjectManager(this); Map = new Map(this); ApiFunctionManager.SetGame(this); ApiEventManager.SetGame(this); IsRunning = false; _logger.Info("Loading C# Scripts"); LoadScripts(); Map.Init(); _logger.Info("Add players"); foreach (var p in Config.Players) { ((PlayerManager)PlayerManager).AddPlayer(p); } _pauseTimer = new Timer { AutoReset = true, Enabled = false, Interval = 1000 }; _pauseTimer.Elapsed += (sender, args) => PauseTimeLeft--; PauseTimeLeft = 30 * 60; // 30 minutes // TODO: GameApp should send the Response/Request handlers _packetServer = server; // TODO: switch the notifier with ResponseHandler PacketNotifier = new PacketNotifier(_packetServer.PacketHandlerManager, Map.NavGrid); InitializePacketHandlers(); _logger.Info("Game is ready."); }