Implements critical capture, tweaks for integration tests.
All checks were successful
Build / Build (push) Successful in 48s
All checks were successful
Build / Build (push) Successful in 48s
This commit is contained in:
@@ -50,7 +50,7 @@ public class DynamicLibraryImpl : IDynamicLibrary
|
||||
/// Initializes a new instance of the <see cref="DynamicLibraryImpl"/> class, with the given
|
||||
/// plugins and static library.
|
||||
/// </summary>
|
||||
public static IDynamicLibrary Create(IEnumerable<Plugin> plugins)
|
||||
public static IDynamicLibrary Create(IEnumerable<IPlugin> plugins)
|
||||
{
|
||||
var load = LibraryLoader.LoadPlugins(plugins);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public static class LibraryLoader
|
||||
/// <summary>
|
||||
/// Loads plugins and creates a static library from them.
|
||||
/// </summary>
|
||||
public static LoadResult LoadPlugins(IEnumerable<Plugin> plugins)
|
||||
public static LoadResult LoadPlugins(IEnumerable<IPlugin> plugins)
|
||||
{
|
||||
var registry = new ScriptRegistry();
|
||||
var orderedPlugins = plugins.OrderBy(x => x.LoadOrder).ToList();
|
||||
@@ -39,7 +39,7 @@ public static class LibraryLoader
|
||||
return new LoadResult(registry, scriptResolver, staticLibrary);
|
||||
}
|
||||
|
||||
private static StaticLibraryImpl CreateStaticLibrary(IReadOnlyList<Plugin> plugins)
|
||||
private static StaticLibraryImpl CreateStaticLibrary(IReadOnlyList<IPlugin> plugins)
|
||||
{
|
||||
var resourceProviders = plugins.OfType<IResourceProvider>().ToList();
|
||||
var settings = resourceProviders.Select(x => x.Settings).LastOrDefault(x => x != null);
|
||||
|
||||
@@ -173,4 +173,7 @@ public class LearnedMoveImpl : ILearnedMove
|
||||
{
|
||||
CurrentPp = Math.Min(uses, MaxPp);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() => MoveData.Name;
|
||||
}
|
||||
@@ -1261,6 +1261,14 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
side.CollectScripts(scripts);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Nickname))
|
||||
return $"{Nickname} ({Species.Name})";
|
||||
return Species.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -2,20 +2,37 @@ using JetBrains.Annotations;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
public interface IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the plugin. Mostly used for debugging purposes.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// When the plugin should be loaded. Lower values are loaded first.
|
||||
/// 0 should be reserved for the core battle scripts.
|
||||
/// </summary>
|
||||
uint LoadOrder { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Run the registration of the plugin when we're building the library.
|
||||
/// </summary>
|
||||
void Register(ScriptRegistry registry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A plugin is a way to register scripts and other dynamic components to the script registry.
|
||||
/// </summary>
|
||||
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
||||
public abstract class Plugin
|
||||
public abstract class Plugin<TConfiguration> : IPlugin where TConfiguration : IPluginConfiguration
|
||||
{
|
||||
/// <inheritdoc cref="Plugin"/>
|
||||
protected Plugin()
|
||||
{
|
||||
}
|
||||
public TConfiguration Configuration { get; }
|
||||
|
||||
/// <inheritdoc cref="Plugin"/>
|
||||
protected Plugin(PluginConfiguration configuration)
|
||||
/// <inheritdoc cref="Plugin{TConfiguration}"/>
|
||||
protected Plugin(TConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,4 +55,4 @@ public abstract class Plugin
|
||||
/// <summary>
|
||||
/// Base class for plugin configuration.
|
||||
/// </summary>
|
||||
public abstract class PluginConfiguration;
|
||||
public interface IPluginConfiguration;
|
||||
Reference in New Issue
Block a user