Syntriax.Engine/Engine.Core/Transform.cs

56 lines
1.1 KiB
C#
Raw Normal View History

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;
private Vector2D _position = Vector2D.Zero;
private Vector2D _scale = Vector2D.One;
2023-11-23 22:07:49 +03:00
private float _rotation = 0f;
public Vector2D Position
2023-11-23 22:07:49 +03:00
{
get => _position;
set
{
if (value == _position)
return;
_position = value;
OnPositionChanged?.Invoke(this);
}
}
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);
}
}
}