using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Torch.API.Managers;
using Torch.API.Session;
using VRage.Game.ModAPI;
using Version = SemanticVersioning.Version;
namespace Torch.API
{
///
/// API for Torch functions shared between client and server.
///
public interface ITorchBase
{
///
/// Gets the currently running session instance, or null if none exists.
///
ITorchSession CurrentSession { get; }
///
/// Configuration for the current instance.
///
ITorchConfig Config { get; }
///
[Obsolete]
IPluginManager Plugins { get; }
///
IDependencyManager Managers { get; }
[Obsolete("Prefer using Managers.GetManager for global managers")]
T GetManager() where T : class, IManager;
[Obsolete("Prefer using Managers.AddManager for global managers")]
bool AddManager(T manager) where T : class, IManager;
///
/// The binary version of the current instance.
///
Version TorchVersion { get; }
///
/// Path of the dedicated instance folder.
///
string InstancePath { get; }
///
/// Name of the dedicated instance.
///
string InstanceName { get; }
///
/// Invoke an action on the game thread.
///
void Invoke(Action action, [CallerMemberName] string caller = "");
///
/// Invoke an action on the game thread and block until it has completed.
///
/// Action to execute
/// Caller of the invoke function
/// Timeout before is thrown, or -1 to never timeout
/// If the action times out
void InvokeBlocking(Action action, int timeoutMs = -1, [CallerMemberName] string caller = "");
///
/// Invoke an action on the game thread asynchronously.
///
Task InvokeAsync(Action action, [CallerMemberName] string caller = "");
///
/// Invoke a function on the game thread asynchronously.
///
Task InvokeAsync(Func func, [CallerMemberName] string caller = "");
///
/// Signals the torch instance to start, then blocks until it's started.
///
void Start();
///
/// Signals the torch instance to stop, then blocks until it's stopped.
///
void Stop();
///
/// Restart the Torch instance, blocking until the restart has been performed.
///
void Restart(bool save = true);
///
/// Initializes a save of the game.
///
/// timeout before the save is treated as failed, or -1 for no timeout
/// Only start saving if we aren't already saving
/// Future result of the save, or null if one is in progress and in exclusive mode
Task Save(int timeoutMs = -1, bool exclusive = false);
///
/// Initialize the Torch instance. Before this is invalid.
///
void Init();
///
/// Disposes the Torch instance. After this is invalid.
///
void Destroy();
///
/// The current state of the game this instance of torch is controlling.
///
TorchGameState GameState { get; }
///
/// Event raised when changes.
///
event TorchGameStateChangedDel GameStateChanged;
}
///
/// API for the Torch server.
///
public interface ITorchServer : ITorchBase
{
///
/// The current
///
ServerState State { get; }
///
/// Raised when the server's Init() method has completed.
///
event Action Initialized;
TimeSpan ElapsedPlayTime { get; set; }
}
///
/// API for the Torch client.
///
public interface ITorchClient : ITorchBase
{
}
}