private bool TryGetHotSpot(XElement xHotSpot, out Profile.HotSpot hotSpot) { string xyz = string.Empty; if ((string)xHotSpot.Attribute("XYZ") != null) { xyz = xHotSpot.Attribute("XYZ").Value; } else { this._errorMessages.add("Couldnt find XYZ attribute in hotspot tag. Skipping. line:" + xHotSpot.ToString()); hotSpot = new Profile.HotSpot(new Clio.Utilities.Vector3()); return(false); } int radius = 0; if ((string)xHotSpot.Attribute("Radius") != null) { try{ radius = Int32.Parse(xHotSpot.Attribute("Radius").Value); }catch (Exception) { this._errorMessages.add("Radius attribute parse failed. setting to 100. Line: " + xHotSpot.ToString()); radius = 100; } hotSpot = new Profile.HotSpot(new Clio.Utilities.Vector3(xyz), radius); } else { this._errorMessages.add("Radius attribute not found in hotspot tag. Setting to 100. line: " + xHotSpot.ToString()); hotSpot = new Profile.HotSpot(new Clio.Utilities.Vector3(xyz)); } return(true); }
private Profile.HotSpot GetBasicHotSpot(XElement hotSpotElem) { var xyz = hotSpotElem.Attribute("XYZ")?.Value; var radiusStr = hotSpotElem.Attribute("Radius")?.Value; if (xyz == null) { throw new ParsingException("HotSpot is missing XYZ attribute"); } try { var hotSpot = new Profile.HotSpot(new Vector3(xyz)); if (int.TryParse(radiusStr, out var radius)) { hotSpot.Radius = radius; } return(hotSpot); } catch (Exception err) { Log.Bot.print(err.Message); throw new ParsingException("Unexpected error while parsing HotSpot"); } }