SunsetHigh.Character.inRange C# (CSharp) Метод

inRange() публичный Метод

Checks in this Character is within a given range with another Interactable to perform any action. The range is another rectangle a given number of pixels thicker than the sprite's drawing rectangle. E.g. talk to another character, pickup an item, collision detection
public inRange ( IInteractable other, int offset ) : bool
other IInteractable The other Interactable to range check against
offset int The pixels offset for the range check
Результат bool
        public bool inRange(IInteractable other, int offset)
        {
            Rectangle copy = other.getBoundingRect();   // not sure if it returns the reference
            Rectangle inflatedRect;
            inflatedRect.X = copy.X - offset;
            inflatedRect.Y = copy.Y - offset;
            inflatedRect.Width = copy.Width + offset * 2;
            inflatedRect.Height = copy.Height + offset * 2;
            return this.getBoundingRect().Intersects(inflatedRect);
        }