Ability System - Pyrohax/Simpleton GitHub Wiki

Introduction

The ability system works using tags to identify if an ability is supposed to be called on something or not. If the affect tags match the tags on the entity, the effect (currently a void(void) function) is called.

Example

It's still quite small, but it works according to the following example:

// Creating an entity, adding a tag to it, and creating an ability effect function to be called on the effect.
UniqueID entity = AddEntity();
myAbilitySystem.AddTag(AbilityTag::Player, entity);
auto testLambda = []() { Log::Print("Test function ran, ability system works.");	};

// Creating some abilities with different targeting configurations: 
// The affect-tags, the ignore-tags, the action, and if the "affect" should override the ignore (default false).
Ability testAbility1(std::vector<AbilityTag>{AbilityTag::Player}, std::vector<AbilityTag>{}, testLambda, false);
Ability testAbility2(std::vector<AbilityTag>{AbilityTag::Player}, std::vector<AbilityTag>{AbilityTag::Player}, testLambda, false);
Ability testAbility3(std::vector<AbilityTag>{AbilityTag::Any}, std::vector<AbilityTag>{AbilityTag::Player}, testLambda, true);
Ability testAbility4(std::vector<AbilityTag>{AbilityTag::Any}, std::vector<AbilityTag>{AbilityTag::Player}, testLambda, false);

// Starting the abilities with a target.
myAbilitySystem.StartAbilityOnEntity(testAbility1, entity);
myAbilitySystem.StartAbilityOnEntity(testAbility2, entity);
myAbilitySystem.StartAbilityOnEntity(testAbility3, entity);
myAbilitySystem.StartAbilityOnEntity(testAbility4, entity);

// This will output:
( ) Test function ran, ability system works.
( ) Test function ran, ability system works.

Plans

I'm imagining the abilities being created in a AbilityDefinitions function, which loads the configurations from a file exported by a simple tool. First, we'll need to make input systems and other supporting logic.

⚠️ **GitHub.com Fallback** ⚠️