using System;
using GameLauncher.Engines.Common;
using GameLauncher.Models;
namespace GameLauncher.Engines.Evb
{
///
/// Engine module for Enigma Virtual Box (EVB) packed applications.
///
/// EVB is a generic packer: it can wrap a game built on any engine (RGSS, NW.js,
/// Wolf, Unity, ...). This module therefore acts as a *pre-stage* — it detects an
/// EVB-packed executable, unpacks it via the bundled evbunpack tool, and then lets
/// the caller re-detect the underlying engine from the unpacked content.
///
/// Per-game hacks never live here; they belong under
/// `Engines/Evb/Games/<GameName>/` and must not affect other games.
///
public sealed class EvbEngineModule : IEngineModule
{
///
public string EngineName => EngineDetectionHelper.EngineEvb;
///
public bool Detect(string gameDirectory) => EvbDetector.IsEvbGame(gameDirectory);
///
/// EVB is a packaging layer, not a game engine, so it has no script mod of its own.
/// Mods are applied by the underlying engine after unpacking.
///
public bool ApplyMod(string gameDirectory, ModPluginDefinition plugin) => false;
/// EVB has no standalone mod state; nothing is ever "applied".
public bool IsModApplied(string gameDirectory) => false;
///
public string ResolveToolPath(string toolFileName)
=> AppPathHelperBridge.Resolve(this.EngineName, toolFileName);
}
///
/// Thin indirection so that can resolve engine tools
/// without taking a hard dependency on the concrete helper type in this file.
///
internal static class AppPathHelperBridge
{
public static string Resolve(string engineName, string toolFileName)
=> Helpers.AppPathHelper.ResolveEngineTool(engineName, toolFileName)
?? throw new InvalidOperationException(
$"External tool '{toolFileName}' for engine '{engineName}' was not found.");
}
}