Пример #1
0
        // 11Apr2013-04:42UTC chinajade
        public static HuntingGroundsType GetOrCreate(XElement parentElement, string elementName,
                                                     WaypointType defaultHuntingGroundCenter = null, double?forcedTolerance = null)
        {
            var huntingGrounds = new HuntingGroundsType(parentElement
                                                        .Elements()
                                                        .DefaultIfEmpty(new XElement(elementName))
                                                        .FirstOrDefault(elem => (elem.Name == elementName)));

            if (!huntingGrounds.IsAttributeProblem)
            {
                if (forcedTolerance.HasValue)
                {
                    foreach (var waypoint in huntingGrounds.Waypoints)
                    {
                        waypoint.ArrivalTolerance = forcedTolerance.Value;
                    }
                }

                // If user didn't provide a HuntingGrounds, and he provided a default center point, add it...
                if (!huntingGrounds.Waypoints.Any() && (defaultHuntingGroundCenter != null))
                {
                    huntingGrounds.Waypoints.Add(defaultHuntingGroundCenter);
                }

                if (!huntingGrounds.Waypoints.Any())
                {
                    QBCLog.Error("Neither the X/Y/Z attributes nor the <{0}> sub-element has been specified.",
                                 elementName);
                    huntingGrounds.IsAttributeProblem = true;
                }
            }

            return(huntingGrounds);
        }
Пример #2
0
        public Queue <WaypointType> FindPath_Egress(WoWUnit mobToAvoid)
        {
            var theWayOut = new List <WaypointType>(Waypoints);

            theWayOut.Reverse();

            WaypointType egressStartPoint =
                (from waypoint in theWayOut
                 let mobDistanceToPoint = (mobToAvoid != null)
                                              ? waypoint.Location.Distance(mobToAvoid.Location)
                                              : float.MaxValue
                                          let myDistanceToPoint = waypoint.Location.Distance(StyxWoW.Me.Location)
                                                                  where
                                                                  myDistanceToPoint < mobDistanceToPoint
                                                                  orderby
                                                                  myDistanceToPoint
                                                                  select waypoint)
                .FirstOrDefault();

            while (theWayOut[0] != egressStartPoint)
            {
                theWayOut.RemoveAt(0);
            }

            return(new Queue <WaypointType>(theWayOut));
        }
Пример #3
0
        // 22Mar2013-11:49UTC chinajade
        public HuntingGroundsType(XElement xElement)
            : base(xElement)
        {
            try
            {
                // Acquire the visit strategy...
                var waypointVisitStrategy = GetAttributeAsNullable <WaypointVisitStrategyType>("WaypointVisitStrategy", false, null, null)
                                            ?? WaypointVisitStrategyType.Random;
                SetWaypointStrategy(waypointVisitStrategy, false);

                // Acquire the waypoints...
                Waypoints = new List <WaypointType>();
                if (xElement != null)
                {
                    var waypointElementsQuery =
                        from element in xElement.Elements()
                        where
                        (element.Name == "Hotspot") ||
                        (element.Name == "Waypoint") ||
                        (element.Name == "WaypointType")
                        select element;

                    foreach (XElement childElement in waypointElementsQuery)
                    {
                        var waypoint = new WaypointType(childElement);

                        if (!waypoint.IsAttributeProblem)
                        {
                            Waypoints.Add(waypoint);
                        }

                        IsAttributeProblem |= waypoint.IsAttributeProblem;
                    }
                }

                HandleAttributeProblem();
            }

            catch (Exception except)
            {
                if (Query.IsExceptionReportingNeeded(except))
                {
                    QBCLog.Exception(except, "PROFILE PROBLEM with \"{0}\"", xElement.ToString());
                }
                IsAttributeProblem = true;
            }
        }
