Question by
gabgab06 · Jul 12, 2021 at 01:30 AM ·
c#methodpolymorphism
Make a virtual method englobing a child override function
Hello!
I'm wondering how do I put the child method between some code of a parent method. Something like that :
public abstract class SpellSO : ScriptableObject
{
public virtual IEnumerator CastSpellCoroutine(Actor caster, Cell centerCell)
{
caster.IsCasting = true;
// Child method in between
yield return null;
caster.IsCasting = false;
}
}
public class DamagingSpellSO : SpellSO
{
public override IEnumerator CastSpellCoroutine(Actor caster, Cell centerCell)
{
centerCell.ActorOnTop.Hurt(_damage);
}
}
So when I call the DamagingSpellSO CastSpellCoroutine, it take the parent code and put it in between of my function, is this possible?
Thanks for the help!
Comment