Roots

Roots

24M Downloads

Implement `is` function and store modifiers per-cast.

noobanidus opened this issue ยท 0 comments

commented

The concept here is to do the following:

  1. Before the actual cast function is called, call instead a different function which stores the modifiers in the tempModifiers field of the SpellBase instance.
  2. That function then calls the default function that we usually use.
  3. Within the context of this function (whether it is the single cast or it is the continuous cast), the modifiers should always be available as tempModifiers.
  4. This means that instead of passing the modifiers as a parameter to the cast function (which can indeed still be done), and using the has function for has(MODIFIER, modifiers), it's possible to instead do is(MODIFIER) or has(MODIFIER).
  5. Things that would improve this would be, per-spell, renaming the modifiers to be roughly closer to what they actual do. i.e., has(FIRE).
  6. Obviously, the is function can and should throw an exception if tempModifiers aren't available. As the EntitySpellModifiable relies on the instance's has function, it would make sense for has(IModifier) to be a shortcut for has(modifier, this.tempModifiers) and handle null functionality in that function.