Example #1
0
        public GameServer GetHandlers()
        {
            try
            {
                GameServer server = (GameServer)GameState.ActiveState;

                if (server == null)
                {
                    return(null);
                }

                mainLog.Info("IRSE: Loaded GameServer Instance!");

                ControllerManager = server.Controllers;

                var universe = ControllerManager.Universe as Game.Server.UniverseController;

                mainLog.Info("IRSE: Waiting for Universe To Populate..");

                while (!universe.IsInitialized)
                {
                    Thread.Sleep(1000);
                    if (universe.IsInitialized)
                    {
                        break;
                    }
                }

                mainLog.Info("IRSE: Loading Handlers..");
                NetworkHandler = new NetworkHandler(ControllerManager);
                NetworkHandler.SetupNetworkHandler(server);

                PlayerHandler = new PlayerHandler(ControllerManager);
                PlayerHandler.SetupPlayerHandler(server);

                ChatHandler = new ChatHandler(ControllerManager);
                ChatHandler.SetupChatMessageHandler(NetworkHandler);

                UniverseHandler = new UniverseHandler(ControllerManager);
                UniverseHandler.SetupHandler(server);

                mainLog.Info("IRSE: Loaded Universe!");

                return(server);
            }
            catch (ArgumentException ex)
            {
                mainLog.Error("Failed to get handlers [Argument Exception] \r\n Exception:" + ex.ToString());
                return(null);
            }
            catch (Exception ex)
            {
                mainLog.Error("Failed to get handlers \r\n Exception: " + ex.ToString());
                return(null);
            }
        }
        public Object GetHandlers()
        {
            try
            {
                m_gameStateType = m_frameworkAssembly.GetType("Game.GameStates.GameState");
                PropertyInfo m_activeState = m_gameStateType.GetProperty("ActiveState");
                object       server        = m_activeState.GetValue(null);

                if (server == null)
                {
                    return(null);
                }

                mainLog.Info("IRSE: Loaded GameServer Instance!");

                FieldInfo m_controllerManagerField = server.GetType().GetField("m_controllers", BindingFlags.NonPublic | BindingFlags.Instance);

                m_controllerManager = m_controllerManagerField.GetValue(server) as Game.Server.ControllerManager;

                var universe = m_controllerManager.Universe as Game.Server.UniverseController;

                mainLog.Info("IRSE: Waiting for Universe To Populate..");

                // will be removed when they fix the ghost client spawner
                ServerInstance.Instance.SpawnGhostClients(m_controllerManager);

                while (m_controllerManager.Players.AllPlayers().Count() < 1)
                {
                    Thread.Sleep(1000);
                    if (m_controllerManager.Players.AllPlayers().Count() <= 1)
                    {
                        break;
                    }
                }

                mainLog.Info("IRSE: Loading Handlers..");
                NetworkHandler = new NetworkHandler(m_controllerManager);
                NetworkHandler.SetupNetworkHandler(server);

                PlayerHandler = new PlayerHandler(m_controllerManager);
                PlayerHandler.SetupPlayerHandler(server);

                ChatHandler = new ChatHandler(m_controllerManager);
                ChatHandler.SetupChatMessageHandler(NetworkHandler);

                UniverseHandler = new UniverseHandler(m_controllerManager);
                UniverseHandler.SetupHandler(server);

                mainLog.Info("IRSE: Loaded Universe!");

                return(true);
            }
            catch (ArgumentException ex)
            {
                mainLog.Error("Failed to get handlers [Argument Exception] \r\n Exception:" + ex.ToString());
                return(null);
            }
            catch (Exception ex)
            {
                mainLog.Error("Failed to get handlers \r\n Exception: " + ex.ToString());
                return(null);
            }
        }