Example #1
0
        public void Initalize()
        {
            Console.WriteLine("Firing up engine...");

#if DEV_MODE
            string rootPath = AppDomain.CurrentDomain.BaseDirectory + "../../";
#else
            string rootPath = AppDomain.CurrentDomain.BaseDirectory;
#endif

            Engine.Initialize(rootPath);

            Console.WriteLine("Initalizing server...");

            Console.WriteLine("Loading server settings...");
            Settings.Initalize();

            Engine.Services.Get <Logger>().SuppressErrors = Settings.SuppressErrors;

            // Point the logger towards the current directory
            Engine.Services.Get <Logger>().LogPath = Constants.FILEPATH_LOGS;

            Engine.Services.Get <Logger>().Start();

            Console.WriteLine($"Log output set to: {Engine.Services.Get<Logger>().LogPath} with error suppression {(Engine.Services.Get<Logger>().SuppressErrors ? "on" : "off")}.");

            Console.WriteLine("Checking file integrity...");
            this.CheckFileIntegrity();

            Engine.Services.Register(new ScriptManager(Constants.FILEPATH_SCRIPTS, Settings.IronPythonLibsDirectory));

            var netHandler = new NetHandler(Settings.GameName, Settings.ServerPort);
            Engine.Services.Register(netHandler);
            netHandler.Initalize();
            Packet.Initalize(netHandler);

            // Register the data loader factories
            IDataManagerFactory dataFactory = new FSDataFactory();
            Engine.Services.RegisterAs(dataFactory, typeof(IDataManagerFactory));
            dataFactory.Initalize();

            // Create and initalize the game content managers.
            var itemManager = new ItemManager();
            Engine.Services.Register(itemManager);
            itemManager.Initalize();

            var classManager = new ClassManager();
            Engine.Services.Register(classManager);
            classManager.Initalize();

            var npcManager = new NPCManager();
            Engine.Services.Register(npcManager);
            npcManager.Initalize();

            var mapManager = new MapManager();
            Engine.Services.Register(mapManager);
            mapManager.Initalize();

            var worldManager = new WorldManager(netHandler);
            Engine.Services.Register(worldManager);
            worldManager.Initalize();

            var playerManager = new PlayerManager();
            Engine.Services.Register(playerManager);
            playerManager.Initalize();

            var dialogueManager = new DialogueManager();
            Engine.Services.Register(dialogueManager);
            dialogueManager.Initalize();

            var gameEventListener = new GameEventListener();
            Engine.Services.Register(gameEventListener);
            gameEventListener.Initalize();

            var pluginManager = new PluginManager();
            pluginManager.Initalize();
            Engine.Services.Register(pluginManager);

            CommandHandler commandHandler = new CommandHandler(netHandler);
            Engine.Services.Register(commandHandler);
            commandHandler.Initalize();

            _webCommunicator = new WebCommunicator();

            //WebCommunicator.SendUDP("127.0.0.1", 41181, WebCommunicator.MessageTypes.Status_Updates, "");
        }