OpenHacknet/CollidableRectangle.cs

74 lines
1.6 KiB
C#
Raw Permalink Normal View History

2015-10-27 23:04:18 -04:00
using Microsoft.Xna.Framework;
2015-10-27 22:34:58 -04:00
namespace Hacknet
{
public struct CollidableRectangle
{
private static readonly CollidableRectangle z = new CollidableRectangle(0.0f, 0.0f, Vector2.Zero);
public Vector2 position;
private float b_width;
private float b_height;
public Rectangle ck;
public static CollidableRectangle Zero
{
get { return z; }
}
public Vector2 pos
{
get { return position; }
set
{
position = value;
ck.X = (int) pos.X;
ck.Y = (int) pos.Y;
}
}
public float Width
{
get { return b_width; }
set
{
b_width = value;
ck.Width = (int) value;
}
}
public float Height
{
get { return b_height; }
set
{
b_height = value;
ck.Height = (int) value;
}
}
public Rectangle checkable
{
get { return ck; }
}
public CollidableRectangle(float w, float h, Vector2 p)
{
b_width = w;
b_height = h;
position = p;
ck = new Rectangle();
}
public override bool Equals(object obj)
{
if (!(obj is CollidableRectangle))
return false;
return ((CollidableRectangle) obj).checkable.Equals(checkable);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}