///  <summary>
        ///
        ///  </summary>
        ///  <param name="initAtom"></param>
        ///  <param name="repository"></param>
        /// <param name="logger"></param>
        public ChannelLoader(DictionaryAtom initAtom, ChannelRepository repository, ILogWrapper logger)
            : base(1, "ChannelLoader")
        {
            _dbManager         = initAtom.GetObject("DatabaseManager").CastAs <IDatabaseManager>();
            _entityManager     = initAtom.GetObject("EntityManager").CastAs <IEntityManager>();
            _staticDataManager = initAtom.GetObject("StaticDataManager").CastAs <IStaticDataManager>();

            _repository = repository;
            _log        = logger;
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        public virtual void OnInit(DictionaryAtom initAtom)
        {
            InitializationAtom = initAtom;
            EventManager       = initAtom.GetObject("EventManager").CastAs <EventManager>();
            StaticDataManager  = initAtom.GetObject("StaticDataManager").CastAs <StaticDataManager>();
            EntityManager      = initAtom.GetObject("EntityManager").CastAs <EntityManager>();
            Logger             = initAtom.GetObject("Logger").CastAs <LogWrapper>();

            Contexts.Add(new FlagContext(this));
            Contexts.Add(new TagContext(this));
            Contexts.Add(new BitContext(this));
            Contexts.Add(new PropertyContext(this));
        }
        public MainMenuHandler(ILuaLoadBalancer luaLoadBalancer, IDatabaseLoadBalancer dbLoadBalancer,
                               ILogWrapper log, DictionaryAtom initAtom)
        {
            _luaLoadBalancer = luaLoadBalancer;
            _dbLoadBalancer  = dbLoadBalancer;
            _log             = log;
            _dataPath        = initAtom.GetObject("DataPath").ToString();
            _kernel          = (IKernel)initAtom.GetObject("Ninject.Kernel");

            _commands = new Dictionary <string, Action <GameUser, string> >
            {
                { "createaccount", Create },
                { "connect", Login },
                { "login", Login },
                { "credits", Credits },
                { "who", Who },
                { "quit", Quit },
                { "logout", Quit },
                { "q", Quit }
            };
        }
示例#4
0
        ///  <summary>
        ///
        ///  </summary>
        ///  <param name="ipAddress"></param>
        ///  <param name="tcpClient"></param>
        /// <param name="initAtom"></param>
        public GameUser(string ipAddress, ITcpUser tcpClient, DictionaryAtom initAtom)
            : base(0, "NewUser")
        {
            var kernel = (IKernel)initAtom.GetObject("Ninject.Kernel");

            IpAddress      = ipAddress;
            TcpClient      = tcpClient;
            TcpServer      = kernel.Get <ITcpServer>();
            MenuRepository = new MenuHandlerRepository();
            MenuRepository.Add("MainMenu",
                               kernel.Get <IMenuHandler>("MainMenu", new Parameter("initAtom", initAtom, false)));

            TcpServer.OnNetworkMessageReceived += Server_OnNetworkMessageReceived;
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="initAtom"></param>
        public void OnInit(DictionaryAtom initAtom)
        {
            Validation.IsNotNull(initAtom, "initAtom");

            _numberVMs = initAtom.GetInt("NumberLuaVMs");
            Validation.Validate <ArgumentOutOfRangeException>(_numberVMs >= 1);

            _dataPath = initAtom.GetString("DataPath");

            Log.DebugFormat("{0} asked to initialize {1} LuaVMs.", GetType(), _numberVMs);

            var kernel = (IKernel)initAtom.GetObject("Ninject.Kernel");

            EventManager.RegisterListener(this, kernel.Get <IGame>(), typeof(OnGameInitialize), Instance_OnGameInitialize);
        }
示例#6
0
        public void OnInit(DictionaryAtom initAtom)
        {
            try
            {
                NinjectKernel = initAtom.GetObject("Ninject.Kernel").CastAs <IKernel>();
                initAtom.Set("Logger", Logger);
                InitBooleanSet = new BooleanSet("OnGameInitialize", Game_OnInitializationComplete);

                NinjectKernel.Load(_ninjectGameModules.Select(
                                       moduleType => (NinjectGameModule)Activator.CreateInstance(moduleType, initAtom, InitBooleanSet)));

                EventMgr  = (EventManager)NinjectKernel.Get <IEventManager>();
                LuaMgr    = (LuaManager)NinjectKernel.Get <ILuaManager>();
                DbMgr     = (DatabaseManager)NinjectKernel.Get <IDatabaseManager>();
                StaticMgr = (StaticDataManager)NinjectKernel.Get <IStaticDataManager>();
                EntityMgr = (EntityManager)NinjectKernel.Get <IEntityManager>();
                EntityMgr.EntityInitializer.RegisterEntityTypes(_entityTypes);
                ChannelMgr = (ChannelManager)NinjectKernel.Get <IChannelManager>();
                CmdMgr     = (CommandManager)NinjectKernel.Get <ICommandManager>();
                PathMgr    = (PathManager)NinjectKernel.Get <IPathManager>();
                TimeMgr    = (TimeManager)NinjectKernel.Get <ITimeManager>();
                NetMgr     = (NetworkManager)NinjectKernel.Get <INetworkManager>();
                // todo DataManager?
                // todo CombatManager ?
                LoopProcessor = (GameLoopProcessor)NinjectKernel.Get <ILoopProcessor>();

                Contexts = new List <IContext> {
                    new PropertyContext(this)
                };

                // Everything that needs early initialization done before this line
                // Now, lets begin regular setup (this will include game data)
                Logger.Debug("Completed initialization of Managers, throwing OnGameInitialize event.");
                EventMgr.ThrowEvent <OnGameInitialize>(this, new EventTable
                {
                    { "BooleanSet", InitBooleanSet },
                    { "InitAtom", initAtom }
                });
            }
            catch (Exception ex)
            {
                ex.Handle <InitializationException>(ExceptionHandlingOptions.RecordAndThrow, Logger);
            }
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="initAtom"></param>
        public override void OnInit(DictionaryAtom initAtom)
        {
            base.OnInit(initAtom);

            Contexts.Add(new ContentsContext(this));

            DbClient = new DatabaseClient(this, initAtom.GetObject("DatabaseManager").CastAs <IDatabaseLoadBalancer>());
            Validation.IsNotNull(DbClient, "DbClient");

            /*Position = Globals.Globals.PositionTypes.Standing;
             * Movement = Globals.Globals.MovementModeTypes.Walking;
             *
             * PerceptionHandler = new PerceptionHandler(this, 1);
             * Inventory = new Inventory(this);
             * EffectsHandler = new EffectsHandler(Game, EntityManager, Log, this);
             *
             * StatisticHandler = new StatisticHandler(this);
             * Game.SetManagerReferences(StatisticHandler);*/
        }
示例#8
0
        public void OnInit(DictionaryAtom initAtom)
        {
            InitializationAtom = initAtom;

            var kernel = (IKernel)initAtom.GetObject("Ninject.Kernel");

            CommandExecutor = (CommandExecutor)kernel.Get <ICommandExecutor>();

            _parsers = new Dictionary <string, IParser>
            {
                { "Command", kernel.Get <IParser>("CommandParser") },
                { "Social", kernel.Get <IParser>("SocialCommandParser") },
                { "Channel", kernel.Get <IParser>("PlayerChannelParser") },
                { "Movement", kernel.Get <IParser>("MovementParser") }
            };
            Log.DebugFormat("CommandManager registered {0} parsers.", _parsers.Count);

            VariableHelper.RegisterVariables();
            Log.DebugFormat("CommandManager registered {0} variables.", VariableHelper.Count);

            Log.DebugFormat("{0} setup.", GetType());
            EventManager.RegisterListener(this, typeof(OnGameInitialize), Instance_OnGameInitialize);
        }