using System;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.IoC.Exceptions;
namespace Robust.Shared.GameObjects
{
///
/// Like SS13's master controller. It controls instances.
/// These instances have set of rules for which components they can run over.
///
///
/// The management of these amounts to a couple of things:
///
/// -
/// Periodically ticking them through .
///
///
/// Periodically ticks instances.
///
///
public interface IEntitySystemManager
{
bool MetricsEnabled { get; set; }
///
/// A new entity system has been loaded into the manager.
///
event EventHandler SystemLoaded;
///
/// An existing entity system has been unloaded from the manager.
///
event EventHandler SystemUnloaded;
///
/// Get an entity system of the specified type.
///
/// The type of entity system to find.
/// The instance matching the specified type.
T GetEntitySystem() where T : IEntitySystem;
///
/// Get an entity system of the specified type, or null if it is not registered.
///
/// The type of entity system to find.
/// The instance matching the specified type, or null.
T? GetEntitySystemOrNull() where T : IEntitySystem;
///
/// Resolves an entity system.
///
/// Thrown if the provided type is not registered.
///
/// Thrown if the resolved type hasn't been created yet
/// because the dependency collection object graph still needs to be constructed for it.
///
void Resolve([NotNull] ref T? instance)
where T : IEntitySystem;
///
///
/// Resolve two entity systems.
///
void Resolve([NotNull] ref T1? instance1, [NotNull] ref T2? instance2)
where T1 : IEntitySystem
where T2 : IEntitySystem;
///
///
/// Resolve three entity systems.
///
void Resolve([NotNull] ref T1? instance1, [NotNull] ref T2? instance2, [NotNull] ref T3? instance3)
where T1 : IEntitySystem
where T2 : IEntitySystem
where T3 : IEntitySystem;
///
///
/// Resolve four entity systems.
///
void Resolve([NotNull] ref T1? instance1, [NotNull] ref T2? instance2, [NotNull] ref T3? instance3, [NotNull] ref T4? instance4)
where T1 : IEntitySystem
where T2 : IEntitySystem
where T3 : IEntitySystem
where T4 : IEntitySystem;
///
/// Tries to get an entity system of the specified type.
///
/// Type of entity system to find.
/// instance matching the specified type (if exists).
/// If an instance of the specified entity system type exists.
bool TryGetEntitySystem([NotNullWhen(true)] out T? entitySystem) where T : IEntitySystem;
///
/// Initialize, discover systems and initialize them through .
///
/// Whether we should automatically find systems or have they been supplied already.
///
void Initialize(bool discover = true);
///
/// Clean up, shut down all systems through and remove them.
///
///
void Shutdown();
void Clear();
///
/// Update all systems.
///
/// Time since the last frame was rendered.
///
/// Only run systems with set true.
///
///
void TickUpdate(float frameTime, bool noPredictions);
void FrameUpdate(float frameTime);
///
/// Adds an extra entity system type that otherwise would not be loaded automatically, useful for testing.
///
/// The type of the entity system to load.
///
/// Thrown if the manager has been initialized already.
///
void LoadExtraSystemType() where T : IEntitySystem, new();
object GetEntitySystem(Type sysType);
}
}