Пример #4
0
        public Queue <WaypointType> FindPath_Ingress()
        {
            var theWayIn = new List <WaypointType>(Waypoints);

            WaypointType ingressStartPoint =
                (from waypoint in theWayIn
                 let myDistanceToPoint = waypoint.Location.Distance(StyxWoW.Me.Location)
                                         orderby
                                         myDistanceToPoint
                                         select waypoint)
                .FirstOrDefault();

            while (theWayIn[0] != ingressStartPoint)
            {
                theWayIn.RemoveAt(0);
            }

            return(new Queue <WaypointType>(theWayIn));
        }
        public HuntingGroundsType(XElement xElement)
            : base(xElement)
        {
            try
            {
                WaypointVisitStrategy = GetAttributeAsNullable <WaypointVisitStrategyType>("WaypointVisitStrategy", false, null, null) ?? WaypointVisitStrategyType.Random;

                Waypoints = new List <WaypointType>();

                int unnamedWaypointNumber = 0;
                foreach (XElement childElement in xElement.Elements().Where(elem => (elem.Name == "Hotspot")))
                {
                    var waypoint = new WaypointType(childElement);

                    if (!waypoint.IsAttributeProblem)
                    {
                        if (string.IsNullOrEmpty(waypoint.Name))
                        {
                            waypoint.Name = string.Format("UnnamedWaypoint{0}", ++unnamedWaypointNumber);
                        }
                        Waypoints.Add(waypoint);
                    }

                    IsAttributeProblem |= waypoint.IsAttributeProblem;
                }

                OnStart_HandleAttributeProblem();
            }

            catch (Exception except)
            {
                if (QuestBehaviorBase.IsExceptionReportingNeeded(except))
                {
                    QuestBehaviorBase.LogError("[PROFILE PROBLEM with \"{0}\"]: {1}\nFROM HERE ({2}):\n{3}\n",
                                               xElement.ToString(), except.Message, except.GetType().Name,
                                               except.StackTrace);
                }
                IsAttributeProblem = true;
            }
        }
Пример #6
0
        public HuntingGroundsType(XElement xElement)
            : base(xElement)
        {
            try
            {
                WaypointVisitStrategy = GetAttributeAsNullable<WaypointVisitStrategyType>("WaypointVisitStrategy", false, null, null) ?? WaypointVisitStrategyType.Random;

                Waypoints = new List<WaypointType>();

                int unnamedWaypointNumber = 0;
                foreach (XElement childElement in xElement.Elements().Where(elem => (elem.Name == "Hotspot")))
                {
                    var waypoint = new WaypointType(childElement);

                    if (!waypoint.IsAttributeProblem)
                    {
                        if (string.IsNullOrEmpty(waypoint.Name))
                            {  waypoint.Name = string.Format("UnnamedWaypoint{0}", ++unnamedWaypointNumber); }
                        Waypoints.Add(waypoint);
                    }

                    IsAttributeProblem |= waypoint.IsAttributeProblem;
                }

                OnStart_HandleAttributeProblem();
            }

            catch (Exception except)
            {
                if (QuestBehaviorBase.IsExceptionReportingNeeded(except))
                {
                    QuestBehaviorBase.LogError("[PROFILE PROBLEM with \"{0}\"]: {1}\nFROM HERE ({2}):\n{3}\n",
                                               xElement.ToString(), except.Message, except.GetType().Name,
                                               except.StackTrace);
                }
                IsAttributeProblem = true;
            }
        }
Пример #7
0
        public SafePathType(XElement xElement, double defaultEgressDistance)
            : base(xElement)
        {
            try
            {
                DismissPet     = GetAttributeAsNullable <bool>("DismissPet", false, null, null) ?? false;
                EgressDistance = GetAttributeAsNullable <double>("EgressDistance", false, null, null)
                                 ?? defaultEgressDistance;
                Strategy = GetAttributeAsNullable <StrategyType>("Strategy", false, null, null)
                           ?? StrategyType.StalkMobAtAvoidDistance;

                Waypoints = new List <WaypointType>();
                foreach (XElement childElement in xElement.Elements().Where(elem => (elem.Name == "Hotspot")))
                {
                    var waypoint = new WaypointType(childElement);

                    if (!waypoint.IsAttributeProblem)
                    {
                        Waypoints.Add(waypoint);
                    }

                    IsAttributeProblem |= waypoint.IsAttributeProblem;
                }

                OnStart_HandleAttributeProblem();
            }

            catch (Exception except)
            {
                if (QuestBehaviorBase.IsExceptionReportingNeeded(except))
                {
                    QuestBehaviorBase.LogError("[PROFILE PROBLEM with \"{0}\"]: {1}\nFROM HERE ({2}):\n{3}\n",
                                               xElement.ToString(), except.Message, except.GetType().Name,
                                               except.StackTrace);
                }
                IsAttributeProblem = true;
            }
        }
