Copy and paste versus public call

I generally like to avoid cut and paste if I’m doing the same thing, as in KillEnemy() here, because that’s effectively an untracked branch. So I chose to make KillEnemy public and call it directly from EnemyMovement. Then I added the ParticleSystem as a parameter. Now, this may violate encapsulation by exposing another function. I guess I was thinking of the GameObject as the class, not the actual…well, class. Is there a better solution for these seemingly conflicting desires?

Privacy & Terms