namespace PkmnLib.Dynamic.ScriptHandling;
public interface IScriptSource
{
ScriptIterator GetScripts();
///
/// The number of scripts that are expected to be relevant for this source. This generally is
/// The number of its own scripts + the number of scripts for any parents.
///
int ScriptCount { get; }
///
/// This should add all scripts belonging to this source to the scripts Vec, disregarding its
/// potential parents.
///
///
void GetOwnScripts(List> scripts);
///
/// This should add all scripts that are relevant to the source the the scripts Vec, including
/// everything that belongs to its parents.
///
///
void CollectScripts(List> scripts);
}
public abstract class ScriptSource : IScriptSource
{
///
public ScriptIterator GetScripts()
{
if (_scripts == null)
{
_scripts = new List>(ScriptCount);
CollectScripts(_scripts);
}
return new ScriptIterator(_scripts);
}
///
public abstract int ScriptCount { get; }
///
public abstract void GetOwnScripts(List> scripts);
///
public abstract void CollectScripts(List> scripts);
///
private List>? _scripts;
}