58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
|
using System;
|
||
|
|
||
|
using Microsoft.Xna.Framework;
|
||
|
|
||
|
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 Vector2 _position = Vector2.Zero;
|
||
|
private Vector2 _scale = Vector2.One;
|
||
|
private float _rotation = 0f;
|
||
|
|
||
|
public Vector2 Position
|
||
|
{
|
||
|
get => _position;
|
||
|
set
|
||
|
{
|
||
|
if (value == _position)
|
||
|
return;
|
||
|
|
||
|
_position = value;
|
||
|
OnPositionChanged?.Invoke(this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Vector2 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);
|
||
|
}
|
||
|
}
|
||
|
}
|