示例#1
0
        public static bool IsAllied(Mobile a, Mobile b)
        {
            var guildA = a.Guild as Guild;
            var guildB = b.Guild as Guild;

            if (guildA != null && guildB != null && (guildA == guildB || guildA.IsAlly(guildB)))
            {
                return(true);
            }

            if (TempCombatants == null)
            {
                return(false);
            }

            var tempA = TempCombatants.FirstOrDefault(c => c.From == a);
            var tempB = TempCombatants.FirstOrDefault(c => c.From == b);

            if (tempA != null && (tempA.Friendly == b || (tempA.FriendlyGuild != null && tempA.FriendlyGuild == guildB)))
            {
                return(true);
            }

            if (tempB != null && (tempB.Friendly == a || (tempB.FriendlyGuild != null && tempB.FriendlyGuild == guildA)))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        public static void OnMapChange(PlayerMobile pm)
        {
            if (TempCombatants == null || pm.Map == Map.Internal || pm.Map == null)
            {
                return;
            }

            TempCombatants.Where(t => t.From == pm).IterateReverse(RemoveTempCombatant);
        }
示例#3
0
        public static void CheckTempCombatants()
        {
            if (TempCombatants == null)
            {
                StopTempCombatantTimer();
            }

            TempCombatants.IterateReverse(c =>
            {
                if (c.Expired)
                {
                    TempCombatants.Remove(c);
                }
            });
        }
示例#4
0
        public static void RemoveTempCombatant(TemporaryCombatant tempCombatant)
        {
            if (TempCombatants == null)
            {
                return;
            }

            TempCombatants.Remove(tempCombatant);
            tempCombatant.From.Delta(MobileDelta.Noto);
            tempCombatant.From.ProcessDelta();

            if (TempCombatants.Count == 0)
            {
                TempCombatants = null;
                StopTempCombatantTimer();
            }
        }
示例#5
0
        public static TemporaryCombatant GetTempCombatant(Mobile from, Mobile to)
        {
            foreach (var combatant in TempCombatants.Where(c => c.From == from))
            {
                if (combatant.Friendly == null && to == null)
                {
                    return(combatant);
                }

                if (combatant.Friendly == to || (combatant.FriendlyGuild != null && combatant.FriendlyGuild == from.Guild as Guild))
                {
                    return(combatant);
                }
            }

            return(null);
        }
示例#6
0
        public static void AddTempParticipant(Mobile m, Mobile friendlyTo)
        {
            if (TempCombatants == null)
            {
                TempCombatants = new List <TemporaryCombatant>();
                AddTempCombatantTimer();
            }

            var combatant = GetTempCombatant(m, friendlyTo);

            if (combatant == null)
            {
                combatant = new TemporaryCombatant(m, friendlyTo);
            }
            else
            {
                combatant.Reset();
            }

            TempCombatants.Add(combatant);

            m.Delta(MobileDelta.Noto);
            m.ProcessDelta();
        }
示例#7
0
        public static bool IsVvVCombatant(Mobile mobile)
        {
            CheckTempCombatants();

            return(IsVvV(mobile) || (TempCombatants != null && TempCombatants.Any(c => c.From == mobile)));
        }