Begin work on outlining dynamic side
This commit is contained in:
52
PkmnLib.Dynamic/ScriptHandling/ScriptSource.cs
Normal file
52
PkmnLib.Dynamic/ScriptHandling/ScriptSource.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
public interface IScriptSource
|
||||
{
|
||||
ScriptIterator GetScripts();
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
int ScriptCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// This should add all scripts belonging to this source to the scripts Vec, disregarding its
|
||||
/// potential parents.
|
||||
/// </summary>
|
||||
/// <param name="scripts"></param>
|
||||
void GetOwnScripts(List<IEnumerable<ScriptContainer>> scripts);
|
||||
|
||||
/// <summary>
|
||||
/// This should add all scripts that are relevant to the source the the scripts Vec, including
|
||||
/// everything that belongs to its parents.
|
||||
/// </summary>
|
||||
/// <param name="scripts"></param>
|
||||
void CollectScripts(List<IEnumerable<ScriptContainer>> scripts);
|
||||
}
|
||||
|
||||
public abstract class ScriptSource : IScriptSource
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ScriptIterator GetScripts()
|
||||
{
|
||||
if (_scripts == null)
|
||||
{
|
||||
_scripts = new List<IEnumerable<ScriptContainer>>(ScriptCount);
|
||||
CollectScripts(_scripts);
|
||||
}
|
||||
return new ScriptIterator(_scripts);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract int ScriptCount { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void GetOwnScripts(List<IEnumerable<ScriptContainer>> scripts);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void CollectScripts(List<IEnumerable<ScriptContainer>> scripts);
|
||||
|
||||
/// <inheritdoc />
|
||||
private List<IEnumerable<ScriptContainer>>? _scripts;
|
||||
}
|
||||
Reference in New Issue
Block a user