Example #1
0
 public virtual void LeaveWorld(Entity entity)
 {
     if (entity is Player)
     {
         Player dummy;
         Players.TryRemove(entity.Id, out dummy);
         PlayersCollision.Remove(entity);
     }
     else if (entity is Enemy)
     {
         Enemy dummy;
         Enemies.TryRemove(entity.Id, out dummy);
         EnemiesCollision.Remove(entity);
         if (entity.ObjectDesc.Quest)
             Quests.TryRemove(entity.Id, out dummy);
         if (entity.isPet)
         {
             Entity dummy2;
             Pets.TryRemove(entity.Id, out dummy2);
         }
     }
     else if (entity is Projectile)
     {
         var p = entity as Projectile;
         Projectiles.TryRemove(new Tuple<int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
     }
     else if (entity is StaticObject)
     {
         StaticObject dummy;
         StaticObjects.TryRemove(entity.Id, out dummy);
         if (entity is Decoy)
             PlayersCollision.Remove(entity);
         else
             EnemiesCollision.Remove(entity);
     }
     entity.Owner = null;
     entity.Dispose();
 }
Example #2
0
 /// <summary>
 /// Removes the physics body of the given entity from the physics world.
 /// </summary>
 public void RemoveEntity(Entity e, World.World worldState)
 {
     e.Dispose();
     worldState.RemoveEntity(e);
     if (e.PhysicsBody != null)
     {
         EntityIdByPhysicsBody.Remove(e.PhysicsBody);
         RemoveBody(e.PhysicsBody);
         e.PhysicsBody = null;
     }
 }
 public virtual void LeaveWorld(Entity entity)
 {
     if (entity is Player)
     {
         Player dummy;
         if (!Players.TryRemove(entity.Id, out dummy))
             Log.WarnFormat("Could not remove {0} from world {1}", entity.Name, Name);
         PlayersCollision.Remove(entity);
     }
     else if (entity is Enemy)
     {
         Enemy dummy;
         Enemies.TryRemove(entity.Id, out dummy);
         EnemiesCollision.Remove(entity);
         if (entity.ObjectDesc.Quest)
             Quests.TryRemove(entity.Id, out dummy);
     }
     else
     {
         var projectile = entity as Projectile;
         if (projectile != null)
         {
             var p = projectile;
             Projectiles.TryRemove(new Tuple<int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
         }
         else if (entity is StaticObject)
         {
             StaticObject dummy;
             StaticObjects.TryRemove(entity.Id, out dummy);
             if (entity is Decoy)
                 PlayersCollision.Remove(entity);
             else
                 EnemiesCollision.Remove(entity);
         }
         else if (entity is Pet)
         {
             if (entity.IsPet)
             {
                 Pet dummy2;
                 Pets.TryRemove(entity.Id, out dummy2);
                 PlayersCollision.Remove(entity);
             }
         }
     }
     entity.Owner = null;
     entity.Dispose();
 }