1
lorentz
1y

What do I call Components as used in ECS when my app is entirely written in React and I want to avoid the tedium of qualifying the names?
This is a really fundamental thing to the project so I get to pick less-than-ideal but short names since anyone who works with the code will encounter it within the first 5 minutes.

Comments
  • 1
    Trait might be a passable name
  • 1
    @12bitfloat I quickly renamed everything and I really like this, thank you!
  • 1
    @lorentz Glad it finally found a use. I wanted to use it for my ECS in rust but that wasn't a particularly good idea :D
  • 1
    @12bitfloat Why not Component?
  • 1
    @lorentz I wanted to differentiate it from more traditional ecs terminology bacause I had something quite a bit different in mind
  • 1
    @12bitfloat I'm a bit uncertain as to what ECS actually is. Bevy's approach is very conservative, but there's also Unity where behaviours have inheritance and the tree is kinda just for context, Godot where behaviours have both a tree (object tree) and an inheritance hierarchy, and identities are realised in the Scenes which are comparable to React components.

    In my model, traits can implement other traits and entities have exactly one trait, but because casting to a trait is done via view objects, this is most efficiently realised by creating instances of parent traits on the distinguished traits that manage an entity's state. Conceptually it's somewhere between an is-a and a has-a relation, hence why I call it ECS.
  • 1
    And just as I wrote this I realized that I forgot to pick an implementation based on the root trait, so it's very possible to end up with two different instances of the same trait - one direct and one indirect - referencing the same entity. Rubber ducking internet strangers is great!
  • 1
    @lorentz Traditionally ecs have dumb entities to which you can attach components which are just data. Then you have systems that specify which component combinations they want to work on and then they run over all entities with the given combinations

    I don't know if I understood how you're doing it but what I like is that in your approach you can have entity "classes" (by having a super trait for each entity). That's not something an ecs typically does, which always annoyed me

    Also behaviour on components/traits is a must! I don't understand how these people build pure data oriented ecs'. Have they never heard of encapsulation?
  • 0
    @lorentz Also glad to hear you found a bug :D
Add Comment