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

89 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>
public interface IGameManager : IEntity
2024-01-30 12:08:21 +03:00
{
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 OnUpdateEventHandler? OnUpdate;
2024-10-25 23:10:20 +03:00
/// <summary>
/// Event triggered when <see cref="PreDraw"/> is called on the <see cref="IGameManager"/>.
/// </summary>
event OnPreDawEventHandler? OnPreDraw;
2024-10-25 23:10:20 +03:00
2024-02-01 12:14:53 +03:00
/// <summary>
/// Event triggered when a <see cref="IGameObject"/> is registered to the <see cref="IGameManager"/>.
/// </summary>
event OnGameObjectRegisteredEventHandler? 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>
event OnGameObjectUnRegisteredEventHandler? 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 OnHierarchyObjectRegisteredEventHandler? OnHierarchyObjectRegistered;
/// <summary>
/// Event triggered when a <see cref="IHierarchyObject"/> is unregistered from the <see cref="IGameManager"/>.
/// </summary>
event OnHierarchyObjectUnRegisteredEventHandler? 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 an <see cref="IHierarchyObject"/> to the <see cref="IGameManager"/>.
2024-02-01 12:14:53 +03:00
/// </summary>
/// <param name="hierarchyObject">The <see cref="IHierarchyObject"/> to register.</param>
void Register(IHierarchyObject hierarchyObject);
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 an <see cref="IHierarchyObject"/> from the <see cref="IGameManager"/>.
2024-02-01 12:14:53 +03:00
/// </summary>
/// <param name="hierarchyObject">The <see cref="IHierarchyObject"/> to remove.</param>
void Remove(IHierarchyObject hierarchyObject);
2024-01-30 12:08:21 +03:00
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
delegate void OnUpdateEventHandler(IGameManager sender, EngineTime time);
delegate void OnPreDawEventHandler(IGameManager sender);
2024-10-25 23:10:20 +03:00
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);
2024-01-30 12:08:21 +03:00
}