Amend Me
This commit is contained in:
@@ -5,9 +5,9 @@ namespace Syntriax.Engine.Core;
|
||||
[System.Diagnostics.DebuggerDisplay("Name: {UniverseObject.Name, nq} Position: {Position.ToString(), nq}, Scale: {Scale.ToString(), nq}, Rotation: {Rotation}")]
|
||||
public class Transform2D : Behaviour, ITransform2D
|
||||
{
|
||||
public Event<ITransform2D, Vector2D> OnPositionChanged { get; private set; } = new();
|
||||
public Event<ITransform2D, Vector2D> OnScaleChanged { get; private set; } = new();
|
||||
public Event<ITransform2D, float> OnRotationChanged { get; private set; } = new();
|
||||
public Event<ITransform2D, ITransform2D.PositionChangedArguments> OnPositionChanged { get; init; } = new();
|
||||
public Event<ITransform2D, ITransform2D.ScaleChangedArguments> OnScaleChanged { get; init; } = new();
|
||||
public Event<ITransform2D, ITransform2D.RotationChangedArguments> OnRotationChanged { get; init; } = new();
|
||||
|
||||
private Vector2D _position = Vector2D.Zero;
|
||||
private Vector2D _scale = Vector2D.One;
|
||||
@@ -31,7 +31,7 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
_position = value;
|
||||
|
||||
UpdateLocalPosition();
|
||||
OnPositionChanged?.Invoke(this, previousPosition);
|
||||
OnPositionChanged?.Invoke(this, new(previousPosition));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
_scale = value;
|
||||
|
||||
UpdateLocalScale();
|
||||
OnScaleChanged?.Invoke(this, previousScale);
|
||||
OnScaleChanged?.Invoke(this, new(previousScale));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
_rotation = value;
|
||||
|
||||
UpdateLocalRotation();
|
||||
OnRotationChanged?.Invoke(this, previousRotation);
|
||||
OnRotationChanged?.Invoke(this, new(previousRotation));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
_localPosition = value;
|
||||
|
||||
UpdatePosition();
|
||||
OnPositionChanged?.Invoke(this, previousPosition);
|
||||
OnPositionChanged?.Invoke(this, new(previousPosition));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
|
||||
UpdateScale();
|
||||
UpdatePosition();
|
||||
OnScaleChanged?.Invoke(this, previousScale);
|
||||
OnPositionChanged?.Invoke(this, previousPosition);
|
||||
OnScaleChanged?.Invoke(this, new(previousScale));
|
||||
OnPositionChanged?.Invoke(this, new(previousPosition));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,21 +114,21 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
_localRotation = value;
|
||||
|
||||
UpdateRotation();
|
||||
OnRotationChanged?.Invoke(this, previousRotation);
|
||||
OnRotationChanged?.Invoke(this, new(previousRotation));
|
||||
}
|
||||
}
|
||||
|
||||
private void RecalculatePosition(ITransform2D _, Vector2D previousPosition)
|
||||
private void RecalculatePosition(ITransform2D _, ITransform2D.PositionChangedArguments arguments)
|
||||
{
|
||||
if (parentTransform is null)
|
||||
return;
|
||||
|
||||
UpdatePosition();
|
||||
|
||||
OnPositionChanged?.Invoke(this, previousPosition);
|
||||
OnPositionChanged?.Invoke(this, arguments);
|
||||
}
|
||||
|
||||
private void RecalculateScale(ITransform2D _, Vector2D previousScale)
|
||||
private void RecalculateScale(ITransform2D _, ITransform2D.ScaleChangedArguments arguments)
|
||||
{
|
||||
if (parentTransform is null)
|
||||
return;
|
||||
@@ -138,11 +138,11 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
UpdateScale();
|
||||
UpdatePosition();
|
||||
|
||||
OnScaleChanged?.Invoke(this, previousScale);
|
||||
OnPositionChanged?.Invoke(this, previousPosition);
|
||||
OnScaleChanged?.Invoke(this, arguments);
|
||||
OnPositionChanged?.Invoke(this, new(previousPosition));
|
||||
}
|
||||
|
||||
private void RecalculateRotation(ITransform2D _, float previousRotation)
|
||||
private void RecalculateRotation(ITransform2D _, ITransform2D.RotationChangedArguments arguments)
|
||||
{
|
||||
if (parentTransform is null)
|
||||
return;
|
||||
@@ -152,8 +152,8 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
UpdateRotation();
|
||||
UpdatePosition();
|
||||
|
||||
OnRotationChanged?.Invoke(this, previousRotation);
|
||||
OnPositionChanged?.Invoke(this, previousPosition);
|
||||
OnRotationChanged?.Invoke(this, arguments);
|
||||
OnPositionChanged?.Invoke(this, new(previousPosition));
|
||||
}
|
||||
|
||||
private void UpdateLocalPosition()
|
||||
@@ -247,21 +247,21 @@ public class Transform2D : Behaviour, ITransform2D
|
||||
UpdateLocalScale();
|
||||
UpdateLocalRotation();
|
||||
|
||||
OnPositionChanged?.Invoke(this, Position);
|
||||
OnScaleChanged?.Invoke(this, Scale);
|
||||
OnRotationChanged?.Invoke(this, Rotation);
|
||||
OnPositionChanged?.Invoke(this, new(Position));
|
||||
OnScaleChanged?.Invoke(this, new(Scale));
|
||||
OnRotationChanged?.Invoke(this, new(Rotation));
|
||||
}
|
||||
|
||||
private void LookForTransform2D(IBehaviourController sender, IBehaviour behaviourAdded)
|
||||
private void LookForTransform2D(IBehaviourController sender, IBehaviourController.BehaviourAddedArguments arguments)
|
||||
{
|
||||
if (behaviourAdded is not ITransform2D transform2D)
|
||||
if (arguments.BehaviourAdded is not ITransform2D)
|
||||
return;
|
||||
|
||||
UpdateReferences(UniverseObject.Parent);
|
||||
}
|
||||
|
||||
private void OnParentChanged(IUniverseObject sender, IUniverseObject? previousParent, IUniverseObject? newParent)
|
||||
private void OnParentChanged(IUniverseObject sender, IUniverseObject.ParentChangedArguments arguments)
|
||||
{
|
||||
UpdateReferences(newParent);
|
||||
UpdateReferences(arguments.CurrentParent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user