Example #1
0
        public async void Start()
        {
            Config.Config config = ServiceProvider.GetService <Config.Config>();
            await config.Initialise();

            await ServiceProvider.GetService <PreReqValidation>().Initialise();

            CharTemplateTable.Initialize();

            // TODO: refactor NetworkBlock
            NetworkBlock.Instance.Initialize();
            GameTime.Initialize();

            await ServiceProvider.GetService <IdFactory>().Initialise();

            L2World.Initialize();

            MapRegionTable.Initialize();
            ZoneTable.Initialize();

            await ServiceProvider.GetService <ItemTable>().Initialise();

            ItemHandler.Initialize();

            NpcTable.Initialize();
            Capsule.Initialize();
            AttackStanceManager.Initialize();
            BlowFishKeygen.GenerateKeys();

            await ServiceProvider.GetService <IAdminCommandHandler>().Initialise();

            await ServiceProvider.GetService <AnnouncementManager>().Initialise();

            StaticObjTable.Initialize();
            await ServiceProvider.GetService <SpawnTable>().Initialise();

            await ServiceProvider.GetService <HtmCache>().Initialise();

            // TODO: review plugin system
            //PluginManager.Instance.Initialize(this);

            ServiceProvider.GetService <AuthThread>().Initialise();

            _listener = new TcpListener(IPAddress.Any, config.ServerConfig.Port);

            try
            {
                _listener.Start();
            }
            catch (SocketException ex)
            {
                Log.Halt($"Socket Error: '{ex.SocketErrorCode}'. Message: '{ex.Message}' (Error Code: '{ex.NativeErrorCode}')");
            }

            Log.Info($"Listening Gameservers on port {config.ServerConfig.Port}");

            Task.Factory.StartNew(WaitForClients);
        }
Example #2
0
        public async void StartAutoAttack()
        {
            if (_character is L2Player)
            {
                if (!IsInAttackStance)
                {
                    await _character.BroadcastPacketAsync(new AutoAttackStart(_character.ObjectId));
                }

                AttackStanceManager.SetAttackStance((L2Player)_character);
                IsInAttackStance = true;
            }
        }