本文整理汇总了C#中Entity.destroy方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.destroy方法的具体用法?C# Entity.destroy怎么用?C# Entity.destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity.destroy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DestroyEntity
public virtual void DestroyEntity(Entity entity) {
var removed = _entities.Remove(entity);
if (!removed) {
throw new PoolDoesNotContainEntityException(entity,
"Could not destroy entity!");
}
_entitiesCache = null;
if (OnEntityWillBeDestroyed != null) {
OnEntityWillBeDestroyed(this, entity);
}
entity.destroy();
if (OnEntityDestroyed != null) {
OnEntityDestroyed(this, entity);
}
if (entity._refCount == 1) {
entity.OnEntityReleased -= _cachedOnEntityReleased;
_reusableEntities.Push(entity);
} else {
_retainedEntities.Add(entity);
}
entity.Release();
}
示例2: DestroyEntity
//Its possible that we create a bullet and say 'destroy yourself in 4 seconds' and then the bullet collides and we say destroy yourself now,
//then the 4 seconds expires and it tries to delete itself again.
//So this 'if' solves that - srivello
private void DestroyEntity(Entity entity)
{
if (_pool.HasEntity(entity))
{
_pool.DestroyEntity(entity);
}
else
{
entity.destroy();
}
}
示例3: DestroyEntity
public virtual void DestroyEntity(Entity entity) {
var removed = _entities.Remove(entity);
if (!removed) {
throw new PoolDoesNotContainEntityException("'" + this + "' cannot destroy " + entity + "!",
"Did you call pool.DestroyEntity() on a wrong pool?");
}
_entitiesCache = null;
if (OnEntityWillBeDestroyed != null) {
OnEntityWillBeDestroyed(this, entity);
}
entity.destroy();
if (OnEntityDestroyed != null) {
OnEntityDestroyed(this, entity);
}
if (entity.retainCount == 1) {
entity.OnEntityReleased -= _cachedOnEntityReleased;
_reusableEntities.Push(entity);
} else {
_retainedEntities.Add(entity);
}
entity.Release(this);
}
示例4: DestroyEntity
public virtual void DestroyEntity(Entity entity)
{
var removed = _entities.Remove(entity);
if(!removed) {
throw new ContextDoesNotContainEntityException(
"'" + this + "' cannot destroy " + entity + "!",
"Did you call context.DestroyEntity() on a wrong context?"
);
}
_entitiesCache = null;
if(OnEntityWillBeDestroyed != null) {
OnEntityWillBeDestroyed(this, entity);
}
entity.destroy();
if(OnEntityDestroyed != null) {
OnEntityDestroyed(this, entity);
}
if(entity.retainCount == 1) {
// Can be released immediately without
// adding to _retainedEntities
entity.OnEntityReleased -= _cachedEntityReleased;
_reusableEntities.Push(entity);
entity.Release(this);
entity.removeAllOnEntityReleasedHandlers();
} else {
_retainedEntities.Add(entity);
entity.Release(this);
}
}