Пример #8
0
        public SafePathType(XElement xElement, double defaultEgressDistance)
            : base(xElement)
        {
            try
            {
                DismissPet     = GetAttributeAsNullable <bool>("DismissPet", false, null, null) ?? false;
                EgressDistance = GetAttributeAsNullable <double>("EgressDistance", false, null, null)
                                 ?? defaultEgressDistance;
                Strategy = GetAttributeAsNullable <StrategyType>("Strategy", false, null, null)
                           ?? StrategyType.StalkMobAtAvoidDistance;

                Waypoints = new List <WaypointType>();
                foreach (XElement childElement in xElement.Elements().Where(elem => (elem.Name == "Hotspot")))
                {
                    var waypoint = new WaypointType(childElement);

                    if (!waypoint.IsAttributeProblem)
                    {
                        Waypoints.Add(waypoint);
                    }

                    IsAttributeProblem |= waypoint.IsAttributeProblem;
                }

                HandleAttributeProblem();
            }

            catch (Exception except)
            {
                if (Query.IsExceptionReportingNeeded(except))
                {
                    QBCLog.Exception(except, "PROFILE PROBLEM with \"{0}\"", xElement.ToString());
                }
                IsAttributeProblem = true;
            }
        }
Пример #9
0
        // We must support 'implied containers' for backward compatibility purposes.
        // An 'implied container' is just a list of <Hotspot> without the <HuntingGrounds> container.  As such, we use defaults.
        // This method will first look for the 'new style' (with container), and if that fails, looks for just a list of hotspots with
        // which we can construct the object.
        // 22Apr2013-10:29UTC chinajade
        public static HuntingGroundsType GetOrCreate_ImpliedContainer(XElement parentElement, string elementName, WaypointType defaultHuntingGroundCenter = null)
        {
            var huntingGrounds = GetOrCreate(parentElement, elementName, defaultHuntingGroundCenter);

            // If 'new form' succeeded, we're done...
            if (!huntingGrounds.IsAttributeProblem)
            {
                return(huntingGrounds);
            }

            // 'Old form' we have to dig out the Hotspots manually...
            huntingGrounds = new HuntingGroundsType(new XElement(elementName));
            if (!huntingGrounds.IsAttributeProblem)
            {
                var waypoints = new List <WaypointType>();

                int unnamedWaypointNumber = 0;
                foreach (XElement childElement in parentElement.Elements().Where(elem => (elem.Name == "Hotspot")))
                {
                    var waypoint = new WaypointType(childElement);

                    if (!waypoint.IsAttributeProblem)
                    {
                        if (string.IsNullOrEmpty(waypoint.Name))
                        {
                            waypoint.Name = string.Format("UnnamedWaypoint{0}", ++unnamedWaypointNumber);
                        }
                        waypoints.Add(waypoint);
                    }

                    huntingGrounds.IsAttributeProblem |= waypoint.IsAttributeProblem;
                }
            }

            return(huntingGrounds);
        }
Пример #10
0
        public SafePathType(XElement xElement, double defaultEgressDistance)
            : base(xElement)
        {
            try
            {
                DismissPet = GetAttributeAsNullable<bool>("DismissPet", false, null, null) ?? false;
                EgressDistance = GetAttributeAsNullable<double>("EgressDistance", false, null, null)
                                    ?? defaultEgressDistance;
                Strategy = GetAttributeAsNullable<StrategyType>("Strategy", false, null, null)
                            ?? StrategyType.StalkMobAtAvoidDistance;

                Waypoints = new List<WaypointType>();
                foreach (XElement childElement in xElement.Elements().Where(elem => (elem.Name == "Hotspot")))
                {
                    var waypoint = new WaypointType(childElement);

                    if (!waypoint.IsAttributeProblem)
                        { Waypoints.Add(waypoint); }

                    IsAttributeProblem |= waypoint.IsAttributeProblem;
                }

                OnStart_HandleAttributeProblem();
            }

            catch (Exception except)
            {
                if (QuestBehaviorBase.IsExceptionReportingNeeded(except))
                {
                    QuestBehaviorBase.LogError("[PROFILE PROBLEM with \"{0}\"]: {1}\nFROM HERE ({2}):\n{3}\n",
                                               xElement.ToString(), except.Message, except.GetType().Name,
                                               except.StackTrace);
                }
                IsAttributeProblem = true;
            }
        }