using System;

[Serializable]
public struct AbsoluteZone {

    public int x;

    public int y;

    public int width;

    public int height;

    public static AbsoluteZone Create(RelativeZone rZone, Vector2I source)
    {
        AbsoluteZone aZone = new AbsoluteZone();
        aZone.x = rZone.x + source.x;
        aZone.y = rZone.y + source.y;
        aZone.width = rZone.width;
        aZone.height = rZone.height;
        return aZone;
    }

    public bool Collides(AbsoluteZone otherZone)
    {
        return MinX <= otherZone.MaxX && MinY <= otherZone.MaxY && otherZone.MinX <= MaxX && otherZone.MinY <= MaxY;
    }

    public int MinX
    {
        get
        {
            return x;
        }
    }

    public int MinY
    {
        get
        {
            return y;
        }
    }

    public int MaxX
    {
        get
        {
            return x+width-1;
        }
    }

    public int MaxY
    {
        get
        {
            return y+height-1;
        }
    }

    public override string ToString()
    {
        return x + ", " + y + ", " + width + ", " + height;
    }

}
