Some initial work on prescient AI, AI runner, and some random fixes
All checks were successful
Build / Build (push) Successful in 1m3s

This commit is contained in:
2025-07-05 17:48:51 +02:00
parent 7b25161a8d
commit d57076374f
9 changed files with 174 additions and 21 deletions

View File

@@ -155,7 +155,8 @@ public static class ScriptExecution
Action<TScriptHook> hook)
{
List<ScriptCategory>? suppressedCategories = null;
foreach (var container in source.SelectMany(x => x))
var iterator = new ScriptIterator(source);
foreach (var container in iterator)
{
if (container.IsEmpty)
continue;
@@ -163,7 +164,7 @@ public static class ScriptExecution
if (script is IScriptOnBeforeAnyHookInvoked onBeforeAnyHookInvoked)
onBeforeAnyHookInvoked.OnBeforeAnyHookInvoked(ref suppressedCategories);
}
foreach (var container in source.SelectMany(x => x))
foreach (var container in iterator)
{
if (container.IsEmpty)
continue;

View File

@@ -10,7 +10,7 @@ namespace PkmnLib.Dynamic.ScriptHandling;
/// We can add, remove, and clear scripts from the set.
/// This is generally used for volatile scripts.
/// </summary>
public interface IScriptSet : IEnumerable<ScriptContainer>
public interface IScriptSet : IEnumerable<ScriptContainer>, IDeepCloneable
{
/// <summary>
/// Adds a script to the set. If the script with that name already exists in this set, this
@@ -97,15 +97,7 @@ public class ScriptSet : IScriptSet
}
/// <inheritdoc />
public IEnumerator<ScriptContainer> GetEnumerator()
{
var currentIndex = 0;
while (currentIndex < _scripts.Count)
{
yield return _scripts[currentIndex];
currentIndex++;
}
}
public IEnumerator<ScriptContainer> GetEnumerator() => _scripts.GetEnumerator();
/// <inheritdoc />
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();