예제 #1
0
파일: World.cs 프로젝트: trapped/rotmg_svr
 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);
     }
     else if (entity is Projectile)
     {
         Projectile 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;
 }
예제 #2
0
        public virtual void LeaveWorld(Entity entity)
        {
            if (entity is Player)
            {
                Player dummy;
                Players.TryRemove(entity.Id, out dummy);
                PlayersCollision.Remove(entity);

                // if in trade, cancel it...
                if (dummy.tradeTarget != null)
                {
                    dummy.CancelTrade();
                }
            }
            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 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.ObjectDesc?.BlocksSight == true)
                {
                    if (Blocking == 3)
                    {
                        Sight.UpdateRegion(Map, (int)entity.X, (int)entity.Y);
                    }

                    foreach (var plr in Players.Values
                             .Where(p => MathsUtils.DistSqr(p.X, p.Y, entity.X, entity.Y) < Player.RadiusSqr))
                    {
                        plr.Sight.UpdateCount++;
                    }
                }

                if (entity is Decoy)
                {
                    PlayersCollision.Remove(entity);
                }
                else
                {
                    EnemiesCollision.Remove(entity);
                }
            }

            entity.Dispose();
        }
예제 #3
0
 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();
 }
예제 #4
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);
         }
     }
     else if (entity is ItemEntity)
     {
         ItemEntity dummy;
         EnemiesCollision.Remove(entity);
         ItemEntities.TryRemove(entity.Id, out dummy);
     }
     entity.Dispose();
     entity = null;
 }
예제 #5
0
        private void TryRemove(Enemy enemy)
        {
            if (enemy.ObjectDesc.Quest)
            {
                if (!Quests.TryRemove(enemy.Id, out Enemy dummy) || !Enemies.TryRemove(enemy.Id, out dummy) || !Entities.TryRemove(enemy.Id, out Entity entity))
                {
                    return;
                }
            }
            else
            {
                if (!Enemies.TryRemove(enemy.Id, out Enemy dummy) || !Entities.TryRemove(enemy.Id, out Entity entity))
                {
                    return;
                }
            }

            EnemiesCollision.Remove(enemy);
        }
예제 #6
0
        public virtual void LeaveWorld(Entity entity)
        {
            if (entity is Player)
            {
                TryRemove(entity as Player);
            }
            else
            {
                if (entity is Enemy)
                {
                    TryRemove(entity as Enemy);
                }
                else
                {
                    if (entity is Projectile)
                    {
                        TryRemove(entity as Projectile);
                    }
                    else
                    {
                        if (entity is GameObject)
                        {
                            TryRemove(entity as GameObject);

                            if (entity is Decoy)
                            {
                                PlayersCollision.Remove(entity);
                            }
                            else
                            {
                                EnemiesCollision.Remove(entity);
                            }
                        }
                    }
                }
            }

            entity.Dispose();

            entity = null;
        }
예제 #7
0
        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);
                }
                foreach (var i in (entity as Enemy).DamageCounter.GetPlayerData())
                {
                    if (i.Item1 != null)
                    {
                        var player = i.Item1;
                        var enemy  = (entity as Enemy);
                        switch (enemy.Name)
                        {
                        case "Archdemon Malphas":
                            player.playerQuestManager.ProcessQuestAction(1);
                            break;

                        case "Septavius the Ghost God":
                            player.playerQuestManager.ProcessQuestAction(2);
                            break;

                        case "Oryx the Mad God 2":
                            player.playerQuestManager.ProcessQuestAction(3);     // quest id
                            break;
                        }
                    }
                }
            }
            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();
        }
예제 #8
0
 public virtual void LeaveWorld(Entity entity)
 {
     if (!(entity is Pet || entity is Portal))
     {
         if (entity is Wall && entity.ObjectDesc != null && entity.ObjectDesc.FullOccupy || entity.ObjectDesc.OccupySquare || entity.ObjectDesc.EnemyOccupySquare)
         {
             WmapTile tile = Map[(int)entity.X, (int)entity.Y].Clone();
             tile.TileId     = Map[(int)entity.X, (int)entity.Y].TileId;
             tile.ObjType    = 0;
             tile.ObjectDesc = null;
             Map[(int)entity.X, (int)entity.Y] = tile;
         }
     }
     if (entity is Player)
     {
         Player dummy;
         if (!Players.TryRemove(entity.Id, out dummy))
         {
             Console.WriteLine("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();
 }