Item system. Components or not?

Hey guys.
I’m creating an item system and I’m wondering which approach would be the best.

  1. Each item is a different class.
  2. Each item category is a different class.
  3. One Item class + store items in database and create components, like ItemHealthAction (ex. heal the player when used), with Action method that would be executed for each added component to the item.

There are multiple different ways to handle items depending on how you want to setup such a system. Items can be custom classes or can be a generic type with an ID that points to a database with all of its properties. There really is no wrong answer. Design it how you feel like it should work and then if down the road you see a better way either refactor your code and just learn from your mistake for the next time you implement such objects.

For instance if you have a simple game with 2 or 3 items then you can just create custom classes for each item but if you need a larger variety each with its own attributes and functionality database might be a better solution. Really it depends on your game and how items work and how much work you want to put into it. Better to get a couple items working and then see if you need to implement a different system than you started on.

I’ve fallen into a trap where I spend so much time trying to figure out how to design / rewrite systems to work better that I actually don’t get any tangible results. So go with your gut and learn from your mistakes for future projects.

It really depends on what type of game you are going for, what items, with what functionality, how many, is it multiplayer etc.

Thanks! I was scared that I might run into some problems by choosing the wrong approach. Your answer really helped me and motivated me to spend more time actually trying to implement it.

It’s survival game, so there will be many items (materials, weapons, etc.) First I’m planning to make singleplayer and later add multiplayer functionality.