Пример #1
0
        /// <summary>
        /// When the scene starts it creates all the needed objects that are required by default
        /// </summary>
        internal void OnLoad()
        {
            QPrefs.Load().Wait();
            CreatorQueue   = new Queue <QEntity>();
            DestroyQueue   = new Queue <QBehavior>();
            Window         = new QWindow(Engine);
            SpriteRenderer = new QSpriteRenderer(Engine);
            GuiRenderer    = new QGuiRenderer(Engine);
            Content        = new QContentManager(Engine);
            Entities       = new QEntityManager(Engine);
            Physics        = new QPhysics();
            List <IQLoad> Loaders = new List <IQLoad>();

            //Use this method to load textures before the scene starts to compile all of them
            //so that the megatexture only has to be created once per scene so that there
            //is no delay when objects spawn, but totally optional if you have a better system
            BehaviorScriptLoader(Loaders);
            foreach (var loader in Loaders)
            {
                ((QBehavior)loader).SetName();
                ((QBehavior)loader).Parent = QEntity.GetEntity();
                loader.OnLoad(new QLoadContent(Engine, Content));
                QEntity.FreeEntity(((QBehavior)(loader)).Parent);
            }
            Accumulator         = new QAccumulator();
            Coroutine           = new QCoroutine();
            Instantiate(Console = new QConsole());
            Instantiate(Debug   = new QDebug());
            Instantiate(Camera  = new QCamera());
            CheckQueue();
            DebugView = new QDebugView(Physics.PhysicsWorld);
            DebugView.LoadContent(Engine.GraphicsDevice, Engine.Content);
            Load();
        }
Пример #2
0
        /*Private Methods*/

        /// <summary>
        /// frees up qobject and removes it from all arrays, sounds cool
        /// </summary>
        /// <param name="script"></param>
        void Obliterate(QBehavior script)
        {
            Entities.Remove(script);
            script.Transform.Reset();
            QEntity.FreeEntity(script.Parent);
        }