Ejemplo n.º 1
0
        // 11Apr2013-04:42UTC chinajade
        public static SafePathType GetOrCreate(XElement parentElement, string elementName, double defaultEgressDistance, WoWPoint?safespotLocation = null)
        {
            if (safespotLocation.HasValue &&
                ((safespotLocation.Value == WoWPoint.Empty) || safespotLocation.Value == WoWPoint.Zero))
            {
                safespotLocation = null;
            }

            var safePath = new SafePathType(parentElement
                                            .Elements()
                                            .DefaultIfEmpty(new XElement(elementName))
                                            .FirstOrDefault(elem => (elem.Name == elementName)),
                                            defaultEgressDistance);

            if (!safePath.IsAttributeProblem)
            {
                // If user didn't provide a HuntingGrounds, and he provided a default center point, add it...
                if (!safePath.Waypoints.Any() && safespotLocation.HasValue)
                {
                    safePath.AppendWaypoint(safespotLocation.Value, "safe spot", Navigator.PathPrecision);
                }

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

            return(safePath);
        }
        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;
            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
0
        public WaypointType(XElement xElement)
            : base(xElement)
        {
            try
            {
                Location = GetAttributeAsNullable <WoWPoint>("", true, ConstrainAs.WoWPointNonEmpty, null) ?? WoWPoint.Empty;
                Name     = GetAttributeAs <string>("Name", false, ConstrainAs.StringNonEmpty, null) ?? string.Empty;
                Radius   = GetAttributeAsNullable <double>("Radius", false, ConstrainAs.Range, null) ?? 10.0;

                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;
            }
        }
        // 11Apr2013-04:42UTC chinajade
        public static HuntingGroundsType GetOrCreate(XElement parentElement, string elementName, WoWPoint?defaultHuntingGroundCenter = null)
        {
            var huntingGrounds = new HuntingGroundsType(parentElement
                                                        .Elements()
                                                        .DefaultIfEmpty(new XElement(elementName))
                                                        .FirstOrDefault(elem => (elem.Name == elementName)));

            if (!huntingGrounds.IsAttributeProblem)
            {
                // If user didn't provide a HuntingGrounds, and he provided a default center point, add it...
                if (!huntingGrounds.Waypoints.Any() && defaultHuntingGroundCenter.HasValue)
                {
                    huntingGrounds.AppendWaypoint(defaultHuntingGroundCenter.Value, "hunting ground center", Navigator.PathPrecision);
                }

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

            return(huntingGrounds);
        }