Added first script, bugfixes
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
[MeansImplicitUse]
|
||||
public class ScriptAttribute : Attribute
|
||||
{
|
||||
public ScriptCategory Category { get; }
|
||||
public string Name { get; }
|
||||
public StringKey Name { get; }
|
||||
|
||||
public ScriptAttribute(ScriptCategory category, string name)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
public class ScriptRegistry
|
||||
{
|
||||
private Dictionary<(ScriptCategory category, string name), Func<Script>> _scriptTypes = new();
|
||||
private Dictionary<(ScriptCategory category, StringKey name), Func<Script>> _scriptTypes = new();
|
||||
private IBattleStatCalculator? _battleStatCalculator;
|
||||
private IDamageCalculator? _damageCalculator;
|
||||
private IMiscLibrary? _miscLibrary;
|
||||
@@ -24,10 +25,8 @@ public class ScriptRegistry
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterScriptType(ScriptCategory category, string name, Type type)
|
||||
public void RegisterScriptType(ScriptCategory category, StringKey name, Type type)
|
||||
{
|
||||
if (name == null)
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
if (type == null)
|
||||
throw new ArgumentNullException(nameof(type));
|
||||
|
||||
@@ -49,7 +48,7 @@ public class ScriptRegistry
|
||||
public void RegisterMiscLibrary<T>(T miscLibrary) where T : IMiscLibrary
|
||||
=> _miscLibrary = miscLibrary;
|
||||
|
||||
internal Dictionary<(ScriptCategory category, string name), Func<Script>> ScriptTypes => _scriptTypes;
|
||||
internal Dictionary<(ScriptCategory category, StringKey name), Func<Script>> ScriptTypes => _scriptTypes;
|
||||
internal IBattleStatCalculator? BattleStatCalculator => _battleStatCalculator;
|
||||
internal IDamageCalculator? DamageCalculator => _damageCalculator;
|
||||
internal IMiscLibrary? MiscLibrary => _miscLibrary;
|
||||
|
||||
Reference in New Issue
Block a user