Weapon enchantments - designing the code architecture?

I’ve been thinking for a couple of days now about how to implement weapon enchantments through Unity.

For example:

  1. Iron Sword (10 damage on hit, 1 attack per second)
  2. Swift Iron Sword (10 damage on hit, 2 attacks per second)
  3. Iron Sword of Fire (20 damage on hit, 1 attacks per second, target burns for 5 seconds)
  4. Swift Iron Sword of Fire (20 damage on hit, 2 attacks per second, target burns for 5 seconds)

I would like to be able to achieve this without having a unique prefab for every single possible combination, primarily as doing so is both time consuming and could eat up a lot of space.

The way I would do this in a “regular” Object Oriented architecture would be decorators.
(Read: The way I WOULD do it, not the way I HAVE done it, this could still be entirely wrong!)
ie,
Weapon sword = new SwiftEnchant( new FireEnchant( new IronMaterial( new Sword() ) ) );

However, I can’t see how a decorator model could exist within the component based architecture of Unity.

Can anyone help me out by pointing me in the right direction here? It would be much appreciated.

The way I would do this, is to have a base item (in this case Iron Sword) that has variables inside for the different possible enhancements.

For a simple setup, you could have booleans for each of the types to set if the weapon has it, and a companion variable to set how much it affects the weapon. Like a bool ‘hasSpeedEnhance’ and a float saying how much faster (or slower for penalties) it swings.

You could also use class inheritance and interfaces to allow for more flexibility, where the base weapon doesn’t need a variable for each type. On attack it could call a method in the derived class that gives it a chance to modify the stats of that attack.

You can define yourself some enhancement class that holds the information (attacks per sec/ dmg multiplier/etc.) and then put all modifiers on a weapon in a list.
Using Linq or just iterating you can then easily get the total effect of all enhancements on a weapon.