當前位置: 首頁>>代碼示例>>C#>>正文


C# Entity.Destroy方法代碼示例

本文整理匯總了C#中System.Entity.Destroy方法的典型用法代碼示例。如果您正苦於以下問題:C# Entity.Destroy方法的具體用法?C# Entity.Destroy怎麽用?C# Entity.Destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Entity的用法示例。


在下文中一共展示了Entity.Destroy方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RemoveEntity

        public virtual void RemoveEntity(Entity entity) {
            var removed = _entities.Remove(entity);

            if (!removed)
                throw new EntityNotInPoolException(entity, "Could not remove entity");

            // Inform subscribers the entity is going to be removed
            OnEntityRemoving.Invoke(this, new PoolChanged(this, entity));

            // Prepare it for removal
            entity.Destroy();

            // Inform subscribers the entity has been removed
            OnEntityRemoved.Invoke(this, new PoolChanged(this, entity));

            // Remove the item from memory
            entity.Dispose();
        }
開發者ID:LambdaSix,項目名稱:Capsicum,代碼行數:18,代碼來源:Pool.cs

示例2: ObjectRemovedInvokedWhenAnEntityIsDestroyed

        public void ObjectRemovedInvokedWhenAnEntityIsDestroyed()
        {
            var entity = new Entity(new VariableCollection());
            this.collection.Add(entity);
            var called = false;
            collection.ObjectRemoved += (x) => { called = true; };
            entity.Destroy();
            MonocleObject.LifeTimeManager.DestroyObjectsFlaggedForDestruction();

            Assert.IsTrue(called);
        }
開發者ID:TheFlyingFiddle,項目名稱:Project-Monocle,代碼行數:11,代碼來源:EntityCollectionTest.cs

示例3: ObjectAddedInvokedWhenAnEntityIsAdded

        public void ObjectAddedInvokedWhenAnEntityIsAdded()
        {
            Entity e = null;
            collection.ObjectAdded += (x) => { e = (Entity)x; };
            var entity = new Entity(new VariableCollection());
            collection.Add(entity);

            Assert.AreSame(e, entity);

            entity.Destroy();
        }
開發者ID:TheFlyingFiddle,項目名稱:Project-Monocle,代碼行數:11,代碼來源:EntityCollectionTest.cs

示例4: EntityCanBeAdded

        public void EntityCanBeAdded()
        {
            var entity = new Entity(new VariableCollection());
            collection.Add(entity);

            Assert.NotNull(collection.Find((x) => true));
            entity.Destroy();
        }
開發者ID:TheFlyingFiddle,項目名稱:Project-Monocle,代碼行數:8,代碼來源:EntityCollectionTest.cs

示例5: ComponentCreatedInvokedWhenAComponentIsCreated

        public void ComponentCreatedInvokedWhenAComponentIsCreated()
        {
            var entity = new Entity(new VariableCollection());
            this.collection.Add(entity);
            var called = false;
            collection.ObjectAdded += (x) => { called = true; };
            entity.AddComponent<FakeComp>();
            Assert.IsTrue(called);

            entity.Destroy();
        }
開發者ID:TheFlyingFiddle,項目名稱:Project-Monocle,代碼行數:11,代碼來源:EntityCollectionTest.cs

示例6: Kill

 public static void Kill(Monster monster, Entity sender, EventArgs args)
 {
     if (sender is Unit)
         (sender as Unit).Kill();
     else
         sender.Destroy();
 }
開發者ID:trigger-death,項目名稱:ZeldaOracle,代碼行數:7,代碼來源:MonsterReactions.cs

示例7: Destroy

 //-----------------------------------------------------------------------------
 // Basic Sender Reactions
 //-----------------------------------------------------------------------------
 public static void Destroy(Monster monster, Entity sender, EventArgs args)
 {
     sender.Destroy();
 }
開發者ID:trigger-death,項目名稱:ZeldaOracle,代碼行數:7,代碼來源:MonsterReactions.cs

示例8: Burn

 // Burn the monster for 1 damage.
 public static void Burn(Monster monster, Entity sender, EventArgs args)
 {
     monster.Burn(1);
     if (sender is Fire)
         sender.Destroy();
 }
開發者ID:trigger-death,項目名稱:ZeldaOracle,代碼行數:7,代碼來源:MonsterReactions.cs

示例9: DestroyAlsoDestroysAllChildren

        public void DestroyAlsoDestroysAllChildren()
        {
            var entity1 = new Entity(new VariableCollection());
            entity.Parent = entity1;

            entity1.Destroy();
            MonocleObject.LifeTimeManager.DestroyObjectsFlaggedForDestruction();

            Assert.IsTrue(entity == null);
        }
開發者ID:TheFlyingFiddle,項目名稱:Project-Monocle,代碼行數:10,代碼來源:EntityTest.cs


注:本文中的System.Entity.Destroy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。