r/EntityComponentSystem • • Feb 21 '24

Functional ECS Attempt in TypeScript

5 Upvotes

Hello!

I would like to get some opinions and/or suggestions on my little ECS engine attempt. Below is the github link. I'm looking for some constructive advice, possible optimizations, and basically whether or not this project is worth building upon.

https://github.com/n3rdw1z4rd/ecs-engine

Here's a screenshot:


r/EntityComponentSystem • • Jan 27 '24

Practices for managing systems order in ECS

Thumbnail self.gameenginedevs
5 Upvotes

r/EntityComponentSystem • • May 30 '23

Arche 0.8 released - Go ECS with native entity relations

5 Upvotes

Arche is an archetype-based Entity Component System for Go.

Release highlights

Version 0.8 adds naitve support for entity relations. This allows for the representation of entity graphs, like hierarchies, as a native ECS feature. Relations are treated like normal components, and relation queries are as fast as usual queries for components.

Arche's entity relations are inspired by Flecs, although the implementation is simpler and provides a more limited set of features.

For a full list of new features and other changes, see the release notes.

Arche's features

  • Simple core API.

  • Optional logic filter and type-safe generic API.

  • Entity relations as first-class feature.

  • No systems. Just queries. Use your own structure (or the Tools).

  • No dependencies. Except for unit tests (100% coverage).

  • Probably the fastest Go ECS out there. See the benchmarks.

For more information, see the GitHub repository and API docs.


r/EntityComponentSystem • • Sep 18 '22

Tutorial: making a data container act like an ECS

Thumbnail
github.com
5 Upvotes

r/EntityComponentSystem • • Aug 02 '22

Regarding quantities of components and systems in ECS architecture

Thumbnail self.gamedev
5 Upvotes

r/EntityComponentSystem • • Jun 23 '22

Does it make sense to use ECS for an audio system in game engine?

5 Upvotes

I have been scratching my head around implementing an audio system and trying to figure out how it fits into the ECS. Audios are generally one time operations and I might want to play different audios at the same time. Does it make sense to create some kind of an Audio component to store audio data or is it not worth the effort and I should just use events to play different audio?


r/EntityComponentSystem • • Jun 03 '22

ECS question

Thumbnail self.gameenginedevs
5 Upvotes

r/EntityComponentSystem • • May 09 '22

When using the archetype pattern for ECS, how does one update a component?

5 Upvotes

I have been looking into differences between archetypes vs sparse sets and I really like the idea behind archetype pattern (I am currently using sparse sets) because I can reduce branching when an entity does not have specific component (with sparse sets, I still need to have conditions to check whether an entity have component in the larger sparse sets).

However, I cannot understand one part of archetypes. How does update work in this pattern? If we have multiple copies of the component in multiple "archetypes," do I not need to update the value in every single array? Won't it result in needing to access different arrays, which will result in significantly more cache misses?


r/EntityComponentSystem • • Apr 23 '22

Supporting ECS in the type system of a scripting language?

5 Upvotes

Hi, I have a bunch of questions and ideas about how ECS could be natively supported in the static type system of a scripting language that is to be connected to the rest of an ECS based game or application. It's probably bs, but I got that idea stuck in my brain, so in order to unstuck it, I'll funpost this anyway.

Caveats are: It's all theory and my knowledge about ECS is shallow at best. I assumed the most basic, vanilla kind of ECS I could think of. So at best you are looking at prior art, but more likely, it is a waste of time. Feel free to correct any misconceptions I have about ECS. Also, I assume that with a scripting language the massive speedup you'd otherwise get from data orientation is off the table, so you would only want to handle individual objects.

The basic assumption about such a scripting language is, that it has the usual amount of primitive types, arrays, functions etc. There would be a type system supporting ECS components. Also, it is triggered by events.

The first question is: How would events reach the script?

At first I figured, you would have special systems that call an event if the systems condition is met. Like so:

fun handleCollision(a as ScriptCollidableComponent, b as CollidableComponent)
    // a is in the system that triggers the scripted event
end

But it seems wasteful to have a system for just a small bunch of entities. But at the same time it would possibly be expensive to hold the data required for this system in a normal collidable component system. Is there an agreed upon way to do this?

As for the type system, I'd figure the basic assumption is that for any component type, the interpreter is just passing along the entity. However, systems are registered types that include what properties and functions are available for their components:

fun handleCollision(a as ScriptCollidableComponent, b as CollidableComponent)
    // let's say script collidables have a name, so scriptable components can be identified individually
    if a.name == "Ghostifier" do
        // let's say collidables have a tag that can switch of collision checks
        b.isImmaterial = true
    end
end

So far there shouldn't be any technical reason that this wouldn't work, should there?

