Path-of-Terraria / PathOfTerraria

GNU General Public License v3.0
1 stars 3 forks source link

feature: npc components #317

Closed shnakamura closed 3 months ago

shnakamura commented 3 months ago

### Link Issues Resolves:

Description of Work

Introduces NPC components - that are not limited to NPCs only - which help reduce the repetition of code by providing reusable behavior and data applications through an EC (Entity-Component) pattern. Components are global types that can be disabled/enabled on an entity, only applying behavior while it's enabled.

Sample:

NPC.TryEnableComponent<NPCDeathEffects>(
    c =>
    {
        c.AddGore($"{Name}_0", 1);
        c.AddGore($"{Name}_1", 2);
        c.AddGore($"{Name}_2", 2);

        c.AddDust(DustID.Blood, 20);
    }
);

Comments

This system is very flexible and easy to expand, soon we may be able to use it more frequently.

shnakamura commented 3 months ago

There's some irrelevant code cleanups on the blame, I just did them on the go