예제 #1
0
        public static bool IsNearStructure(Husk husk, Structure structure)
        {
            EntityHitbox hitbox = GetHitbox(husk);

            if (structure != null)
            {
                return(IsNearStructure(hitbox, structure));
            }

            return(false);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
 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);
 }
예제 #7
0
 internal static bool CanSeeStructure(EntityHitbox hitbox, Structure structure)
 => CanSeeRegion(hitbox, structure.Shape);
예제 #8
0
 internal static bool IsNearStructure(EntityHitbox hitbox, Structure structure)
 => IsNearRegion(hitbox, structure.Shape);
예제 #9
0
        public static bool CanSeePoint(Husk husk, float x, float y)
        {
            EntityHitbox hitbox = GetHitbox(husk);

            return(CanSeePoint(hitbox, x, y));
        }
예제 #10
0
        public static bool CanSeePoint(Husk husk, Vector2 point)
        {
            EntityHitbox hitbox = GetHitbox(husk);

            return(CanSeePoint(hitbox, point));
        }