Syntriax.Engine/Engine.Core/Transform.cs

57 lines
1.3 KiB
C#

using System;
using Syntriax.Engine.Core.Abstract;
namespace Syntriax.Engine.Core;
[System.Diagnostics.DebuggerDisplay("Position: {Position.ToString(), nq}, Scale: {Scale.ToString(), nq}, Rotation: {Rotation}")]
public class Transform : ITransform
{
public Action<ITransform>? OnPositionChanged { get; set; } = null;
public Action<ITransform>? OnScaleChanged { get; set; } = null;
public Action<ITransform>? OnRotationChanged { get; set; } = null;
private Vector2D _position = Vector2D.Zero;
private Vector2D _scale = Vector2D.One;
private float _rotation = 0f;
public Vector2D Position
{
get => _position;
set
{
if (value == _position)
return;
_position = value;
OnPositionChanged?.Invoke(this);
}
}
public Vector2D Scale
{
get => _scale;
set
{
if (value == _scale)
return;
_scale = value;
OnScaleChanged?.Invoke(this);
}
}
public float Rotation
{
get => _rotation;
set
{
if (value == _rotation)
return;
_rotation = value;
OnRotationChanged?.Invoke(this);
}
}
}