private OptionalStats ReadOptionalStats(XElement optionalStatsEl) { var optionalStats = new OptionalStats(); foreach (var optionalStatsAttr in optionalStatsEl.Attributes()) { var optionalStatsAttrName = optionalStatsAttr.Name.ToString(); switch (optionalStatsAttrName) { case "boss": optionalStats.Boss = ReadBooleanLike(optionalStatsAttr.Value); break; case "bounceOnMovementFail": optionalStats.BounceOnMovementFail = ReadBooleanLike(optionalStatsAttr.Value); break; case "floating": optionalStats.Floating = ReadBooleanLike(optionalStatsAttr.Value); break; case "ignoreLiquids": optionalStats.IgnoreLiquids = ReadBooleanLike(optionalStatsAttr.Value); break; case "ignoreWalls": optionalStats.IgnoreWalls = ReadBooleanLike(optionalStatsAttr.Value); break; case "isMonkeyLike": optionalStats.IsMonkeyLike = ReadBooleanLike(optionalStatsAttr.Value); break; case "massive": optionalStats.Massive = ReadBooleanLike(optionalStatsAttr.Value); break; case "miniboss": optionalStats.Miniboss = ReadBooleanLike(optionalStatsAttr.Value); break; default: log.Debug($"Unknown optionalStats attribute: '{optionalStatsAttrName}'."); break; } } return(optionalStats); }
private static XElement WriteOptionalStats(OptionalStats optionalStats) { var optionalStatsEl = new XElement("optionalStats"); if (optionalStats.Floating) { optionalStatsEl.Add(new XAttribute("floating", "True")); } if (!optionalStats.BounceOnMovementFail) { optionalStatsEl.Add(new XAttribute("bounceOnMovementFail", "False")); } if (optionalStats.Boss) { optionalStatsEl.Add(new XAttribute("boss", "True")); } if (optionalStats.IgnoreLiquids) { optionalStatsEl.Add(new XAttribute("ignoreLiquids", "True")); } if (optionalStats.IgnoreWalls) { optionalStatsEl.Add(new XAttribute("ignoreWalls", "True")); } if (optionalStats.IsMonkeyLike) { optionalStatsEl.Add(new XAttribute("isMonkeyLike", "True")); } if (optionalStats.Massive) { optionalStatsEl.Add(new XAttribute("massive", "True")); } if (optionalStats.Miniboss) { optionalStatsEl.Add(new XAttribute("miniboss", "True")); } return(optionalStatsEl); }