Beispiel #1
0
        public virtual void Reset()
        {
            if (Dead != null)
            {
                Dead.Clear();
            }
            else
            {
                Dead = new Dictionary <PlayerMobile, DateTime>();
            }

            if (Idlers != null)
            {
                Idlers.Clear();
            }
            else
            {
                Idlers = new List <PlayerMobile>();
            }

            if (Members != null)
            {
                ForEachMember(pm => RemoveMember(pm, true));
                Members.Clear();
            }
            else
            {
                Members = new Dictionary <PlayerMobile, DateTime>();
            }
        }
Beispiel #2
0
        public void MicroSync()
        {
            if (Members != null && Idlers != null && Battle != null && Battle.State == PvPBattleState.Running)
            {
                var now = DateTime.UtcNow;

                foreach (var kvp in Members)
                {
                    if (!Battle.IdleKick || IsDead(kvp.Key))
                    {
                        Idlers.Remove(kvp.Key);
                        continue;
                    }

                    if (kvp.Value + Battle.IdleThreshold < now && !IsIdle(kvp.Key))
                    {
                        Idlers.Add(kvp.Key);
                    }
                }

                if (Battle.IdleKick && Idlers.Count > 0)
                {
                    Idlers.AsEnumerable().ForEach(pm => Battle.Eject(pm, true));
                }
            }

            OnMicroSync();

            if (Battle != null)
            {
                Battle.OnTeamMicroSync(this);
            }
        }
Beispiel #3
0
        public void MicroSync()
        {
            if (Battle.State == PvPBattleState.Running)
            {
                DateTime now = DateTime.UtcNow;

                foreach (var kvp in Members)
                {
                    if (IsDead(kvp.Key))
                    {
                        Idlers.Remove(kvp.Key);
                        continue;
                    }

                    if (kvp.Value + Battle.IdleThreshold < now && !IsIdle(kvp.Key))
                    {
                        Idlers.Add(kvp.Key);
                    }
                }

                if (Battle.IdleKick)
                {
                    Idlers.Not(IsDead).ForEach(pm => Battle.Eject(pm, true));
                }
            }

            OnMicroSync();

            Battle.OnTeamMicroSync(this);
        }
Beispiel #4
0
        public virtual void UpdateActivity(PlayerMobile pm)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            Idlers.Remove(pm);

            if (IsMember(pm))
            {
                Members[pm] = DateTime.UtcNow;
            }
        }
Beispiel #5
0
        public virtual void RemoveMember(PlayerMobile pm, bool teleport)
        {
            if (!IsMember(pm))
            {
                return;
            }

            Dead.Remove(pm);
            Idlers.Remove(pm);

            Members.Remove(pm);
            OnMemberRemoved(pm);

            if (teleport)
            {
                Battle.TeleportToSpectateLocation(pm);
            }
        }
Beispiel #6
0
        public void MicroSync()
        {
            if (!Members.IsNullOrEmpty() && !Idlers.IsNullOrEmpty() && Battle != null && Battle.IsRunning)
            {
                if (Battle.IdleKick)
                {
                    var then = DateTime.UtcNow - Battle.IdleThreshold;

                    foreach (var o in Members)
                    {
                        if (o.Value > then)
                        {
                            Idlers.Remove(o.Key);
                        }
                        else if (o.Value < then)
                        {
                            Idlers.Update(o.Key);
                        }
                    }

                    Idlers.RemoveAll(IsDead);

                    if (Idlers.Count > 0)
                    {
                        Idlers.ForEachReverse(pm => Battle.Quit(pm, true));
                    }
                }
                else
                {
                    Idlers.Clear();
                }
            }

            OnMicroSync();

            if (Battle != null)
            {
                Battle.OnTeamMicroSync(this);
            }
        }
Beispiel #7
0
 public bool IsIdle(PlayerMobile pm)
 {
     return(Idlers != null && Idlers.Contains(pm));
 }