Designing a Scalable Combat System with Composition

I thought I had watched that first video, and maybe I did, but I was also confusing it with the one in this thread:

Feel free to read my comments on that.

I then talked at length about composition in Godot in this thread:

I’m linking them because it’s a LOT to type.

First Video

This guy kinda gets components, and kinda doesn’t. First of all, his naming SUCKS, but he shares that with the second guy. You don’t name something “Component”. You just name it what it is. Sprite2D isn’t called Sprite2DComponent, so why should yours be called that?

Also, an Input component seems like a good idea, but it actually breaks the Single Responsibility Principle that he’s talking about while he’s showing off his components. In fact, SRP is really hard to implement well, and when you do it looks dumb. Using SRP would mean you have one object for left input, another for right input, and well… you get the idea.

Instead, input should be handled by the object that is affected by it. Or, by a component in some cases. But not an Input component. Here’s why: That Input component doesn’t DO anything. For the Movement component to work, it has to rely on the Input component existing. This is called tight coupling, and again, goes against the SRP he says he’s following. (The one exception to this is if you’re using a Command Pattern.)

I stopped about 5 minutes in, but overall, he was discussing the benefits of components well. I just don’t feel like watching an hour of video.

Second Video

In the second video, his intro is good, but his naming convention SUCKS. Notice how everything he made was called HealthComponent and HurtBoxComponent. Right after he got gone explaining how Sprite2D and AudioStreamPlayer are components.

In this post, I walk you through creating a Health component:

It even has a cool icon:
image

And a number of visual representations for the same component:

Your Stuff

I would say the Resource approach you’ve adopted is the best one. I walk someone how to implement something like that in this thread here:

For your needs, basically you are using a Command Pattern. So if you keep all the details inside your Resource object, you can just attach them to the Weapon. Those Resources can even have generic functions in them like attack() or use(). Then you can just call those functions and have custom code when necessary.