public static bool IsNearStructure(Husk husk, Structure structure) { EntityHitbox hitbox = GetHitbox(husk); if (structure != null) { return(IsNearStructure(hitbox, structure)); } return(false); }
public static bool IsNearClosestStructure(Husk husk, out Structure closest) { EntityHitbox hitbox = GetHitbox(husk); closest = GetClosestStructure(husk); if (closest != null) { return(CanSeeStructure(hitbox, closest)); } return(false); }
internal static IEnumerable <Structure> GetVisibleStructures(EntityHitbox hitbox, IEnumerable <Structure> structures) { if (!(structures?.Count() > 0)) { yield break; } foreach (Structure structure in structures) { if (CanSeeStructure(hitbox, structure)) { yield return(structure); } } }
internal static Structure GetClosestStructure(Husk husk) { EntityHitbox hitbox = GetHitbox(husk); // FIELD // SECTOR // WORLD // AREA (all structures are instant) if (!IsInLocation(husk, out Sector sector)) { throw new ArgumentException("The specified Husk is not currently within a valid location."); } // this change now only gets the closest VISIBLE structure // GetVisibleStructures(hitbox, sector.Structures) return(GetClosestStructure(hitbox, sector.Structures)); }
internal static Structure GetClosestStructure(EntityHitbox hitbox, IEnumerable <Structure> structures) { Structure closest = null; float nearest = float.MaxValue; foreach (Structure structure in structures) { Line line = GetLineToRegion(hitbox.X, hitbox.Y, structure.Shape); float dist = line.GetLength(); if (dist < nearest) { nearest = dist; closest = structure; } } return(closest); }
private static void DrawHitboxOn(Canvas canvas, EntityHitbox hitbox, ImmutableColor sightColor, ImmutableColor reachColor, ImmutableColor originColor) { DrawCircleOn(canvas, hitbox.Sight, sightColor); DrawCircleOn(canvas, hitbox.Reach, reachColor); DrawPointOn(canvas, hitbox.X, hitbox.Y, originColor); }
internal static bool CanSeeStructure(EntityHitbox hitbox, Structure structure) => CanSeeRegion(hitbox, structure.Shape);
internal static bool IsNearStructure(EntityHitbox hitbox, Structure structure) => IsNearRegion(hitbox, structure.Shape);
public static bool CanSeePoint(Husk husk, float x, float y) { EntityHitbox hitbox = GetHitbox(husk); return(CanSeePoint(hitbox, x, y)); }
public static bool CanSeePoint(Husk husk, Vector2 point) { EntityHitbox hitbox = GetHitbox(husk); return(CanSeePoint(hitbox, point)); }