2024-07-27 14:26:45 +00:00
|
|
|
using System.Collections;
|
2024-07-27 14:53:06 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2024-07-27 14:26:45 +00:00
|
|
|
|
|
|
|
namespace PkmnLib.Dynamic.ScriptHandling;
|
|
|
|
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A holder class for a script. This is used so we can cache a list of these, and iterate over them, even when
|
|
|
|
/// the underlying script changes.
|
|
|
|
/// </summary>
|
2024-07-27 14:26:45 +00:00
|
|
|
public class ScriptContainer : IEnumerable<ScriptContainer>
|
|
|
|
{
|
2024-07-28 10:52:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this container is empty.
|
|
|
|
/// </summary>
|
2024-07-27 14:53:06 +00:00
|
|
|
[MemberNotNullWhen(false, nameof(ScriptHandling.Script))]
|
2024-07-28 10:52:17 +00:00
|
|
|
public bool IsEmpty => Script is null;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The script in this container.
|
|
|
|
/// </summary>
|
|
|
|
public Script? Script { get; set; } = null;
|
2024-07-27 14:26:45 +00:00
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public IEnumerator<ScriptContainer> GetEnumerator()
|
|
|
|
{
|
|
|
|
yield return this;
|
|
|
|
}
|
2024-07-28 10:52:17 +00:00
|
|
|
|
2024-07-27 14:26:45 +00:00
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
|
|
{
|
|
|
|
return GetEnumerator();
|
|
|
|
}
|
|
|
|
}
|