Style cleanup
This commit is contained in:
@@ -3,8 +3,7 @@ using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
[MeansImplicitUse]
|
||||
[AttributeUsage(AttributeTargets.Class), MeansImplicitUse]
|
||||
public class ItemScriptAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -11,11 +11,11 @@ public abstract class Plugin
|
||||
protected Plugin()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected Plugin(PluginConfiguration configuration)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The name of the plugin. Mostly used for debugging purposes.
|
||||
/// </summary>
|
||||
|
||||
@@ -6,8 +6,7 @@ namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
/// <summary>
|
||||
/// Helper attribute to register scripts through reflection.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
[MeansImplicitUse]
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false), MeansImplicitUse]
|
||||
public class ScriptAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ScriptRegistry
|
||||
// This is more performant than using Activator.CreateInstance.
|
||||
_scriptTypes[(category, name)] = Expression.Lambda<Func<Script>>(Expression.New(constructor)).Compile();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Register an item script type with the given name.
|
||||
/// </summary>
|
||||
@@ -83,32 +83,32 @@ public class ScriptRegistry
|
||||
// This is more performant than using Activator.CreateInstance.
|
||||
var parameterExpression = Expression.Parameter(typeof(IItem), "item");
|
||||
var newExpression = Expression.New(constructor, parameterExpression);
|
||||
_itemScriptTypes[name] = Expression.Lambda<Func<IItem, ItemScript>>(newExpression, parameterExpression).Compile();
|
||||
_itemScriptTypes[name] =
|
||||
Expression.Lambda<Func<IItem, ItemScript>>(newExpression, parameterExpression).Compile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a battle stat calculator.
|
||||
/// </summary>
|
||||
public void RegisterBattleStatCalculator<T>(T battleStatCalculator)
|
||||
where T : IBattleStatCalculator => _battleStatCalculator = battleStatCalculator;
|
||||
public void RegisterBattleStatCalculator<T>(T battleStatCalculator) where T : IBattleStatCalculator =>
|
||||
_battleStatCalculator = battleStatCalculator;
|
||||
|
||||
/// <summary>
|
||||
/// Register a damage calculator.
|
||||
/// </summary>
|
||||
public void RegisterDamageCalculator<T>(T damageCalculator)
|
||||
where T : IDamageCalculator => _damageCalculator = damageCalculator;
|
||||
public void RegisterDamageCalculator<T>(T damageCalculator) where T : IDamageCalculator =>
|
||||
_damageCalculator = damageCalculator;
|
||||
|
||||
/// <summary>
|
||||
/// Register a misc library.
|
||||
/// </summary>
|
||||
public void RegisterMiscLibrary<T>(T miscLibrary) where T : IMiscLibrary
|
||||
=> _miscLibrary = miscLibrary;
|
||||
|
||||
public void RegisterMiscLibrary<T>(T miscLibrary) where T : IMiscLibrary => _miscLibrary = miscLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Register a capture library.
|
||||
/// </summary>
|
||||
public void RegisterCaptureLibrary<T>(T captureLibrary) where T : ICaptureLibrary
|
||||
=> _captureLibrary = captureLibrary;
|
||||
public void RegisterCaptureLibrary<T>(T captureLibrary) where T : ICaptureLibrary =>
|
||||
_captureLibrary = captureLibrary;
|
||||
|
||||
internal IReadOnlyDictionary<(ScriptCategory category, StringKey name), Func<Script>> ScriptTypes => _scriptTypes;
|
||||
internal IReadOnlyDictionary<StringKey, Func<IItem, ItemScript>> ItemScriptTypes => _itemScriptTypes;
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
public static class ScriptUtils
|
||||
{
|
||||
private static readonly Dictionary<Type, StringKey> NameCache = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolve name from the <see cref="ScriptAttribute"/> of the given script.
|
||||
/// </summary>
|
||||
public static StringKey ResolveName(this Script script) => ResolveName(script.GetType());
|
||||
|
||||
|
||||
public static StringKey ResolveName<T>() where T : Script => ResolveName(typeof(T));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolve name from the <see cref="ScriptAttribute"/> of the given type.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user