public void TickLogic(RealmTime time)
        {
            if (EnemiesCollision != null)
            {
                foreach (var i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                {
                    i.Tick(time);
                }
                foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                {
                    i.Value.Tick(time);
                }
            }
            else
            {
                foreach (var i in Enemies)
                {
                    i.Value.Tick(time);
                }
                foreach (var i in StaticObjects)
                {
                    i.Value.Tick(time);
                }
            }
            foreach (var i in Enemies.Where(_ => _.Value.ObjectDesc?.Group == "Zombies"))
            {
                i.Value.Tick(time);
            }

            foreach (var i in Pets)
            {
                i.Value.Tick(time);
            }
        }
Example #2
0
        public virtual void Tick(RealmTime time)
        {
            if (IsLimbo)
            {
                return;
            }

            for (int i = 0; i < Timers.Count; i++)
            {
                if (Timers[i].Tick(this, time))
                {
                    Timers.RemoveAt(i);
                    i--;
                }
            }

            foreach (var i in Players)
            {
                i.Value.Tick(time);
            }

            if (EnemiesCollision != null)
            {
                foreach (var i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                {
                    i.Tick(time);
                }
                foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                {
                    i.Value.Tick(time);
                }
            }
            else
            {
                foreach (var i in Enemies)
                {
                    i.Value.Tick(time);
                }
                foreach (var i in StaticObjects)
                {
                    i.Value.Tick(time);
                }
            }
            foreach (var i in Projectiles)
            {
                i.Value.Tick(time);
            }

            if (Players.Count != 0 || !closable || !IsDungeon())
            {
                return;
            }
            var vault = this as Vault;

            if (vault != null)
            {
                Manager.RemoveVault(vault.AccountId);
            }
            Manager.RemoveWorld(this);
        }
Example #3
0
        public void TickLogic(RealmTime time)
        {
            using (TimedLock.Lock(_deleteLock))
            {
                if (Deleted)
                {
                    return;
                }

                if (EnemiesCollision != null)
                {
                    foreach (var i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                    {
                        i.Tick(time);
                    }
                    foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                    {
                        i.Value.Tick(time);
                    }
                }
                else
                {
                    foreach (var i in Enemies)
                    {
                        i.Value.Tick(time);
                    }
                    foreach (var i in StaticObjects)
                    {
                        i.Value.Tick(time);
                    }
                }
            }
        }
Example #4
0
        public virtual void Tick(RealmTime time)
        {
            try
            {
                if (IsLimbo)
                {
                    return;
                }

                for (int i = 0; i < Timers.Count; i++)
                {
                    if (Timers[i].Tick(this, time))
                    {
                        Timers.RemoveAt(i);
                        i--;
                    }
                }

                foreach (var i in Players)
                {
                    i.Value.Tick(time);
                }

                if (EnemiesCollision != null)
                {
                    foreach (Entity i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                    {
                        i.Tick(time);
                    }
                    foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                    {
                        i.Value.Tick(time);
                    }
                }
                else
                {
                    foreach (var i in Enemies)
                    {
                        i.Value.Tick(time);
                    }
                    foreach (var i in StaticObjects)
                    {
                        i.Value.Tick(time);
                    }
                }
                foreach (var i in Projectiles)
                {
                    i.Value.Tick(time);
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }
Example #5
0
        public void TickLogic(RealmTime time)
        {
            lock (Players)
            {
                if (Deleted)
                {
                    return;
                }

                if (EnemiesCollision != null)
                {
                    foreach (var i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                    {
                        if (!(i is ItemEntity))
                        {
                            i.Tick(time);
                        }
                    }
                    foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                    {
                        i.Value.Tick(time);
                    }
                    foreach (var i in ItemEntities)
                    {
                        i.Value.Tick(time);
                    }
                }
                else
                {
                    foreach (var i in Enemies)
                    {
                        i.Value.Tick(time);
                    }
                    foreach (var i in StaticObjects)
                    {
                        i.Value.Tick(time);
                    }
                    foreach (var i in ItemEntities)
                    {
                        i.Value.Tick(time);
                    }
                }


                foreach (var i in Pets)
                {
                    i.Value.Tick(time);
                }
            }
        }
Example #6
0
        public virtual void Tick(RealmTime time)
        {
            try
            {
                if (IsLimbo)
                {
                    return;
                }

                for (var i = 0; i < Timers.Count; i++)
                {
                    try
                    {
                        if (Timers[i] == null)
                        {
                            continue;
                        }
                        if (!Timers[i].Tick(this, time))
                        {
                            continue;
                        }
                        Timers.RemoveAt(i);
                        i--;
                    }
                    catch
                    {
                        // ignored
                    }
                }

                foreach (var i in Players)
                {
                    i.Value.Tick(time);
                }

                foreach (var i in Pets)
                {
                    i.Value.Tick(time);
                }

                if (EnemiesCollision != null)
                {
                    foreach (var i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                    {
                        i.Tick(time);
                    }
                    foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                    {
                        i.Value.Tick(time);
                    }
                }
                else
                {
                    foreach (var i in Enemies)
                    {
                        i.Value.Tick(time);
                    }
                    foreach (var i in StaticObjects)
                    {
                        i.Value.Tick(time);
                    }
                }
                foreach (var i in Projectiles)
                {
                    i.Value.Tick(time);
                }

                if (Players.Count != 0 || !canBeClosed || !IsDungeon())
                {
                    return;
                }
                var vault = this as Vault;
                if (vault != null)
                {
                    Manager.RemoveVault(vault.AccountId);
                }
                Manager.RemoveWorld(this);
            }
            catch (Exception e)
            {
                Log.Error("World: " + Name + "\n" + e);
            }
        }
Example #7
0
        public virtual void Tick(RealmTime time)
        {
            if (IsLimbo)
            {
                return;
            }

            for (int i = 0; i < Timers.Count; i++)
            {
                if (Timers[i] == null)
                {
                    Console.Write("Timer is null\n");
                    Timers.RemoveAt(i);
                    continue;
                }

                if (Timers[i].Tick(this, time))
                {
                    Timers.RemoveAt(i);
                    i--;
                }
            }

            foreach (var i in Players)
            {
                if (i.Value == null)
                {
                    Console.Write("Player is null\n");
                }
                i.Value.Tick(time);
            }

            if (EnemiesCollision != null)
            {
                foreach (Entity i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                {
                    if (i == null)
                    {
                        Console.Write("Entity is null\n");
                    }
                    i.Tick(time);
                }

                foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                {
                    if (i.Value == null)
                    {
                        Console.Write("StaticObject:Decoy is null\n");
                    }
                    i.Value.Tick(time);
                }
            }
            else
            {
                foreach (var i in Enemies)
                {
                    if (i.Value == null)
                    {
                        Console.Write("Enemy is null\n");
                    }
                    i.Value.Tick(time);
                }
            }
            foreach (var i in Projectiles)
            {
                if (i.Value == null)
                {
                    Console.Write("Projectile is null\n");
                }
                i.Value.Tick(time);
            }

            //if (Players.Count == 0 && canBeClosed && IsDungeon())
            //     Manager.RemoveWorld(this);
        }
Example #8
0
        public virtual void Tick(RealmTime time)
        {
            if (IsLimbo)
            {
                return;
            }

            if (disposable)
            {
                if (Players.Count <= 0 && !isDisposing)
                {
                    isDisposing = true;
                    if (RemovalMS < 25000)
                    {
                        //    log.WarnFormat("World \"{0}\" does not have a valid RemovalMS: {1}! Please allow at least 25 seconds. Default: 25000 ms", Name, RemovalMS);
                        RemovalMS = 25000;
                    }
                    //  log.InfoFormat("World {0}, ID:{1} is unused and will dispose in {2}MS.", Name, Id, RemovalMS);
                    WorldTimer timer = new WorldTimer(RemovalMS, (w, t) =>
                    {
                        manager.RemoveWorld(w);
                    });
                    Timers.Add(timer);
                }
                else if (isDisposing && Players.Count >= 1)
                {
                    isDisposing = false;
                    //      log.InfoFormat("World {0}, ID:{1} is in use and has cancelled disposal.", Name, Id);
                }
            }

            if (Timers != null && Timers.Count > 0)
            {
                for (int i = 0; i < Timers.Count; i++)
                {
                    if (Timers[i].Tick(this, time) && Timers.Count > 0)
                    {
                        Timers.RemoveAt(i);
                        i--;
                    }
                }
            }

            try //entity ticking now, possible huge range of issues that i can't yet remove the try catch - jade
            {
                foreach (var i in Players)
                {
                    i.Value.Tick(time);
                }

                if (isDisposing)
                {
                    return;
                }

                if (EnemiesCollision != null)
                {
                    foreach (Entity i in EnemiesCollision.GetActiveChunks(PlayersCollision))
                    {
                        i.Tick(time);
                    }
                    foreach (var i in StaticObjects.Where(x => x.Value is Decoy))
                    {
                        i.Value.Tick(time);
                    }
                }
                else
                {
                    foreach (var i in Enemies)
                    {
                        i.Value.Tick(time);
                    }
                    foreach (var i in StaticObjects)
                    {
                        i.Value.Tick(time);
                    }
                }
                foreach (var i in Projectiles)
                {
                    i.Value.Tick(time);
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }