Item Affix System in Unity C# with the Decorator Pattern

Ever wanted to do:

var awesomeNewHat = new OfProgramming( new Sagacious( new WizardHat() ) );

Well, I used to, that’s why I implemented an affix system with the decorator pattern. Code available here –

> Puts on Sagacious Wizard Hat of Programming

An affix system is the sort of thing every loot based RPG needs to have satisfying item names and effects.

Here, have some hats:Unity WebGL Player | item-affix-decorators

The decorators are the affixes, an item is a component, and the Wizard Hat in this case is a concrete item.

The decorator pattern can model a lot of fun stuff in games.
Making a skill system should be fun too, where the decorating order factors into what effects you get.

Leave a Reply

Your email address will not be published. Required fields are marked *