In order to get other components of an entity you'd need a bunch of operators, similar to cast operators or pattern matching:

fun handleCollision(a as ScriptCollidableComponent, b as CollidableComponent)
    // let's say a has a tag, so scriptable components can be identified individually
    if a.name == "Ghostifier" do
        // let's say you want to remove b from the CollidableComponent system
        removeFrom(b, CollidableComponent)
        // some registered function removed the component, b is now of type Entity as far as the type system is considered
        
        // make b transparent, if it has a component in rendering
        tryGet b as RenderableComponent do
            // in here, b has a component in the RenderableComponent system
            // some registered function checked that the component to this entity exists
            b.transparency = 0.5
            
            // you could also imagine an else branch or multiple component types being checked for
        end
        
        // create a speech bubble
        getOrCreate b as SpeechBubbleable do
            b.setBubbleText("Oh no, I'm a ghost now.")
        end

    end
end

In order for this to work, not only would you have to register properties and functions for each system, but also functions to create, query or delete components in each system.

Do you see any technical reason why this wouldn't work? One difficulty I see is order of processing, because each script can potentially access any component at any time.

Now another idea for the type system is groups, in order to avoid querying the systems for components all the time. Basically, you'd register a group as a type at the interpreter that includes multiple systems. It would also mean that you couldn't remove a component from a system within the group.

Any idea if all of the above would work or would not work? Any further ideas?


r/EntityComponentSystem • • Mar 23 '22

my new article on ecs and code design

Thumbnail
sebaslab.com
5 Upvotes

r/EntityComponentSystem • • Mar 02 '22

Should components be plain old data structures or OOP classes with destructors and functiond?

5 Upvotes

I am using C++ for my entities and this question have become important due to the fact that I need to delete system specific resources while deleting the component. When I check Unity or UE4, all the components have functions and constructors etc but I am not sure of this is just a user API or the internal structure is also like that.

Should components be plain structs:

struct CollidableComponent {
  PxShape* shape;
  GeometryDesc geometryDesc;
};

Or OOP classes:

class CollidableComponent {
public:
  CollidableComponent(PxShape *shape) : mShape(shape) {}

  ~CollidableComponent() {
    mShape->release();
  }

private:
  PxShape *mShape;
};

If POD structs are preferred, how should synchronization between components and system's internal objects happen? (e.g NVIDIA Physx physics system had its own representation of scene).


r/EntityComponentSystem • • Jul 22 '21

The Similarities between an ECS and a rendergraph

Thumbnail self.gamedev
5 Upvotes

r/EntityComponentSystem • • Jun 06 '21

How come you can't visit this subreddit from a mobile browser?

Post image
5 Upvotes

r/EntityComponentSystem • • May 22 '21

What are some of the most common bad practices with ECS?

Thumbnail self.gamedev
5 Upvotes

r/EntityComponentSystem • • Apr 29 '21

A new podcast for software engineers and first episode about ECS with Sebastiano Mandalà, author of Svelto.ECS

Thumbnail
sonny.alvesdi.as
5 Upvotes

r/EntityComponentSystem • • Apr 02 '21

Ecs with spatial separation

5 Upvotes

Hello guys,

I'm wondering how to separate entities with the use of octrees to distribute the workload of different spaces in a setup with multiple nodes. I thought about the entt framework in combination with the octree pattern and zeromq. But I'm currently curious how to distribute the entities through multiple registries and still allow interaction between them.

Has anyone some hints on how to do this?


r/EntityComponentSystem • • Oct 16 '20

Deconstructing Flecs Prefabs

Thumbnail
ajmmertens.medium.com
5 Upvotes

r/EntityComponentSystem • • Jul 12 '20

Looking for someone to write a brief introduction to the ECS design pattern for the subreddit wiki

5 Upvotes

Anyone with at least 3 subreddit karma can edit:

https://www.reddit.com/r/EntityComponentSystem/wiki/index


r/EntityComponentSystem • • May 19 '20

An Entity Component System with Data Locality in C++ (code walk-through)

Thumbnail
indiegamedev.net
5 Upvotes

r/EntityComponentSystem • • May 02 '20

More complex applications of Entity Component Systems

Thumbnail self.gamedev
5 Upvotes

r/EntityComponentSystem • • Feb 22 '20

EnTT v3.3.0 is out: Gaming meets Modern C++

Thumbnail self.gamedev
5 Upvotes

r/EntityComponentSystem • • Dec 07 '19

Card model and visuals made using ECS

5 Upvotes

r/EntityComponentSystem • • Sep 05 '19

EnTT v3.1.1 is out: gaming meets modern C++ - a fast and reliable Entity-Component-System (ECS) and much more

Thumbnail
github.com
5 Upvotes