Example #1
0
        /// <summary>
        ///     LoadContent will be called once per game and is the place to load
        ///     all of your content.
        /// </summary>
        protected sealed override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            if (!Directory.Exists("cfg"))
            {
                Directory.CreateDirectory("cfg");
            }
            if (!Directory.Exists("addons"))
            {
                Directory.CreateDirectory("addons");
            }


            ComponentCache.RegisterComponents();
            HeaderCache.RegisterHeaders();
            NetworkMethodCache.RegisterSendables();
            TileTypeCache.RegisterTileTypes();

            ServiceLocator.RegisterService(Content);
            ServiceLocator.RegisterService(spriteBatch);
            ServiceLocator.RegisterService(graphics);

            ServiceLocator.RegisterImplementations();
            DefineImplementations();
            ServiceLocator.RegisterServices();

            GameState.RegisterStates();
            ServiceLocator.Get <IPerformanceProfiler>().StartSession(false);
            for (var i = 0; i < 1000; i++)
            {
                //var world = new ObjectFactory<ThreeTierWorld>().Make(1, 1);
            }

            var time = ServiceLocator.Get <IPerformanceProfiler>().StopSession();

            Debug.WriteLine(time.TotalTime.Milliseconds);

            ServiceLocator.Get <IPropertyService>().Load("app");
            SteamCallback.Create();
            LuaContext.LoadAddons();

            Window.TextInput += ServiceLocator.Get <ITextInputService>().Execute;

            camera          = ServiceLocator.Get <ICamera>();
            input           = ServiceLocator.Get <IInput>();
            gameTimeService = ServiceLocator.Get <IGameTimeService>();
            stateService    = ServiceLocator.Get <IStateService>();
            client          = ServiceLocator.Get <IClient>();


            LoadGameContent();
        }