Entity-Component-System

THIS REPOSITORY WILL NO LONGER BE UPDATED BEYOND FIXES

If it wasn’t obvious from the last time a commit was done to the Github repository, this thing is no longer maintained anyway. I wasn’t happy with how this ended up turning out, and ran into quite a few issues while trying to work with it. I approached the ECS problem on Roblox incorrectly, not fully taking into account how Roblox handles things, instead I tried to bruteforce Roblox to work with this framework, instead of trying to get them to play together nicely.

I may try to approach a ECS framework on Roblox again in the future, but I’ll do a better job at it in the future.

Latest Update

Fixed a issue with using the Replications Shared System, that caused everything to hang. (reported by YourFriendlyError)

More on Systems

Systems are usually called in intervals and all the entities are sent with each call, but the systems only get the entities with the Components the System needs to operate on. The order of the Systems will also affect how things work, usually. For example, you wouldn’t want the Input System to be after the PlayerController System (if you had custom player movement) as there could be input lag.
Systems also can’t communicate to each other by default, but on Roblox it’s easy with bindables and remotes.

What are the benefits of the Entity-Component-System over Object Oriented Programming?

In ECS it is easy to create Components and easily swap them out with others, add new ones on the fly during runtime, and allows for easy reuse. While in OOP you have to create new classes that inherit from many things, which doesn’t allow flexibility, nor can you make a new class during runtime to create a class that inherits from it. Since Components are easy to reuse, it allows for less classes that work in similar but varying ways, such as players, bullets, walls, trees, weapons, and so on.

Why I use the Entity-Component-System

It’s ultimately made it easier for me to create game logic, experiment with new things, for example, if I wanted to I could have a game where there are cows, rockets, cars, etc., and at random during runtime I can add a Rocket Component to a random cow, and watch as it flew off. It allows for easy configuration and even allows people who don’t have the full knowledge of coding to mess with things easily.

Github Repository

Github repository for the Entity-Component-System:
https://github.com/FirstValentine/Roblox-Entity-Component-System

57 Likes

This is a really great resource. Clean and easy to read code. I really like the flexibility and structure your system offers in place of OOP.

3 Likes

Very nicely organized and documented.
I think it’s very useful for most people and gives an alternative to Object-Oriented-Programming (OOP).

5 Likes

A very tidy and powerful implementation of ECS, great job! Will definitely study it as to grasp the concept a little better.

3 Likes

Hey - I think custom values for assemblages are broken in the current build.

In ECS.createAssemblage you pass in the components.values to ECS.addComponent, but ECS.addComponent never does anything with those values (not in the arguments).

I tried adding it myself manually but for some reason I can’t get the values into the Component data table. I insert them manually one by one in Entity:AddComponent, but when I try to getcomponent it just returns nil (from the original component).

Will take another crack at it tomorrow. Thanks for the great base, I’m building off it for a test project. Just need to get these custom values for Assemblages working.

1 Like

Thanks for letting me know!
addComponent used to use those values, but I removed the code for it because it wasn’t working properly.
However, it is now added in, you can now expect it all to work like it should :grinning:

2 Likes

For some reason I’ve got an infinite yield when using the function ECS.create()?

1 Like

Did you place everything in the correct spots like the README module said to?

1 Like

Pretty sure I did, do you guys have a discord server where I can seek help?

1 Like

There’s not a discord specific for the library, but check your devforum messages, i’ll send you my discord there

1 Like

I would love to see this in action in Roblox.

I’m currently looking at different frameworks and coding paradigms. ECS looks great to me, however that is how I felt with my last visit to a different framework.

Honestly I find these frameworks very confining and I’ve enjoyed just going with the flow when I code rather than following a set structure.

From your personal experience, what is the process like when making a game using your ECS-like framework?

I haven’t used my ECS library in a good while. I left it because of how I implemented it. That isn’t to say it’s bad, but I ran into a couple issues (that I can’t remember anymore, just an FYI).

I do like ECS in general, but it was just my own implementation I ended up having issues with. If I was to make another ECS library there are a few things I’d do differently, like the composition itself. As well as I’d make it easier to get entities with certain components

2 Likes