private void m_gameDocumentRegistry_DocumentRemoved(object sender, ItemRemovedEventArgs <IGameDocument> e)
        {
            IGameDocument document = e.Item;

            document.DirtyChanged -= m_document_DirtyChanged;
            document.UriChanged   -= m_document_UriChanged;

            IGame game = document.Cast <IGame>();

            if (document == m_designView.Context.Cast <IGameDocument>())
            {// master document.
                IGrid        grid       = document.As <IGame>().Grid;
                GridRenderer gridRender = grid.Cast <GridRenderer>();
                gridRender.DeleteVertexBuffer();
                m_designView.Context = null;
                GameEngine.DestroyObject(game.Cast <NativeObjectAdapter>());
                GameEngine.Clear();
            }
            else
            {// sub document.
                DomNode masterNode            = m_gameDocumentRegistry.MasterDocument.As <DomNode>();
                DomNode rooFolderNode         = game.RootGameObjectFolder.Cast <DomNode>();
                NativeGameWorldAdapter gworld = masterNode.Cast <NativeGameWorldAdapter>();
                gworld.Remove(masterNode, rooFolderNode, masterNode.Type.GetChildInfo("gameObjectFolder"));
            }
        }
 protected override void Dispose(bool disposing)
 {
     if (m_intanceId != 0)
     {
         GameEngine.DestroyObject(0, m_intanceId, m_typeId);
         m_intanceId = 0;
     }
     base.Dispose(disposing);
 }
 protected override void Dispose(bool disposing)
 {
     GameEngine.DestroyObject(swapChainId, SurfaceId);
     SurfaceId = 0;
     if (disposing)
     {
         m_renderState.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #4
0
        protected override void Dispose(bool disposing)
        {
            if (m_instanceId != 0)
            {
                if (m_manageLifetime)
                {
                    GameEngine.DestroyObject(TypeId, m_instanceId);
                }

                m_instanceId = 0;
            }
            base.Dispose(disposing);
        }
Beispiel #5
0
 protected override void Dispose(bool disposing)
 {
     if (m_intanceId != 0)
     {
         GameEngine.DestroyObject(m_typeId, m_intanceId);
         m_typeId       = 0;
         m_renderFlagId = 0;
         m_wirecolorId  = 0;
         m_selColorId   = 0;
         m_intanceId    = 0;
     }
     base.Dispose(disposing);
 }
Beispiel #6
0
        public void OnRemoveFromDocument(XLEBridgeUtils.INativeDocumentAdapter doc)
        {
            if (DomNode == null || m_instanceId == 0)
            {
                return;
            }

            ulong documentId = (doc != null) ? doc.NativeDocumentId : 0;

            System.Diagnostics.Debug.Assert(documentId == m_documentId);

            GameEngine.DestroyObject(m_documentId, m_instanceId, TypeId);
            GameEngine.DeregisterGob(m_documentId, m_instanceId, this);
            ReleaseNativeHandle();
        }
Beispiel #7
0
        public void Remove(DomNode parent, DomNode child, ChildInfo chInfo)
        {
            NativeObjectAdapter childObject  = child.As <NativeObjectAdapter>();
            NativeObjectAdapter parentObject = parent.As <NativeObjectAdapter>();

            object listIdObj = chInfo.GetTag(NativeAnnotations.NativeElement);

            if (childObject == null || parentObject == null || listIdObj == null)
            {
                return;
            }

            uint  listId   = (uint)listIdObj;
            uint  typeId   = (uint)chInfo.DefiningType.GetTag(NativeAnnotations.NativeType);
            ulong parentId = parentObject.InstanceId;
            ulong childId  = childObject.InstanceId;

            GameEngine.ObjectRemoveChild(typeId, listId, parentId, childId);
            if (ManageNativeObjectLifeTime)
            {
                GameEngine.DestroyObject(childObject);
            }
        }
Beispiel #8
0
        private void Init()
        {
            if (m_game != null)
            {
                return;
            }

            NativeObjectAdapter curLevel = GameEngine.GetGameLevel();

            try
            {
                // create new document by creating a Dom node of the root type defined by the schema
                DomNode   rootNode = new DomNode(m_schemaLoader.GameType, m_schemaLoader.GameRootElement);
                INameable nameable = rootNode.As <INameable>();
                nameable.Name = "Game";
                NativeObjectAdapter gameLevel = rootNode.Cast <NativeObjectAdapter>();
                GameEngine.CreateObject(gameLevel);
                GameEngine.SetGameLevel(gameLevel);
                gameLevel.UpdateNativeOjbect();
                NativeGameWorldAdapter gworld = rootNode.Cast <NativeGameWorldAdapter>();
                m_game = rootNode.Cast <IGame>();
                IGameObjectFolder rootFolder = m_game.RootGameObjectFolder;
                m_renderSurface.Game            = m_game;
                m_renderSurface.GameEngineProxy = m_gameEngine;
            }
            finally
            {
                GameEngine.SetGameLevel(curLevel);
            }


            m_mainWindow.Closed += delegate
            {
                GameEngine.DestroyObject(m_game.Cast <NativeObjectAdapter>());
                m_renderSurface.Dispose();
            };
        }
Beispiel #9
0
        private void Init()
        {
            NativeObjectAdapter curLevel = GameEngine.GetGameLevel();

            try
            {
                // create new document by creating a Dom node of the root type defined by the schema
                DomNode   rootNode = new DomNode(m_schemaLoader.GameType, m_schemaLoader.GameRootElement);
                INameable nameable = rootNode.Cast <INameable>();
                nameable.Name = "ThumbnailGenerator";

                NativeObjectAdapter gameLevel = rootNode.Cast <NativeObjectAdapter>();
                GameEngine.CreateObject(gameLevel);
                GameEngine.SetGameLevel(gameLevel);
                gameLevel.UpdateNativeOjbect();
                NativeGameWorldAdapter gworld = rootNode.Cast <NativeGameWorldAdapter>();

                m_game = rootNode.Cast <IGame>();
                IGameObjectFolder rootFolder = m_game.RootGameObjectFolder;
                m_renderSurface          = new TextureRenderSurface(96, 96);
                m_renderState            = new RenderState();
                m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit | GlobalRenderFlags.Shadows;
            }
            finally
            {
                GameEngine.SetGameLevel(curLevel);
            }


            m_mainWindow.Closed += delegate
            {
                GameEngine.DestroyObject(m_game.Cast <NativeObjectAdapter>());
                m_renderSurface.Dispose();
                m_renderState.Dispose();
            };
        }