Syntriax.Engine/Engine.Core/Abstract/IGameManager.cs

90 lines
3.8 KiB
C#
Raw Normal View History

2024-01-30 12:08:21 +03:00
using System.Collections.Generic;
namespace Syntriax.Engine.Core.Abstract;
2024-02-01 12:14:53 +03:00
/// <summary>
/// Represents a game world responsible for managing <see cref="IGameObject"/>s.
/// </summary>
2024-01-30 12:08:21 +03:00
public interface IGameManager : IEntity, IEnumerable<IGameObject>
{
2024-10-25 23:10:20 +03:00
/// <summary>
/// Event triggered when <see cref="Update(EngineTime)"/> is called on the <see cref="IGameManager"/>.
/// </summary>
event OnUpdateDelegate? OnUpdate;
/// <summary>
/// Event triggered when <see cref="PreDraw"/> is called on the <see cref="IGameManager"/>.
/// </summary>
event OnPreDawDelegate? OnPreDraw;
2024-02-01 12:14:53 +03:00
/// <summary>
/// Event triggered when a <see cref="IGameObject"/> is registered to the <see cref="IGameManager"/>.
/// </summary>
2024-07-15 01:13:39 +03:00
event OnGameObjectRegisteredDelegate? OnGameObjectRegistered;
2024-01-30 12:08:21 +03:00
2024-02-01 12:14:53 +03:00
/// <summary>
/// Event triggered when a <see cref="IGameObject"/> is unregistered from the <see cref="IGameManager"/>.
/// </summary>
2024-07-15 01:13:39 +03:00
event OnGameObjectUnRegisteredDelegate? OnGameObjectUnRegistered;
2024-01-30 12:08:21 +03:00
/// <summary>
/// Event triggered when a <see cref="IHierarchyObject"/> is registered to the <see cref="IGameManager"/>.
/// </summary>
event OnHierarchyObjectRegisteredDelegate? OnHierarchyObjectRegistered;
/// <summary>
/// Event triggered when a <see cref="IHierarchyObject"/> is unregistered from the <see cref="IGameManager"/>.
/// </summary>
event OnHierarchyObjectUnRegisteredDelegate? OnHierarchyObjectUnRegistered;
2024-02-01 12:14:53 +03:00
/// <summary>
/// Gets a read-only list of <see cref="IGameObject"/>s managed by the <see cref="IGameManager"/>.
/// </summary>
2024-01-30 12:08:21 +03:00
IReadOnlyList<IGameObject> GameObjects { get; }
/// <summary>
/// Gets a read-only list of <see cref="IHierarchyObject"/>s managed by the <see cref="IGameManager"/>.
/// </summary>
IReadOnlyList<IHierarchyObject> HierarchyObjects { get; }
2024-02-01 12:14:53 +03:00
/// <summary>
/// Registers a <see cref="IGameObject"/> to the <see cref="IGameManager"/>.
/// </summary>
/// <param name="gameObject">The <see cref="IGameObject"/> to register.</param>
2024-01-30 12:08:21 +03:00
void RegisterGameObject(IGameObject gameObject);
2024-02-01 12:14:53 +03:00
/// <summary>
/// Instantiates a <see cref="IGameObject"/> 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>
2024-01-30 12:08:21 +03:00
T InstantiateGameObject<T>(params object?[]? args) where T : class, IGameObject;
2024-02-01 12:14:53 +03:00
/// <summary>
/// Removes a <see cref="IGameObject"/> from the <see cref="IGameManager"/>.
/// </summary>
/// <param name="gameObject">The <see cref="IGameObject"/> to remove.</param>
/// <returns>The removed <see cref="IGameObject"/>.</returns>
2024-01-30 12:08:21 +03:00
IGameObject RemoveGameObject(IGameObject gameObject);
2024-02-01 12:14:53 +03:00
/// <summary>
/// Updates the <see cref="IGameManager"/> with the given engine time data.
/// </summary>
/// <param name="time">The engine time.</param>
2024-01-30 12:08:21 +03:00
void Update(EngineTime time);
2024-02-01 12:14:53 +03:00
/// <summary>
/// Performs operations that should be done before the draw calls.
/// </summary>
2024-01-30 12:08:21 +03:00
void PreDraw();
2024-07-15 01:13:39 +03:00
2024-10-25 23:10:20 +03:00
delegate void OnUpdateDelegate(IGameManager sender, EngineTime time);
delegate void OnPreDawDelegate(IGameManager sender);
2024-07-15 01:13:39 +03:00
delegate void OnGameObjectRegisteredDelegate(IGameManager sender, IGameObject gameObjectRegistered);
delegate void OnGameObjectUnRegisteredDelegate(IGameManager sender, IGameObject gameObjectUnregistered);
delegate void OnHierarchyObjectRegisteredDelegate(IGameManager sender, IHierarchyObject hierarchyObjectRegistered);
delegate void OnHierarchyObjectUnRegisteredDelegate(IGameManager sender, IHierarchyObject hierarchyObjectUnregistered);
2024-01-30 12:08:21 +03:00
}