Coding isn't that hard actually. The hard part is to write code that makes sense, is readable and understandable. So I want to get a better developer and create some solid architecture.
So I want to do create an architecture for NPCs in a video-game. It is a Realtime Strategy game like Starcraft, Age of Empires, Command & Conquers, etc etc.. So I'll have different kinds of NPCs. A NPC can have one to many abilities (methods) of these:
I hope everything is clear so far.
So now I do have my NPC Types and their abilities. But lets come to the technical / programmatical aspect.
What would be a good programmatic architecture for my different kinds of NPCs?
Okay I could have a base class. Actually I think this is a good way to stick with the DRY principle. So I can have methods like
WalkTo(x,y) in my base class since every NPC will be able to move. But now lets come to the real problem. Where do I implement my abilities? (remember:
Since the abilities will consists of the same logic it would be annoying / break DRY principle to implement them for each NPC (Worker,Warrior, ..).
Okay I could implement the abilities within the base class. This would require some kind of logic that verifies if a NPC can use ability X.
CanBuild, .. I think it is clear what I want to express.
But I don't feel very well with this idea. This sounds like a bloated base class with too much functionality.
I do use C# as programming language. So multiple inheritance isn't an opinion here. Means: Having extra base classes like
Fisherman : Farmer, Attacker won't work.