Lots more work on implementing battling

This commit is contained in:
2024-08-10 09:44:46 +02:00
parent 554e1cf2cd
commit a049dda240
29 changed files with 1226 additions and 48 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.ScriptHandling;
@@ -29,7 +30,7 @@ public class ScriptContainer : IEnumerable<ScriptContainer>
/// <summary>
/// The script in this container.
/// </summary>
public Script? Script { get; set; } = null;
public Script? Script { get; private set; }
/// <inheritdoc />
public IEnumerator<ScriptContainer> GetEnumerator()
@@ -42,4 +43,27 @@ public class ScriptContainer : IEnumerable<ScriptContainer>
{
return GetEnumerator();
}
public void Set(Script script)
{
if (Script is not null)
{
Script.OnRemove();
Script.MarkForDeletion();
}
Script = script;
}
/// <summary>
/// Removes the script from this container.
/// </summary>
public void Clear()
{
if (Script is not null)
{
Script.OnRemove();
Script.MarkForDeletion();
}
Script = null;
}
}