Пример #1
0
        public bool CanSee(PhaseShift other)
        {
            if (Flags.HasFlag(PhaseShiftFlags.Unphased) && other.Flags.HasFlag(PhaseShiftFlags.Unphased))
            {
                return(true);
            }
            if (Flags.HasFlag(PhaseShiftFlags.AlwaysVisible) || other.Flags.HasFlag(PhaseShiftFlags.AlwaysVisible))
            {
                return(true);
            }
            if (Flags.HasFlag(PhaseShiftFlags.Inverse) && other.Flags.HasFlag(PhaseShiftFlags.Inverse))
            {
                return(true);
            }

            PhaseFlags excludePhasesWithFlag = PhaseFlags.None;

            if (Flags.HasFlag(PhaseShiftFlags.NoCosmetic) && other.Flags.HasFlag(PhaseShiftFlags.NoCosmetic))
            {
                excludePhasesWithFlag = PhaseFlags.Cosmetic;
            }

            if (!Flags.HasFlag(PhaseShiftFlags.Inverse) && !other.Flags.HasFlag(PhaseShiftFlags.Inverse))
            {
                ObjectGuid ownerGuid         = PersonalGuid;
                ObjectGuid otherPersonalGuid = other.PersonalGuid;
                return(Phases.Intersect(other.Phases, (myPhase, otherPhase) => !myPhase.Value.Flags.HasAnyFlag(excludePhasesWithFlag) && (!myPhase.Value.Flags.HasFlag(PhaseFlags.Personal) || ownerGuid == otherPersonalGuid)).Any());
            }

            var checkInversePhaseShift = new Func <PhaseShift, PhaseShift, bool>((phaseShift, excludedPhaseShift) =>
            {
                if (phaseShift.Flags.HasFlag(PhaseShiftFlags.Unphased) && excludedPhaseShift.Flags.HasFlag(PhaseShiftFlags.InverseUnphased))
                {
                    return(false);
                }

                foreach (var pair in phaseShift.Phases)
                {
                    if (pair.Value.Flags.HasAnyFlag(excludePhasesWithFlag))
                    {
                        continue;
                    }

                    var ExcludedPhaseRef = excludedPhaseShift.Phases.LookupByKey(pair.Key);
                    if (ExcludedPhaseRef != null || !ExcludedPhaseRef.Flags.HasAnyFlag(excludePhasesWithFlag))
                    {
                        return(false);
                    }
                }

                return(true);
            });

            if (other.Flags.HasFlag(PhaseShiftFlags.Inverse))
            {
                return(checkInversePhaseShift(this, other));
            }

            return(checkInversePhaseShift(other, this));
        }
Пример #2
0
 public PhaseRef(uint id, PhaseFlags flags, List <Condition> conditions)
 {
     Id             = id;
     Flags          = flags;
     References     = 0;
     AreaConditions = conditions;
 }
Пример #3
0
        public bool CanSee(PhaseShift other)
        {
            if (Flags.HasFlag(PhaseShiftFlags.Unphased) && other.Flags.HasFlag(PhaseShiftFlags.Unphased))
            {
                return(true);
            }
            if (Flags.HasFlag(PhaseShiftFlags.AlwaysVisible) || other.Flags.HasFlag(PhaseShiftFlags.AlwaysVisible))
            {
                return(true);
            }
            if (Flags.HasFlag(PhaseShiftFlags.Inverse) && other.Flags.HasFlag(PhaseShiftFlags.Inverse))
            {
                return(true);
            }

            PhaseFlags excludePhasesWithFlag = PhaseFlags.None;

            if (Flags.HasFlag(PhaseShiftFlags.NoCosmetic) && other.Flags.HasFlag(PhaseShiftFlags.NoCosmetic))
            {
                excludePhasesWithFlag = PhaseFlags.Cosmetic;
            }

            if (!Flags.HasFlag(PhaseShiftFlags.Inverse) && !other.Flags.HasFlag(PhaseShiftFlags.Inverse))
            {
                ObjectGuid ownerGuid         = PersonalGuid;
                ObjectGuid otherPersonalGuid = other.PersonalGuid;
                return(Phases.Intersect(other.Phases, (myPhase, otherPhase) => !myPhase.Flags.HasAnyFlag(excludePhasesWithFlag) && (!myPhase.Flags.HasFlag(PhaseFlags.Personal) || ownerGuid == otherPersonalGuid)).Any());
            }

            var checkInversePhaseShift = new Func <PhaseShift, PhaseShift, bool>((phaseShift, excludedPhaseShift) =>
            {
                if (phaseShift.Flags.HasFlag(PhaseShiftFlags.Unphased) && !excludedPhaseShift.Flags.HasFlag(PhaseShiftFlags.InverseUnphased))
                {
                    return(true);
                }

                foreach (var itr in phaseShift.Phases)
                {
                    if (itr.Flags.HasAnyFlag(excludePhasesWithFlag))
                    {
                        continue;
                    }

                    var index = excludedPhaseShift.Phases.IndexOf(itr);
                    if (index == -1 || excludedPhaseShift.Phases[index].Flags.HasAnyFlag(excludePhasesWithFlag))
                    {
                        return(true);
                    }
                }

                return(false);
            });

            if (other.Flags.HasFlag(PhaseShiftFlags.Inverse))
            {
                return(checkInversePhaseShift(this, other));
            }

            return(checkInversePhaseShift(other, this));
        }
Пример #4
0
        public bool AddPhase(uint phaseId, PhaseFlags flags, List <Condition> areaConditions, int references = 1)
        {
            var phase = new PhaseRef(phaseId, flags, null);

            ModifyPhasesReferences(phase, references);
            if (areaConditions != null)
            {
                phase.AreaConditions = areaConditions;
            }

            Phases.Add(phase);
            return(true);
        }
Пример #5
0
        public bool AddPhase(uint phaseId, PhaseFlags flags, List <Condition> areaConditions, int references = 1)
        {
            bool newPhase = false;

            if (!Phases.ContainsKey(phaseId))
            {
                newPhase = true;
                Phases.Add(phaseId, new PhaseRef(flags, null));
            }

            var phase = Phases.LookupByKey(phaseId);

            ModifyPhasesReferences(phaseId, phase, references);
            if (areaConditions != null)
            {
                phase.AreaConditions = areaConditions;
            }

            return(newPhase);
        }
Пример #6
0
 public PhaseRef(PhaseFlags flags, List <Condition> conditions)
 {
     Flags          = flags;
     References     = 0;
     AreaConditions = conditions;
 }