Scripting an effect resolver with visual effects

I’m trying to figure out if I can program generic effect resolvers for my game. What I mean with that is that my effects exist out of two parts. A visual part and a data part. The visual part is for example a cannon ball leaving an origin and hitting a target. The data part being the target hp lowering by x amount. I had the following in mind but I’m not sure if this will be able to render my visual part since it’s outside of any update() method. Could you tell me if I’m on the right track ?

I have following classes now

  • an enum giving the effect a name
  • an abstract class giving an interface to an effect resolver
  • two implementations of that abstract class
  • a factory to instantiate an effect resolver
public enum CastEffectEnum {
     NONE, NORMAL_DAMAGE, RANDOM_DAMAGE
}
public abstract class CastEffectResolver {

    public void ResolveCastEffect(Ship origin, Ship target)
    {
        ResolveVisualEffect(origin, target);
        ResolveDataEffect(origin, target);
    }

    internal abstract void ResolveDataEffect(Ship origin, Ship target);
    internal abstract void ResolveVisualEffect(Ship origin, Ship target);
}
public class NormalDamageCastEffect : CastEffectResolver
{
    internal override void ResolveDataEffect(Ship origin, Ship target)
    {
        throw new NotImplementedException();
    }

    internal override void ResolveVisualEffect(Ship origin, Ship target)
    {
        throw new NotImplementedException();
    }
}
public class CastEffectFactory {

    public CastEffectResolver GetCastEffectResolver(CastEffectEnum castEffect)
    {
        switch(castEffect)
        {
            case CastEffectEnum.NORMAL_DAMAGE: return new NormalDamageCastEffect();
            case CastEffectEnum.RANDOM_DAMAGE: return new RandomDamageCastEffect();
            default: throw new System.Exception("No casteffect found for [" + castEffect + "]");
        }       
    }
}

before I spend to much time in the rabbit hole I would love a second opinion if this is a good way to go and how I would deal showing effects without using an update() method. I read about coroutines so I’m looking in that direction. Seems the rest of a scene runs on a single thread ? I’m still new to unity being a java developer this is a new world for me I’m still learning to navigate through.

Thanks in advance

Well I went ahead and made one implementation that works on the data side

public class NormalDamageCastEffect : CastEffectResolver
{
    internal override void ResolveDataEffect(Ship origin, Ship target)
    {
        target.health += -20;
    }

    internal override void ResolveVisualEffect(Ship origin, Ship target)
    {
    }
}

I think I’m going to forgo spawning physical objects to show a canon being shot and try doing it with particle effects. I had the loose thought on extending the CastEffectResolver from the MonoBehaviorclass. However I haven’t tried it yet and I don’t think it’s possible since MonoBehavior isn’t abstract at all. Maybe I should forgo the abstract idea and is that more something for java programming and not for Unity C#. I don’t know yet so I hope if there is still someone here that can tell me if my idea will get me stomped in the end or I can carry through