Original Post
Hey all, I'm working out a component based entity system for the Flash engine that I constantly rework after every successful project to address the shortfalls that came up during development. In the interests of re-usability I plan to make the switch. However, I'm wondering just how re-usable / interconnected components can / should be? It seems like in theory I should be able to take any component from any project, add it to a new project and it should "just work". I must be missing something though. Example: HealthComponent seems like something that would easily be re-usable. It has two properties, MaxHealth and CurrentHealth. It exposes a TakeDamage() method to modify those properties. Now I have a Fireball entity and when it hits something, it checks to see if that Entity has a HealthComponent to deal damage to. If it doesn't, it doesn't deal damage. Seems very straight forward. The problem is... Who is responsible for modifying that damage if need be? Say characters have a Fire Resistance attribute. A Fireball's damage should scale depending on that attribute. The Fireball could do it like such: EntityThatWasHit->HealthComponent->TakeDamage(25 * CollidedEntity.GetProperty("FireResistance")); But I don't think the Fireball should (or could) be responsible to know every single property that can modify damage. What if you're playing on Hard and all damage is doubled? What if there's a special boss monster that takes twice as much damage? All of those seem like the responsibility of the HealthComponent to manage. But if the next game doesn't have a Hard mode, or it doesn't have Fire Resistance, or it doesn't have bosses... it's no longer re-usable. Any insights? Apologies for the long ramble.