// The references are not needed anymore
        // tell the source to remove them from the list and free the mem
        public void DeleteReferences()
        {
            HostileReference refe = GetFirst();

            while (refe != null)
            {
                HostileReference nextRef = refe.Next();
                refe.RemoveReference();
                refe = nextRef;
            }
        }
        // Remove specific faction references
        public void DeleteReferencesForFaction(uint faction)
        {
            HostileReference refe = GetFirst();

            while (refe != null)
            {
                HostileReference nextRef = refe.Next();
                if (refe.GetSource().GetOwner().GetFactionTemplateEntry().Faction == faction)
                {
                    refe.RemoveReference();
                }
                refe = nextRef;
            }
        }
        public void UpdateVisibility()
        {
            HostileReference refe = GetFirst();

            while (refe != null)
            {
                HostileReference nextRef = refe.Next();
                if (!refe.GetSource().GetOwner().CanSeeOrDetect(GetOwner()))
                {
                    nextRef = refe.Next();
                    refe.RemoveReference();
                }
                refe = nextRef;
            }
        }
        // delete one reference, defined by Unit
        public void DeleteReference(Unit creature)
        {
            HostileReference refe = GetFirst();

            while (refe != null)
            {
                HostileReference nextRef = refe.Next();
                if (refe.GetSource().GetOwner() == creature)
                {
                    refe.RemoveReference();
                    break;
                }
                refe = nextRef;
            }
        }
        // delete all references out of specified range
        public void DeleteReferencesOutOfRange(float range)
        {
            HostileReference refe = GetFirst();

            range = range * range;
            while (refe != null)
            {
                HostileReference nextRef = refe.Next();
                Unit             owner   = refe.GetSource().GetOwner();
                if (!owner.IsActiveObject() && owner.GetExactDist2dSq(GetOwner()) > range)
                {
                    refe.RemoveReference();
                }
                refe = nextRef;
            }
        }