A big part of our unit and item identity will be defined by their abilities. Most importantly in the current design our “Specialist” units will each have three. To address the need of a large amount of abilities I have tried to implement them in a flexible and expandable way.
I based my approach on a design pattern where a subclass implements most of its behavior with functionality provided by the base class. This pattern is called subclass sandbox. In our case the base class provides several functions to apply stat-altering effects to units in different ways (target unit, target area, units in an area,… ). The effects provide the unit with the correct information on how to alter its stats and what particle effects to spawn, each unit handles its own effects.
The base class has an Activate() method, the subclass overrides this one to implement its behavior with base class operations. More specific functionality needs to be coded inside the subclass. Because we’re using Unreal Engine, the Activate() is an event to be used in subclass blueprint. The base class also has Select() and Deselect() functions to be called by the player to toggle the correct ability casting feedback such as a cursor change or decal to indicate the affected area.