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

58 lines
2.3 KiB
C#
Raw Normal View History

2024-01-30 12:08:21 +03:00
using System;
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-02-01 12:14:53 +03:00
/// <summary>
/// Event triggered when a <see cref="IGameObject"/> is registered to the <see cref="IGameManager"/>.
/// </summary>
2024-01-30 18:52:31 +03:00
Action<IGameManager, IGameObject>? OnGameObjectRegistered { get; set; }
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>
Action<IGameManager, IGameObject>? OnGameObjectUnRegistered { get; set; }
2024-01-30 12:08:21 +03:00
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; }
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();
}