2023-11-23 22:07:49 +03:00
|
|
|
using System;
|
|
|
|
|
|
|
|
using Syntriax.Engine.Core.Abstract;
|
|
|
|
|
|
|
|
namespace Syntriax.Engine.Core;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-01-22 22:45:40 +03:00
|
|
|
private Vector2D _position = Vector2D.Zero;
|
|
|
|
private Vector2D _scale = Vector2D.One;
|
2023-11-23 22:07:49 +03:00
|
|
|
private float _rotation = 0f;
|
|
|
|
|
2024-01-22 22:45:40 +03:00
|
|
|
public Vector2D Position
|
2023-11-23 22:07:49 +03:00
|
|
|
{
|
|
|
|
get => _position;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == _position)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_position = value;
|
|
|
|
OnPositionChanged?.Invoke(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-22 22:45:40 +03:00
|
|
|
public Vector2D Scale
|
2023-11-23 22:07:49 +03:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|