// An interface to represent a pre-configured action performed asynchronously // on a block. Implements a Run() method that executes the action and provides an // Enumerator to monitor when the action is complete. using System.Collections.Generic; namespace IngameScript { partial class Program { public abstract class BlockAction { public bool Running { get; private set; } = false; public IEnumerator Run() { if (Running) yield break; Running = true; IEnumerator childRun = onRun(); while (childRun.MoveNext()) yield return true; Running = false; } protected abstract IEnumerator onRun(); } } }