141 lines
6.1 KiB
C#
141 lines
6.1 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Syntriax.Engine.Core.Abstract;
|
|
|
|
/// <summary>
|
|
/// Represents the transformation properties of an object such as position, scale, and rotation.
|
|
/// </summary>
|
|
public interface ITransform : IAssignableGameObject, IEnumerable<ITransform>
|
|
{
|
|
/// <summary>
|
|
/// Event triggered when the <see cref="Position"/> of the <see cref="ITransform"/> changes.
|
|
/// </summary>
|
|
event OnPositionChangedEventHandler? OnPositionChanged;
|
|
|
|
/// <summary>
|
|
/// Event triggered when the <see cref="Scale"/> of the <see cref="ITransform"/> changes.
|
|
/// </summary>
|
|
event OnScaleChangedEventHandler? OnScaleChanged;
|
|
|
|
/// <summary>
|
|
/// Event triggered when the <see cref="Rotation"/> of the <see cref="ITransform"/> changes.
|
|
/// </summary>
|
|
event OnRotationChangedEventHandler? OnRotationChanged;
|
|
|
|
/// <summary>
|
|
/// Event triggered when the <see cref="Parent"/> of the <see cref="ITransform"/> changes. The second parameter is the old <see cref="ITransform"/>.
|
|
/// </summary>
|
|
event OnParentChangedEventHandler? OnParentChanged;
|
|
|
|
/// <summary>
|
|
/// Event triggered when a new <see cref="ITransform"/> is added to the <see cref="Children"/>.
|
|
/// </summary>
|
|
event OnChildrenAddedEventHandler? OnChildrenAdded;
|
|
|
|
/// <summary>
|
|
/// Event triggered when an <see cref="ITransform"/> is removed from the <see cref="Children"/>.
|
|
/// </summary>
|
|
event OnChildrenRemovedEventHandler? OnChildrenRemoved;
|
|
|
|
/// <summary>
|
|
/// The world position of the <see cref="ITransform"/> in 2D space.
|
|
/// </summary>
|
|
Vector2D Position { get; set; }
|
|
|
|
/// <summary>
|
|
/// The world scale of the <see cref="ITransform"/>.
|
|
/// </summary>
|
|
Vector2D Scale { get; set; }
|
|
|
|
/// <summary>
|
|
/// The world rotation of the <see cref="ITransform"/> in degrees.
|
|
/// </summary>
|
|
float Rotation { get; set; }
|
|
|
|
/// <summary>
|
|
/// The local position of the <see cref="ITransform"/> in 2D space.
|
|
/// </summary>
|
|
Vector2D LocalPosition { get; set; }
|
|
|
|
/// <summary>
|
|
/// The local scale of the <see cref="ITransform"/>.
|
|
/// </summary>
|
|
Vector2D LocalScale { get; set; }
|
|
|
|
/// <summary>
|
|
/// The local rotation of the <see cref="ITransform"/> in degrees.
|
|
/// </summary>
|
|
float LocalRotation { get; set; }
|
|
|
|
/// <summary>
|
|
/// The parent <see cref="ITransform"/> of the <see cref="ITransform"/>.
|
|
/// </summary>
|
|
ITransform? Parent { get; }
|
|
|
|
/// <summary>
|
|
/// The <see cref="ITransform"/>s that have this <see cref="ITransform"/> as their <see cref="Parent"/>.
|
|
/// </summary>
|
|
IReadOnlyList<ITransform> Children { get; }
|
|
|
|
/// <summary>
|
|
/// Sets the parent <see cref="ITransform"/> of this <see cref="ITransform"/>.
|
|
/// </summary>
|
|
/// <param name="transform">The parent <see cref="ITransform"/> to set.</param>
|
|
void SetParent(ITransform? transform);
|
|
|
|
/// <summary>
|
|
/// Adds a child <see cref="ITransform"/> to this <see cref="ITransform"/>.
|
|
/// </summary>
|
|
/// <param name="transform">The child <see cref="ITransform"/> to add.</param>
|
|
void AddChild(ITransform transform);
|
|
|
|
/// <summary>
|
|
/// Removes a child <see cref="ITransform"/> from this <see cref="ITransform"/>.
|
|
/// </summary>
|
|
/// <param name="transform">The child <see cref="ITransform"/> to remove.</param>
|
|
void RemoveChild(ITransform transform);
|
|
|
|
/// <summary>
|
|
/// Delegate for the event triggered when the <see cref="ITransform"/>'s rotation changes.
|
|
/// </summary>
|
|
/// <param name="sender">The <see cref="ITransform"/> that the parent has changed.</param>
|
|
/// <param name="previousPosition">The previous <see cref="Position"/> of the <see cref="ITransform"/>.</param>
|
|
delegate void OnPositionChangedEventHandler(ITransform sender, Vector2D previousPosition);
|
|
|
|
/// <summary>
|
|
/// Delegate for the event triggered when the <see cref="ITransform"/>'s rotation changes.
|
|
/// </summary>
|
|
/// <param name="sender">The <see cref="ITransform"/> that the parent has changed.</param>
|
|
/// <param name="previousScale">The previous <see cref="Scale"/> of the <see cref="ITransform"/>.</param>
|
|
delegate void OnScaleChangedEventHandler(ITransform sender, Vector2D previousScale);
|
|
|
|
/// <summary>
|
|
/// Delegate for the event triggered when the <see cref="ITransform"/>'s rotation changes.
|
|
/// </summary>
|
|
/// <param name="sender">The <see cref="ITransform"/> that the parent has changed.</param>
|
|
/// <param name="previousRotation">The previous <see cref="Rotation"/> of the <see cref="ITransform"/>.</param>
|
|
delegate void OnRotationChangedEventHandler(ITransform sender, float previousRotation);
|
|
|
|
/// <summary>
|
|
/// Delegate for the event triggered when the <see cref="ITransform"/>'s parent changes.
|
|
/// </summary>
|
|
/// <param name="sender">The <see cref="ITransform"/> that the parent has changed.</param>
|
|
/// <param name="previousParent">The previous <see cref="ITransform"/> the sender was a child of.</param>
|
|
/// <param name="newParent">The new and current <see cref="ITransform"/> the sender is a child of.</param>
|
|
delegate void OnParentChangedEventHandler(ITransform sender, ITransform? previousParent, ITransform? newParent);
|
|
|
|
/// <summary>
|
|
/// Delegate for the event triggered when a new <see cref="ITransform"/> added as a child.
|
|
/// </summary>
|
|
/// <param name="sender">The parent <see cref="ITransform"/> this event is being called from.</param>
|
|
/// <param name="childrenAdded">The <see cref="ITransform"/> that got removed as a children of the sender <see cref="ITransform"/>.</param>
|
|
delegate void OnChildrenAddedEventHandler(ITransform sender, ITransform childrenAdded);
|
|
|
|
/// <summary>
|
|
/// Delegate for the event triggered when a new <see cref="ITransform"/> removed from being a child.
|
|
/// </summary>
|
|
/// <param name="sender">The parent <see cref="ITransform"/> this event is being called from.</param>
|
|
/// <param name="childrenAdded">The <see cref="ITransform"/> that got removed as a children of the sender <see cref="ITransform"/>.</param>
|
|
delegate void OnChildrenRemovedEventHandler(ITransform sender, ITransform childrenRemoved);
|
|
}
|