public bool check(GameLocation loc) { bool ret = true; if (Children.Count > 0) { if (ChildrenCombine != "and") { ret = false; } int totalMet = 0; foreach (var child in Children) { bool childCheck = child.check(loc); if (childCheck) { ++totalMet; } switch (ChildrenCombine) { case "and": ret = ret && childCheck; break; case "or": ret = ret || childCheck; break; case "xor": ret = ret ^ childCheck; break; } } if (ChildrenCombine.StartsWith("atleast")) { ret = totalMet >= int.Parse(ChildrenCombine.Substring(7)); } else if (ChildrenCombine.StartsWith("exactly")) { ret = totalMet == int.Parse(ChildrenCombine.Substring(7)); } else if (ChildrenCombine != "and" && ChildrenCombine != "or" && ChildrenCombine != "xor") { throw new ArgumentException("Bad ChildrenCombine: " + ChildrenCombine); } } else if (MinTimeOfDay != -1 && Game1.timeOfDay < MinTimeOfDay) { ret = false; } else if (MaxTimeOfDay != -1 && Game1.timeOfDay > MaxTimeOfDay) { ret = false; } else if (Seasons != null && Seasons.Count() > 0 && !Seasons.Contains(Game1.currentSeason)) { ret = false; } else if (Locations != null && Locations.Count() > 0 && !Locations.Contains(loc.Name)) { ret = false; } else if (Game1.random.NextDouble() >= Math.Max(0.15, (Math.Min(0.5, loc.map.Layers[0].LayerWidth * loc.map.Layers[0].LayerHeight / ChancePerTile)))) { ret = false; } else if (RequireDarkOut && !Game1.isDarkOut()) { ret = false; } else if (!AllowRain && Game1.isRaining) { ret = false; } if (Not) { ret = !ret; } return(ret); }