LADXHD/InGame/GameObjects/Base/CObjects/CRectangle.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2023-12-14 22:21:22 +00:00
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);
}
}
}