refactor!: IGameObject removed
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IGameObject"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableGameObject : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IGameObject"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
event OnGameObjectAssignedEventHandler? OnGameObjectAssigned;
|
||||
|
||||
/// <inheritdoc cref="IGameObject" />
|
||||
IGameObject GameObject { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="IGameObject"/> field of this object.
|
||||
/// </summary>
|
||||
/// <param name="gameObject">New <see cref="IGameObject"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(IGameObject gameObject);
|
||||
|
||||
delegate void OnGameObjectAssignedEventHandler(IAssignableGameObject sender);
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="ITransform"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableTransform : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="ITransform"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
event OnTransformAssignedEventHandler? OnTransformAssigned;
|
||||
|
||||
/// <inheritdoc cref="ITransform" />
|
||||
ITransform Transform { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="ITransform"/> field of this object.
|
||||
/// </summary>
|
||||
/// <param name="transform">New <see cref="ITransform"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(ITransform transform);
|
||||
|
||||
delegate void OnTransformAssignedEventHandler(IAssignableTransform sender);
|
||||
}
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IBehaviourController"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableBehaviourController : IAssignable
|
||||
public interface IHasBehaviourController : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IBehaviourController"/> value has has been assigned a new value.
|
||||
@@ -22,5 +22,5 @@ public interface IAssignableBehaviourController : IAssignable
|
||||
/// </returns>
|
||||
bool Assign(IBehaviourController behaviourController);
|
||||
|
||||
delegate void OnBehaviourControllerAssignedEventHandler(IAssignableBehaviourController sender);
|
||||
delegate void OnBehaviourControllerAssignedEventHandler(IHasBehaviourController sender);
|
||||
}
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IEntity"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableEntity : IAssignable
|
||||
public interface IHasEntity : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IEntity"/> value has has been assigned a new value.
|
||||
@@ -22,5 +22,5 @@ public interface IAssignableEntity : IAssignable
|
||||
/// </returns>
|
||||
bool Assign(IEntity entity);
|
||||
|
||||
delegate void OnEntityAssignedEventHandler(IAssignableEntity sender);
|
||||
delegate void OnEntityAssignedEventHandler(IHasEntity sender);
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="ITransform"/> field.
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="ITransform2D"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableGameManager : IAssignable
|
||||
public interface IHasGameManager : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IGameManager"/> value has has been assigned a new value.
|
||||
@@ -22,5 +22,5 @@ public interface IAssignableGameManager : IAssignable
|
||||
/// </returns>
|
||||
bool Assign(IGameManager gameManager);
|
||||
|
||||
delegate void OnGameManagerAssignedEventHandler(IAssignableGameManager sender);
|
||||
delegate void OnGameManagerAssignedEventHandler(IHasGameManager sender);
|
||||
}
|
26
Engine.Core/Abstract/Assignable/IHasHierarchyObject.cs
Normal file
26
Engine.Core/Abstract/Assignable/IHasHierarchyObject.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IHierarchyObject"/> field.
|
||||
/// </summary>
|
||||
public interface IHasHierarchyObject : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IHierarchyObject"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
event OnHierarchyObjectAssignedEventHandler? OnHierarchyObjectAssigned;
|
||||
|
||||
/// <inheritdoc cref="IHierarchyObject" />
|
||||
IHierarchyObject HierarchyObject { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="IHierarchyObject"/> field of this object.
|
||||
/// </summary>
|
||||
/// <param name="hierarchyObject">New <see cref="IHierarchyObject"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(IHierarchyObject hierarchyObject);
|
||||
|
||||
delegate void OnHierarchyObjectAssignedEventHandler(IHasHierarchyObject sender);
|
||||
}
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IStateEnable"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableStateEnable : IAssignable
|
||||
public interface IHasStateEnable : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IStateEnable"/> value has has been assigned a new value.
|
||||
@@ -22,5 +22,5 @@ public interface IAssignableStateEnable : IAssignable
|
||||
/// </returns>
|
||||
bool Assign(IStateEnable stateEnable);
|
||||
|
||||
delegate void OnStateEnableAssignedEventHandler(IAssignableStateEnable sender);
|
||||
delegate void OnStateEnableAssignedEventHandler(IHasStateEnable sender);
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an <see cref="IEntity"/> that can enter and exit a hierarchy within the <see cref="IGameManager"/> system.
|
||||
/// This interface allows for tracking the object's presence in the hierarchy and provides events
|
||||
/// for notifying when the see enters or exits the hierarchy.
|
||||
/// </summary>
|
||||
public interface IHierarchyObject : IEntity, INameable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IEntity"/> enters the hierarchy.
|
||||
/// </summary>
|
||||
event OnEnteredHierarchyEventHandler? OnEnteredHierarchy;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IEntity"/> exits the hierarchy.
|
||||
/// </summary>
|
||||
event OnExitedHierarchyEventHandler? OnExitedHierarchy;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IGameManager"/> associated with this <see cref="IEntity"/> , if any.
|
||||
/// </summary>
|
||||
IGameManager GameManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the <see cref="IEntity"/> is currently in the hierarchy.
|
||||
/// </summary>
|
||||
bool IsInHierarchy { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to handle entering the hierarchy.
|
||||
/// This should be called by the system to properly manage hierarchy states.
|
||||
/// </summary>
|
||||
/// <param name="gameManager">The game manager that is managing this hierarchy.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/> if the <see cref="IEntity"/> successfully entered the hierarchy;
|
||||
/// <see cref="false"/> if it failed to do so.
|
||||
/// </returns>
|
||||
internal bool EnterHierarchy(IGameManager gameManager);
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to handle exiting the hierarchy.
|
||||
/// This should be called by the system to properly manage hierarchy states.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <see cref="true"/> if the <see cref="IEntity"/> successfully exited the hierarchy;
|
||||
/// <see cref="false"/> if it failed to do so.
|
||||
/// </returns>
|
||||
internal bool ExitHierarchy();
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler delegate for the event triggered when the <see cref="IEntity"/> enters the hierarchy of a <see cref="IGameManager">.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="IEntity"/> that entered the hierarchy.</param>
|
||||
/// <param name="gameManager">The <see cref="IGameManager"/> that the <see cref="IEntity"/> has entered it's hierarchy.</param>
|
||||
delegate void OnEnteredHierarchyEventHandler(IHierarchyObject sender, IGameManager gameManager);
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler delegate for the event triggered when the <see cref="IEntity"/> exits the hierarchy of a <see cref="IGameManager">.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="IEntity"/> that exited the hierarchy.</param>
|
||||
/// <param name="gameManager">The <see cref="IGameManager"/> that the <see cref="IEntity"/> has exited it's hierarchy.</param>
|
||||
delegate void OnExitedHierarchyEventHandler(IHierarchyObject sender, IGameManager gameManager);
|
||||
}
|
@@ -1,17 +1,15 @@
|
||||
using System;
|
||||
|
||||
using Syntriax.Engine.Core.Exceptions;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public abstract class BaseEntity : IEntity
|
||||
{
|
||||
public event IEntity.OnIdChangedEventHandler? OnIdChanged = null;
|
||||
|
||||
public event IInitialize.OnInitializedEventHandler? OnInitialized = null;
|
||||
public event IInitialize.OnFinalizedEventHandler? OnFinalized = null;
|
||||
public event IInitializable.OnInitializedEventHandler? OnInitialized = null;
|
||||
public event IInitializable.OnFinalizedEventHandler? OnFinalized = null;
|
||||
|
||||
public event IAssignableStateEnable.OnStateEnableAssignedEventHandler? OnStateEnableAssigned = null;
|
||||
public event IHasStateEnable.OnStateEnableAssignedEventHandler? OnStateEnableAssigned = null;
|
||||
public event IAssignable.OnUnassignedEventHandler? OnUnassigned = null;
|
||||
|
||||
private IStateEnable _stateEnable = null!;
|
||||
@@ -28,6 +26,9 @@ public abstract class BaseEntity : IEntity
|
||||
get => _id;
|
||||
set
|
||||
{
|
||||
if (IsInitialized)
|
||||
throw new($"Can't change {nameof(Id)} of {_id} because it's initialized");
|
||||
|
||||
if (value == _id)
|
||||
return;
|
||||
|
||||
@@ -85,7 +86,7 @@ public abstract class BaseEntity : IEntity
|
||||
if (IsInitialized)
|
||||
return false;
|
||||
|
||||
NotAssignedException.Check(this, _stateEnable);
|
||||
_stateEnable ??= new Factory.StateEnableFactory().Instantiate(this);
|
||||
|
||||
InitializeInternal();
|
||||
|
||||
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Represents a behaviour that any object in the game might use to interact with itself or other objects.
|
||||
/// </summary>
|
||||
public interface IBehaviour : IEntity, IAssignableBehaviourController, IAssignableStateEnable
|
||||
public interface IBehaviour : IEntity, IHasBehaviourController, IHasStateEnable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the priority of the <see cref="IBehaviour"/> changes.
|
||||
|
6
Engine.Core/Abstract/IBehaviour2D.cs
Normal file
6
Engine.Core/Abstract/IBehaviour2D.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public interface IBehaviour2D : IBehaviour
|
||||
{
|
||||
ITransform2D Transform { get; }
|
||||
}
|
@@ -7,7 +7,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// Provides mechanisms for tracking additions and removals, and notifies subscribers when such events occur on the assigned <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of objects tracked by the collector.</typeparam>
|
||||
public interface IBehaviourCollector<T> : IAssignableGameManager, IEnumerable<T> where T : class
|
||||
public interface IBehaviourCollector<T> : IHasGameManager, IEnumerable<T> where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when an object of type <typeparamref name="T"/> is added to the collector.
|
||||
|
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a controller for managing <see cref="IBehaviour"/>s and notify them accordingly about the engine's updates. Connected to an <see cref="IGameObject"/>.
|
||||
/// Represents a controller for managing <see cref="IBehaviour"/>s and notify them accordingly about the engine's updates. Connected to an <see cref="IHierarchyObject"/>.
|
||||
/// </summary>
|
||||
public interface IBehaviourController : IInitialize, IAssignableGameObject, IEnumerable<IBehaviour>
|
||||
public interface IBehaviourController : IInitializable, IHasHierarchyObject, IEnumerable<IBehaviour>
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered before the update of <see cref="IBehaviour"/>s.
|
||||
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Represents a 2D camera in the engine.
|
||||
/// </summary>
|
||||
public interface ICamera2D : IBehaviour, IAssignableTransform
|
||||
public interface ICamera2D : IBehaviour2D
|
||||
{
|
||||
/// <summary>
|
||||
/// The zoom level of the camera.
|
||||
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Represents a basic entity in the engine.
|
||||
/// </summary>
|
||||
public interface IEntity : IInitialize, IAssignableStateEnable
|
||||
public interface IEntity : IInitializable, IHasStateEnable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Id"/> of the <see cref="IEntity"/> changes.
|
||||
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a game world responsible for managing <see cref="IGameObject"/>s.
|
||||
/// Represents a game world responsible for managing <see cref="IHierarchyObject"/>s.
|
||||
/// </summary>
|
||||
public interface IGameManager : IEntity
|
||||
{
|
||||
@@ -17,16 +17,6 @@ public interface IGameManager : IEntity
|
||||
/// </summary>
|
||||
event OnPreDawEventHandler? OnPreDraw;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when a <see cref="IGameObject"/> is registered to the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
event OnGameObjectRegisteredEventHandler? OnGameObjectRegistered;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when a <see cref="IGameObject"/> is unregistered from the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
event OnGameObjectUnRegisteredEventHandler? OnGameObjectUnRegistered;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when a <see cref="IHierarchyObject"/> is registered to the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
@@ -37,11 +27,6 @@ public interface IGameManager : IEntity
|
||||
/// </summary>
|
||||
event OnHierarchyObjectUnRegisteredEventHandler? OnHierarchyObjectUnRegistered;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read-only list of <see cref="IGameObject"/>s managed by the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
IReadOnlyList<IGameObject> GameObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read-only list of <see cref="IHierarchyObject"/>s managed by the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
@@ -54,12 +39,12 @@ public interface IGameManager : IEntity
|
||||
void Register(IHierarchyObject hierarchyObject);
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a <see cref="IGameObject"/> of type T with the given arguments and registers it to the <see cref="IGameManager"/>.
|
||||
/// Instantiates a <see cref="IHierarchyObject"/> of type T with the given arguments and registers it to the <see cref="IGameManager"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of <see cref="IGameObject"/> to instantiate.</typeparam>
|
||||
/// <param name="args">Constructor parameters for the given type of <see cref="IGameObject"/>.</param>
|
||||
/// <returns>The instantiated <see cref="IGameObject"/>.</returns>
|
||||
T InstantiateGameObject<T>(params object?[]? args) where T : class, IGameObject;
|
||||
/// <typeparam name="T">The type of <see cref="IHierarchyObject"/> to instantiate.</typeparam>
|
||||
/// <param name="args">Constructor parameters for the given type of <see cref="IHierarchyObject"/>.</param>
|
||||
/// <returns>The instantiated <see cref="IHierarchyObject"/>.</returns>
|
||||
T InstantiateHierarchyObject<T>(params object?[]? args) where T : class, IHierarchyObject;
|
||||
|
||||
/// <summary>
|
||||
/// Removes an <see cref="IHierarchyObject"/> from the <see cref="IGameManager"/>.
|
||||
@@ -81,8 +66,6 @@ public interface IGameManager : IEntity
|
||||
delegate void OnUpdateEventHandler(IGameManager sender, EngineTime time);
|
||||
delegate void OnPreDawEventHandler(IGameManager sender);
|
||||
|
||||
delegate void OnGameObjectRegisteredEventHandler(IGameManager sender, IGameObject gameObjectRegistered);
|
||||
delegate void OnGameObjectUnRegisteredEventHandler(IGameManager sender, IGameObject gameObjectUnregistered);
|
||||
delegate void OnHierarchyObjectRegisteredEventHandler(IGameManager sender, IHierarchyObject hierarchyObjectRegistered);
|
||||
delegate void OnHierarchyObjectUnRegisteredEventHandler(IGameManager sender, IHierarchyObject hierarchyObjectUnregistered);
|
||||
}
|
||||
|
@@ -1,19 +0,0 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a game object with various properties and functionalities.
|
||||
/// </summary>
|
||||
public interface IGameObject : IEntity, IHierarchyObject, IAssignableTransform, IAssignableBehaviourController, INameable, IInitialize
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Update"/> method is called.
|
||||
/// </summary>
|
||||
event OnUpdatedEventHandler? OnUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Updates the game object.
|
||||
/// </summary>
|
||||
void Update();
|
||||
|
||||
delegate void OnUpdatedEventHandler(IGameObject sender);
|
||||
}
|
131
Engine.Core/Abstract/IHierarchyObject.cs
Normal file
131
Engine.Core/Abstract/IHierarchyObject.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an <see cref="IEntity"/> that can enter and exit a hierarchy within the <see cref="IGameManager"/> system.
|
||||
/// This interface allows for tracking the object's presence in the hierarchy and provides events
|
||||
/// for notifying when the see enters or exits the hierarchy.
|
||||
/// </summary>
|
||||
public interface IHierarchyObject : IEntity, INameable, IHasBehaviourController, IEnumerable<IHierarchyObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IHierarchyObject"/> enters the hierarchy.
|
||||
/// </summary>
|
||||
event OnEnteredHierarchyEventHandler? OnEnteredHierarchy;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="IHierarchyObject"/> exits the hierarchy.
|
||||
/// </summary>
|
||||
event OnExitedHierarchyEventHandler? OnExitedHierarchy;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Parent"/> of the <see cref="IHierarchyObject"/> changes. The second parameter is the old <see cref="IHierarchyObject"/>.
|
||||
/// </summary>
|
||||
event OnParentChangedEventHandler? OnParentChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when a new <see cref="IHierarchyObject"/> is added to the <see cref="Children"/>.
|
||||
/// </summary>
|
||||
event OnChildrenAddedEventHandler? OnChildrenAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when an <see cref="IHierarchyObject"/> is removed from the <see cref="Children"/>.
|
||||
/// </summary>
|
||||
event OnChildrenRemovedEventHandler? OnChildrenRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IGameManager"/> this <see cref="IHierarchyObject"/> is connected to, if any.
|
||||
/// </summary>
|
||||
IGameManager GameManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the <see cref="IHierarchyObject"/> is currently in the hierarchy.
|
||||
/// </summary>
|
||||
bool IsInHierarchy { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The parent <see cref="IHierarchyObject"/> of the <see cref="IHierarchyObject"/>.
|
||||
/// </summary>
|
||||
IHierarchyObject? Parent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IHierarchyObject"/>s that have this <see cref="IHierarchyObject"/> as their <see cref="Parent"/>.
|
||||
/// </summary>
|
||||
IReadOnlyList<IHierarchyObject> Children { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to handle entering the hierarchy.
|
||||
/// This should be called by the system to properly manage hierarchy states.
|
||||
/// </summary>
|
||||
/// <param name="gameManager">The <see cref="IGameManager"/> that is managing this hierarchy.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/> if the <see cref="IHierarchyObject"/> successfully entered the hierarchy;
|
||||
/// <see cref="false"/> if it failed to do so.
|
||||
/// </returns>
|
||||
internal bool EnterHierarchy(IGameManager gameManager);
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to handle exiting the hierarchy.
|
||||
/// This should be called by the system to properly manage hierarchy states.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <see cref="true"/> if the <see cref="IHierarchyObject"/> successfully exited the hierarchy;
|
||||
/// <see cref="false"/> if it failed to do so.
|
||||
/// </returns>
|
||||
internal bool ExitHierarchy();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the parent <see cref="IHierarchyObject"/> of this <see cref="IHierarchyObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hierarchyObject">The parent <see cref="IHierarchyObject"/> to set.</param>
|
||||
void SetParent(IHierarchyObject? hierarchyObject);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a child <see cref="IHierarchyObject"/> to this <see cref="IHierarchyObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hierarchyObject">The child <see cref="IHierarchyObject"/> to add.</param>
|
||||
void AddChild(IHierarchyObject hierarchyObject);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a child <see cref="IHierarchyObject"/> from this <see cref="IHierarchyObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hierarchyObject">The child <see cref="IHierarchyObject"/> to remove.</param>
|
||||
void RemoveChild(IHierarchyObject hierarchyObject);
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler delegate for the event triggered when the <see cref="IHierarchyObject"/> enters the hierarchy of a <see cref="IGameManager">.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="IHierarchyObject"/> that entered the hierarchy.</param>
|
||||
/// <param name="gameManager">The <see cref="IGameManager"/> that the <see cref="IHierarchyObject"/> has entered it's hierarchy.</param>
|
||||
delegate void OnEnteredHierarchyEventHandler(IHierarchyObject sender, IGameManager gameManager);
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler delegate for the event triggered when the <see cref="IHierarchyObject"/> exits the hierarchy of a <see cref="IGameManager">.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="IHierarchyObject"/> that exited the hierarchy.</param>
|
||||
/// <param name="gameManager">The <see cref="IGameManager"/> that the <see cref="IHierarchyObject"/> has exited it's hierarchy.</param>
|
||||
delegate void OnExitedHierarchyEventHandler(IHierarchyObject sender, IGameManager gameManager);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the event triggered when the <see cref="IHierarchyObject"/>'s parent changes.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="IHierarchyObject"/> that the parent has changed.</param>
|
||||
/// <param name="previousParent">The previous <see cref="IHierarchyObject"/> the sender was a child of.</param>
|
||||
/// <param name="newParent">The new and current <see cref="IHierarchyObject"/> the sender is a child of.</param>
|
||||
delegate void OnParentChangedEventHandler(IHierarchyObject sender, IHierarchyObject? previousParent, IHierarchyObject? newParent);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the event triggered when a new <see cref="IHierarchyObject"/> added as a child.
|
||||
/// </summary>
|
||||
/// <param name="sender">The parent <see cref="IHierarchyObject"/> this event is being called from.</param>
|
||||
/// <param name="childrenAdded">The <see cref="IHierarchyObject"/> that got removed as a children of the sender <see cref="IHierarchyObject"/>.</param>
|
||||
delegate void OnChildrenAddedEventHandler(IHierarchyObject sender, IHierarchyObject childrenAdded);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the event triggered when a new <see cref="IHierarchyObject"/> removed from being a child.
|
||||
/// </summary>
|
||||
/// <param name="sender">The parent <see cref="IHierarchyObject"/> this event is being called from.</param>
|
||||
/// <param name="childrenAdded">The <see cref="IHierarchyObject"/> that got removed as a children of the sender <see cref="IHierarchyObject"/>.</param>
|
||||
delegate void OnChildrenRemovedEventHandler(IHierarchyObject sender, IHierarchyObject childrenRemoved);
|
||||
}
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Represents an entity that can be initialized and finalized. This information is useful for objects we know that are not in use and can be either recycled or dropped for garbage collection.
|
||||
/// </summary>
|
||||
public interface IInitialize
|
||||
public interface IInitializable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Initialize"/> method is called successfully.
|
||||
@@ -11,7 +11,7 @@ public interface IInitialize
|
||||
event OnInitializedEventHandler? OnInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Finalize"/> method is called successfully.
|
||||
/// Event triggered when the <see cref="IInitializable"/> method is called successfully.
|
||||
/// </summary>
|
||||
event OnFinalizedEventHandler? OnFinalized;
|
||||
|
||||
@@ -32,6 +32,6 @@ public interface IInitialize
|
||||
/// <returns><see cref="true"/> if finalization is successful, otherwise <see cref="false"/>.</returns>
|
||||
bool Finalize();
|
||||
|
||||
delegate void OnInitializedEventHandler(IInitialize sender);
|
||||
delegate void OnFinalizedEventHandler(IInitialize sender);
|
||||
delegate void OnInitializedEventHandler(IInitializable sender);
|
||||
delegate void OnFinalizedEventHandler(IInitializable sender);
|
||||
}
|
@@ -3,7 +3,7 @@ namespace Syntriax.Engine.Core.Abstract;
|
||||
/// <summary>
|
||||
/// Represents an entity with an enable state that can be toggled.
|
||||
/// </summary>
|
||||
public interface IStateEnable : IAssignableEntity
|
||||
public interface IStateEnable : IHasEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Enabled"/> state of the <see cref="IStateEnable"/> changes.
|
||||
|
@@ -1,140 +0,0 @@
|
||||
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);
|
||||
}
|
73
Engine.Core/Abstract/ITransform2D.cs
Normal file
73
Engine.Core/Abstract/ITransform2D.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the transformation properties of an object such as position, scale, and rotation in 2D space.
|
||||
/// </summary>
|
||||
public interface ITransform2D : IBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Position"/> of the <see cref="ITransform2D"/> changes.
|
||||
/// </summary>
|
||||
event OnPositionChangedEventHandler? OnPositionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Scale"/> of the <see cref="ITransform2D"/> changes.
|
||||
/// </summary>
|
||||
event OnScaleChangedEventHandler? OnScaleChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when the <see cref="Rotation"/> of the <see cref="ITransform"/> changes.
|
||||
/// </summary>
|
||||
event OnRotationChangedEventHandler? OnRotationChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The world position of the <see cref="ITransform2D"/> in 2D space.
|
||||
/// </summary>
|
||||
Vector2D Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The world scale of the <see cref="ITransform2D"/>.
|
||||
/// </summary>
|
||||
Vector2D Scale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The world rotation of the <see cref="ITransform2D"/> in degrees.
|
||||
/// </summary>
|
||||
float Rotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The local position of the <see cref="ITransform2D"/> in 2D space.
|
||||
/// </summary>
|
||||
Vector2D LocalPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The local scale of the <see cref="ITransform2D"/>.
|
||||
/// </summary>
|
||||
Vector2D LocalScale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The local rotation of the <see cref="ITransform2D"/> in degrees.
|
||||
/// </summary>
|
||||
float LocalRotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the event triggered when the <see cref="ITransform2D"/>'s rotation changes.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="ITransform2D"/> that the parent has changed.</param>
|
||||
/// <param name="previousPosition">The previous <see cref="Position"/> of the <see cref="ITransform2D"/>.</param>
|
||||
delegate void OnPositionChangedEventHandler(ITransform2D sender, Vector2D previousPosition);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the event triggered when the <see cref="ITransform2D"/>'s rotation changes.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="ITransform2D"/> that the parent has changed.</param>
|
||||
/// <param name="previousScale">The previous <see cref="Scale"/> of the <see cref="ITransform2D"/>.</param>
|
||||
delegate void OnScaleChangedEventHandler(ITransform2D sender, Vector2D previousScale);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for the event triggered when the <see cref="ITransform2D"/>'s rotation changes.
|
||||
/// </summary>
|
||||
/// <param name="sender">The <see cref="ITransform2D"/> that the parent has changed.</param>
|
||||
/// <param name="previousRotation">The previous <see cref="Rotation"/> of the <see cref="ITransform2D"/>.</param>
|
||||
delegate void OnRotationChangedEventHandler(ITransform2D sender, float previousRotation);
|
||||
}
|
Reference in New Issue
Block a user