public bool Intersects(RegionF region) { var quad = new Quad(region); return(region.Contains(Origin) || Intersects(quad.GetLeftLine()) || Intersects(quad.GetTopLine()) || Intersects(quad.GetRightLine()) || Intersects(quad.GetBottomLine())); }
// TODO: Use Engine.GetVisibleRegions(Husk husk); public bool Judge(Husk husk) { if (Ids?.Count() > 0) { return(Ids.Contains(husk.Location.Id)); } if (Region.HasValue) { Location location = husk.Location.GetLocation(); if (Structure.HasValue) { var results = location.Filter(Structure.Value); if (results.Any(x => (Interaction == InteractionType.View ? husk.Hitbox.Sight : husk.Hitbox.Reach) .Intersects(x.Shape))) { return(true); } } if (Location.HasValue) { if (Construct.HasValue && (location as Construct) != null) { if (!Construct.Value.HasFlag((location as Construct).Tag)) { return(false); } } if (!Location.Value.HasFlag(location.Type)) { return(false); } } if (!Region.Value.HasFlag(location.Subtype)) { return(false); } } if (X.HasValue && Y.HasValue) { float x = husk.Location.X; float y = husk.Location.Y; if (!string.IsNullOrWhiteSpace(Id)) { if (Id != husk.Location.Id) { return(false); } } if (Width > 0 && Height > 0) { return(RegionF.Contains(X.Value, Y.Value, Width, Height, x, y)); } if (Radius > 0) { return(CircleF.Contains(X.Value, Y.Value, Radius, x, y)); } return((Interaction == InteractionType.View ? husk.Hitbox.Sight : husk.Hitbox.Reach) .Contains(X.Value, Y.Value)); } if (!string.IsNullOrWhiteSpace(Id)) { if (Depth == BindDepth.In) { Location location = Engine.World.Find(Id); return(location.GetChildren().Any(x => x.Id == husk.Location.Id)); } return(Id == husk.Location.Id); } Console.WriteLine("No eligible regions were matched."); return(false); }