I have some count of weapons - pistol, shotgun, rifle. And I have one system which deals with all weapons, and another system which deals only with pistol. So I need to create both components "weapons" and "pistol", and I add them both to the entity - "Pistol". So now we have next components - "Weapons", "Pistol", "Rifle", "Shotgun", becase probably I will need to have separate system for different weapons in future. Then in the same reasons I create next Components - "Character", "Player", "Enemy", "Friend" (maybe more types of Enemies and Friends), "Ammo", "AmmoForPistol", "AmmoForRifle" ... And there are too much different components only for tagging different entities regarding to the types. How can I avoid this amount of Components?
There is really no harm in adding a single
WeaponComponent which holds a
TYPE attribute to describe whether it's a Pistol, Rifle, Shotgun, Knife, etc.
Nothing dictates however that you must store all
WeaponComponent instances in the same list inside your
WeaponSystem either. In fact, to avoid branching on specific use cases, it might be advantageous to store each
WeaponComponent in a type-specific list and simply iterate over multiple lists as part of your update loop.
I also don't believe that Character and Player make sense to be represented as components.
In order to determine hostility vs friendly could simply be derived by checking whether the entity in question has a specific type of component, perhaps
HostileComponent. The assumption here being that all entities are friendly unless that component exists.
There are plenty of ways to split / tag things through components without going overboard.