Initial work on scripts
This commit is contained in:
@@ -1,6 +1,36 @@
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
public abstract class Script
|
||||
{
|
||||
|
||||
private bool _markedForDeletion;
|
||||
private int _suppressCount;
|
||||
|
||||
public abstract string Name { get; }
|
||||
public bool MarkForDeletion() => _markedForDeletion = true;
|
||||
public bool IsMarkedForDeletion() => _markedForDeletion;
|
||||
public int SuppressCount() => _suppressCount;
|
||||
public bool IsSuppressed() => _suppressCount > 0;
|
||||
public void Suppress() => _suppressCount++;
|
||||
public void Unsuppress() => _suppressCount--;
|
||||
|
||||
public virtual void Stack()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnRemove()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnInitialize(IDynamicLibrary library, IReadOnlyDictionary<StringKey, object> parameters)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ChangeStabModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber,
|
||||
ref float modifier)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
@@ -6,7 +7,14 @@ public class ScriptContainer : IEnumerable<ScriptContainer>
|
||||
{
|
||||
private Script? _script = null;
|
||||
|
||||
[MemberNotNullWhen(false, nameof(ScriptHandling.Script))]
|
||||
public bool IsEmpty => _script is null;
|
||||
|
||||
public Script? Script
|
||||
{
|
||||
get => _script;
|
||||
set => _script = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerator<ScriptContainer> GetEnumerator()
|
||||
|
||||
16
PkmnLib.Dynamic/ScriptHandling/ScriptExecution.cs
Normal file
16
PkmnLib.Dynamic/ScriptHandling/ScriptExecution.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
public static class ScriptExecution
|
||||
{
|
||||
public static void RunScriptHook(this IScriptSource source, Action<Script> hook)
|
||||
{
|
||||
var iterator = source.GetScripts();
|
||||
foreach (var container in iterator)
|
||||
{
|
||||
if (container.IsEmpty)
|
||||
continue;
|
||||
var script = container.Script;
|
||||
hook(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user