LADXHD/InGame/GameObjects/Base/CObjects/CRectangle.cs
2023-12-14 17:21:22 -05:00

40 lines
1.1 KiB
C#

using Microsoft.Xna.Framework;
using ProjectZ.Base;
namespace ProjectZ.InGame.GameObjects.Base.CObjects
{
public class CRectangle
{
public RectangleF Rectangle;
public Rectangle OffsetSize;
private bool MoveZ;
public CRectangle(Rectangle rectangle)
{
Rectangle = rectangle;
}
public CRectangle(RectangleF rectangle)
{
Rectangle = rectangle;
}
public CRectangle(CPosition position, Rectangle offsetSize, bool moveZ = false)
{
OffsetSize = offsetSize;
position.AddPositionListener(typeof(CRectangle), UpdateRectangle);
UpdateRectangle(position);
MoveZ = moveZ;
}
public void UpdateRectangle(CPosition position)
{
Rectangle = new RectangleF(
position.X + OffsetSize.X,
position.Y + OffsetSize.Y + (MoveZ ? -position.Z : 0),
OffsetSize.Width, OffsetSize.Height);
}
}
}