Use tuples instead of vectors. Tuples allow you to have a dynamic array that contains multiple types.
@Code_Gains8 ай бұрын
Thanks for the tip. I will be sure to include tuples in my analysis once I come back to this in the future vids.
@timtreichel31617 ай бұрын
No I don't think this is a good if you want to go with an ECS architecture. You want the components to be stored continuously, for each component type. So going with a single vectors for each component is exactly the right way to go. Then you want to iterate over the components vectors individually when updating the game/simulation state. That way you have the most cash benefits. Code duplication can be avoided with templates. Looking up components can also be implemented with linear or binary search and will probably be fast enough in most cases. Dealing with hash maps brings their own draw back, but I guess it can be done and might be needed in some cases.
@Abdullah-nu4od3 ай бұрын
Love this channel
@GTGTRIK9 ай бұрын
This is really helpful on my own ECS journey. I've been struggling with the whole magic layer of "linking components to entities".
@Code_Gains9 ай бұрын
Glad to hear I helped someone
@TheTimmyewrardАй бұрын
I'm now not alone with feeling dumb...
@basboerboom93289 ай бұрын
I feel your pain. I am currently on my countless'th iteration of ECS for my game. Every time I almost get a Eureka moment, I run into a problem with my ECS system.
@ParanoicoBR11 ай бұрын
The internet historian style video but for programming. I love it! Keep up the good work, man!
@anthonyapm8 ай бұрын
Good job man. I've been battling the same problems 😅
@aybcrazybeats85884 ай бұрын
I suggest you consider creating a generic "Component" type. After that all those individual component vectors could get replaced a single vector holding either component pointers or better yet, smart pointers. Doing that you don't have to create new containers for every new component type. Exploit the features of polymorphism, that way you can write code that's more maintainable and easily expandable with new features
@theseangle18 күн бұрын
Interesting approach, except that it goes against the whole point of ECS, which is Data Oriented Design. At that point your code will not get any benefit from ECS. Storing each component instance in a random place in the heap will *not* make your code any better than multiple-inheritance OOP mess
@drominitoketchup8 ай бұрын
Nice, another guy who loves low level programming². Oh, I'm already a subscriber to your site, I didn't even notice 🤔
@liutaurasgaidamavicius137911 ай бұрын
shadow wizard money gang
@doce360911 ай бұрын
i am loving it 👍🏻👍🏻
@dontknow786311 ай бұрын
Best video so far ,,🔥💪😎
@thomasp951111 ай бұрын
Keep it up champ💪
@Felix-we7iq11 ай бұрын
Deciding what type of int the ID of an entity should be sure is the most difficult part of ecs
@Code_Gains11 ай бұрын
I think I will switch to size_t later :')
@arnoldaz11 ай бұрын
God programmer is back at it again. When you were explaining why you moved to ECS, is there any reason why do you think you need separate classes for Physics Sphere or Physics Trail Sphere? Can't you just have some parameters in Sphere class that can be set on or off for each functionality? Or even do dependency injection for components if they share some common base. Amazing video as always tho!
@Code_Gains11 ай бұрын
There is nothing inherently special with ECS that allows to solve this and you likely could make it work. In my case having separate classes in OOP would ensure that you are not wasting memory by having properties on objects that should not have these properties (like physics) and passing parameters to enable functionality would likely still have the same memory overhead issue. I did not even consider doing something like injecting components (I guess ECS is kind of similar in a sense?), but I would have to be honest that I had my mind set on ECS without much consideration for OOP to begin with since I have plans for large scale simulations.
@Doggy_Styles_Coding11 ай бұрын
looks cool :D cant find anything dump
@Code_Gains11 ай бұрын
Hopefully someone will. I need to live up to the title