2023-11-23 22:07:49 +03:00
|
|
|
using System;
|
2024-02-06 12:34:18 +03:00
|
|
|
using System.Collections.Generic;
|
2023-11-23 22:07:49 +03:00
|
|
|
|
|
|
|
namespace Syntriax.Engine.Core.Abstract;
|
|
|
|
|
2024-02-01 12:14:53 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Represents the transformation properties of an object such as position, scale, and rotation.
|
|
|
|
/// </summary>
|
2024-02-06 12:04:51 +03:00
|
|
|
public interface ITransform : IAssignableGameObject, IEnumerable<ITransform>
|
2023-11-23 22:07:49 +03:00
|
|
|
{
|
2024-02-01 12:14:53 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Event triggered when the <see cref="Position"/> of the <see cref="ITransform"/> changes.
|
|
|
|
/// </summary>
|
2024-11-23 23:14:44 +03:00
|
|
|
event OnPositionChangedEventHandler? OnPositionChanged;
|
2024-02-01 12:14:53 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Event triggered when the <see cref="Scale"/> of the <see cref="ITransform"/> changes.
|
|
|
|
/// </summary>
|
2024-11-23 23:14:44 +03:00
|
|
|
event OnScaleChangedEventHandler? OnScaleChanged;
|
2024-02-01 12:14:53 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Event triggered when the <see cref="Rotation"/> of the <see cref="ITransform"/> changes.
|
|
|
|
/// </summary>
|
2024-11-23 23:14:44 +03:00
|
|
|
event OnRotationChangedEventHandler? OnRotationChanged;
|
2023-11-23 22:07:49 +03:00
|
|
|
|
2024-02-01 12:14:53 +03:00
|
|
|
/// <summary>
|
2024-02-06 12:34:18 +03:00
|
|
|
/// Event triggered when the <see cref="Parent"/> of the <see cref="ITransform"/> changes. The second parameter is the old <see cref="ITransform"/>.
|
|
|
|
/// </summary>
|
2024-11-23 23:14:44 +03:00
|
|
|
event OnParentChangedEventHandler? OnParentChanged;
|
2024-02-06 12:34:18 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Event triggered when a new <see cref="ITransform"/> is added to the <see cref="Children"/>.
|
|
|
|
/// </summary>
|
2024-11-23 23:14:44 +03:00
|
|
|
event OnChildrenAddedEventHandler? OnChildrenAdded;
|
2024-02-06 12:34:18 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Event triggered when an <see cref="ITransform"/> is removed from the <see cref="Children"/>.
|
|
|
|
/// </summary>
|
2024-11-23 23:14:44 +03:00
|
|
|
event OnChildrenRemovedEventHandler? OnChildrenRemoved;
|
2024-02-06 12:34:18 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The world position of the <see cref="ITransform"/> in 2D space.
|
2024-02-01 12:14:53 +03:00
|
|
|
/// </summary>
|
2024-01-22 22:45:40 +03:00
|
|
|
Vector2D Position { get; set; }
|
2024-02-01 12:14:53 +03:00
|
|
|
|
|
|
|
/// <summary>
|
2024-02-06 12:34:18 +03:00
|
|
|
/// The world scale of the <see cref="ITransform"/>.
|
2024-02-01 12:14:53 +03:00
|
|
|
/// </summary>
|
2024-01-22 22:45:40 +03:00
|
|
|
Vector2D Scale { get; set; }
|
2023-11-23 22:07:49 +03:00
|
|
|
|
2024-02-01 12:14:53 +03:00
|
|
|
/// <summary>
|
2024-02-06 12:34:18 +03:00
|
|
|
/// The world rotation of the <see cref="ITransform"/> in degrees.
|
2024-02-01 12:14:53 +03:00
|
|
|
/// </summary>
|
2023-11-23 22:07:49 +03:00
|
|
|
float Rotation { get; set; }
|
2024-02-06 12:34:18 +03:00
|
|
|
|
|
|
|
/// <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; }
|
|
|
|
|
2024-02-06 12:58:17 +03:00
|
|
|
/// <summary>
|
|
|
|
/// Sets the parent <see cref="ITransform"/> of this <see cref="ITransform"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="transform">The parent <see cref="ITransform"/> to set.</param>
|
2024-02-06 12:34:18 +03:00
|
|
|
void SetParent(ITransform? transform);
|
2024-02-06 12:58:17 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Adds a child <see cref="ITransform"/> to this <see cref="ITransform"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="transform">The child <see cref="ITransform"/> to add.</param>
|
2024-02-06 12:34:18 +03:00
|
|
|
void AddChild(ITransform transform);
|
2024-02-06 12:58:17 +03:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Removes a child <see cref="ITransform"/> from this <see cref="ITransform"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="transform">The child <see cref="ITransform"/> to remove.</param>
|
2024-02-06 12:34:18 +03:00
|
|
|
void RemoveChild(ITransform transform);
|
2024-07-15 01:13:39 +03:00
|
|
|
|
2024-11-23 23:14:44 +03:00
|
|
|
delegate void OnPositionChangedEventHandler(ITransform sender);
|
|
|
|
delegate void OnScaleChangedEventHandler(ITransform sender);
|
|
|
|
delegate void OnRotationChangedEventHandler(ITransform sender);
|
|
|
|
delegate void OnParentChangedEventHandler(ITransform sender, ITransform? previousParent, ITransform? newParent);
|
|
|
|
delegate void OnChildrenAddedEventHandler(ITransform sender, ITransform childrenAdded);
|
|
|
|
delegate void OnChildrenRemovedEventHandler(ITransform sender, ITransform childrenRemoved);
|
2023-11-23 22:07:49 +03:00
|
|
|
}
|