From 2f5c04e66b1d13c230105e8f5f28c01050f10cdd Mon Sep 17 00:00:00 2001 From: Syntriax Date: Sun, 19 Oct 2025 00:22:30 +0300 Subject: [PATCH] feat: ITransform.OnTransformUpdated event added --- Engine.Core/Abstract/ITransform2D.cs | 7 ++++++- Engine.Core/Transform2D.cs | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Engine.Core/Abstract/ITransform2D.cs b/Engine.Core/Abstract/ITransform2D.cs index d899386..46f3bf9 100644 --- a/Engine.Core/Abstract/ITransform2D.cs +++ b/Engine.Core/Abstract/ITransform2D.cs @@ -16,10 +16,15 @@ public interface ITransform2D : IBehaviour Event OnScaleChanged { get; } /// - /// Event triggered when the of the changes. + /// Event triggered when the of the changes. /// Event OnRotationChanged { get; } + /// + /// Event triggered when any of the properties of the gets updated. + /// + Event OnTransformUpdated { get; } + /// /// The pointing upwards in world space. /// diff --git a/Engine.Core/Transform2D.cs b/Engine.Core/Transform2D.cs index 4b68c81..5fea3af 100644 --- a/Engine.Core/Transform2D.cs +++ b/Engine.Core/Transform2D.cs @@ -8,6 +8,7 @@ public class Transform2D : Behaviour, ITransform2D public Event OnPositionChanged { get; } = new(); public Event OnScaleChanged { get; } = new(); public Event OnRotationChanged { get; } = new(); + public Event OnTransformUpdated { get; } = new(); private Vector2D _position = Vector2D.Zero; private Vector2D _scale = Vector2D.One; @@ -37,6 +38,7 @@ public class Transform2D : Behaviour, ITransform2D UpdateLocalPosition(); OnPositionChanged.Invoke(this, new(previousPosition)); + OnTransformUpdated.Invoke(this); } } @@ -53,6 +55,7 @@ public class Transform2D : Behaviour, ITransform2D UpdateLocalScale(); OnScaleChanged.Invoke(this, new(previousScale)); + OnTransformUpdated.Invoke(this); } } @@ -69,6 +72,7 @@ public class Transform2D : Behaviour, ITransform2D UpdateLocalRotation(); OnRotationChanged.Invoke(this, new(previousRotation)); + OnTransformUpdated.Invoke(this); } } @@ -85,6 +89,7 @@ public class Transform2D : Behaviour, ITransform2D UpdatePosition(); OnPositionChanged.Invoke(this, new(previousPosition)); + OnTransformUpdated.Invoke(this); } } @@ -104,6 +109,7 @@ public class Transform2D : Behaviour, ITransform2D UpdatePosition(); OnScaleChanged.Invoke(this, new(previousScale)); OnPositionChanged.Invoke(this, new(previousPosition)); + OnTransformUpdated.Invoke(this); } } @@ -120,6 +126,7 @@ public class Transform2D : Behaviour, ITransform2D UpdateRotation(); OnRotationChanged.Invoke(this, new(previousRotation)); + OnTransformUpdated.Invoke(this); } } @@ -131,6 +138,7 @@ public class Transform2D : Behaviour, ITransform2D UpdatePosition(); OnPositionChanged.Invoke(this, args); + OnTransformUpdated.Invoke(this); } private void RecalculateScale(ITransform2D _, ITransform2D.ScaleChangedArguments args) @@ -145,6 +153,7 @@ public class Transform2D : Behaviour, ITransform2D OnScaleChanged.Invoke(this, args); OnPositionChanged.Invoke(this, new(previousPosition)); + OnTransformUpdated.Invoke(this); } private void RecalculateRotation(ITransform2D _, ITransform2D.RotationChangedArguments args) @@ -159,6 +168,7 @@ public class Transform2D : Behaviour, ITransform2D OnRotationChanged.Invoke(this, args); OnPositionChanged.Invoke(this, new(previousPosition)); + OnTransformUpdated.Invoke(this); } private void UpdateLocalPosition() @@ -255,6 +265,7 @@ public class Transform2D : Behaviour, ITransform2D OnPositionChanged.Invoke(this, new(Position)); OnScaleChanged.Invoke(this, new(Scale)); OnRotationChanged.Invoke(this, new(Rotation)); + OnTransformUpdated.Invoke(this); } private void LookForTransform2D(IBehaviourController sender, IBehaviourController.BehaviourAddedArguments args)