I was wondering if anyone would mind explaining a little about how a composition based spell system should work.
I've been working on this for a few days now, I think I understand the composite pattern enough for what I want to do as my entity's follow the same pattern. (Everything has a single purpose)
But I am really having trouble connecting everything together.
For example my
Entity has a
Entity Caster Component and
Entity SpellList Component and I believe following a pattern like this the
Entity Caster Component shoudn't need to know anything about the spell other than it's just been asked to cast the one given, correct?
Which leads me to the problem of actually casting the spell as each spell is currently an empty object with 4 SpellComponents on it one of each type (
SpellModifier) which all extend from
SpellComp so I should in theory be able to treat them all the same.
But in practice I can't as targeting, modifier and effect mostly only need to run once where as locomotion needs to be called every frame.
I haven't figured out how to still call one inherited base method but have 1 component fire a coroutine and the others work as normal while still treating them the same.
Currently when I "cast" a spell I spawn an empty gameobject with the comps and enable the first component which does it's job and fires an event to start the next component until the last.
EffectComp (VFX) >
ModifierComp (Heal/Hurt etc)
which has the obvious effect of leaving a empty object in my scene that responds to target input even after the spell is over.
I feel like at some point I've started mixing two separate systems together and made an unholy mess I no longer understand.
Every other part of the project has gone and is going fine but just thinking about taking another look at the spell system makes me lose a few brain cells.
I linked an empty project I created purely for testing this with my "oh god its so awful but it sort of works" implementation attempt.
I would add the code for each file but there is over 10 and most of them are just extending from a base abstract class so I can treat them the same and this post is already very long.
Any help appreciated, thanks!
Note: Also I use "Entity" as a base class for anything that moves and would have health, I am not trying to implement ECS, I think.. it was just the easiest way to categorize it in my head.