Adds several new scripts

This commit is contained in:
2024-12-22 11:24:01 +01:00
parent 44cd2ee03e
commit 45439a20a4
5 changed files with 81 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.ScriptHandling;
@@ -26,7 +27,12 @@ public interface IScriptSet : IEnumerable<ScriptContainer>
/// Gets a script from the set using its unique name.
/// </summary>
ScriptContainer? Get(StringKey scriptKey);
/// <summary>
/// Gets a script from the set using its type.
/// </summary>
T? Get<T>() where T : Script;
/// <summary>
/// Removes a script from the set using its unique name.
/// </summary>
@@ -107,6 +113,9 @@ public class ScriptSet : IScriptSet
/// <inheritdoc />
public ScriptContainer? Get(StringKey scriptKey) => _scripts.FirstOrDefault(s => s.Script?.Name == scriptKey);
/// <inheritdoc />
public T? Get<T>() where T : Script => Get(ScriptUtils.ResolveName<T>())?.Script as T;
/// <inheritdoc />
public void Remove(StringKey scriptKey)
{