I am trying to make a modular ship system, where parts can be added or removed to the ship entity.
I am using a class I made called
ModuleManager and it has a list of
ShipModules. this works fine for very basic block building ships, but I want to add a
ThrusterModule that has thrust capabilities, and possible a
GunMountModule for obvious reasons.
the problem is that I cannot do this.
List<ShipModules> modules = new List<ShipModules>();
ThrusterModule engine = new ThrusterModule();
I know that I cannot do this because they are different types.
Question: How can I add all these modules to the module manager? because I don't want to have to deal with having several different type modules that need several different variables to hold them
I have an idea of what to do, but I want to know if it would be the best route, I have heard of Class Composition. would that be beneficial for what I have explained? thanks.