using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// Base class all logic blocks are derived from
///
[System.Serializable]
public abstract class LogicBlock : ScriptableObject
{
#region Inspector Fields
[SerializeField]
[Header("Base Settings")]
[Tooltip("Wait until this block is resolved before moving to next")]
public bool WaitUntilFinished = false;
[SerializeField]
[Tooltip("Amount of times to run this Block before moving to next")]
protected int RepeatAmount = 1;
#endregion Inspector Fields
#region private variables
///
/// Amount of times this block has run
///
protected int RepeatCount = 0;
#endregion private variables
#region Class Functions
///
/// Runs the block
///
/// Player which will be affected by the block
/// returns true if block is finished
public virtual bool Run(Character player)
{
RepeatCount++;
BlockLogic(player);
return isFinished();
}
///
/// Returns the amount of space this logic block takes up
///
/// Int which controlls how much space this takes up
public virtual int Size()
{
return 1;
}
///
/// Where derived callses should implement the logic for their classes
///
/// Player which will be affected by the block
/// returns true if block is finished
protected abstract void BlockLogic(Character player);
///
/// Resets the block to be ready to used again
///
public virtual void Reset()
{
RepeatCount = 0;
}
///
/// False if this block needs to be run again
///
/// bool false if block needs to be run again
public virtual bool isFinished()
{
return (RepeatCount == RepeatAmount);
}
#endregion Class Functions
}