Should CanAttack() be part of CombatTarget?

Every statement within CanAttack(CombatTarget combatTarget) is accessing the combatTarget and it makes more sense to me for this method to be a member of that class rather than of fighter.

The CombatTarget component enables something to be targeted in combat, so it makes sense for it to contain the logic for whether or not the CombatTarget can be attacked.

1 Like

It seems that way now, but when we get to Swappable Control Systems, we’re going to be changing that

public bool CanAttack(CombatTarget combatTarget) 

to

public bool CanAttack(GameObject combatTarget)

Because we also want our enemies to use the same method (the player doesn’t have a CombatTarget), and because the CombatTarget really doesnt’ need to know about the Mover or the Health component, where the Fighter already needs to know about both of these things. We were just using CombatTarget up till now to serve as a reference to get to the other components we need.

That’s not to say that it can’t be done in CombatTarget.

Privacy & Terms