Core - GoldhawkInteractive/X2-Modding GitHub Wiki

Artitas is a C# Entity-Component-System framework inspired by Artemis-ODB and Entitas. The general design centers around reactive design that uses code generation to provide easy and performant syntax.

Features

The major features or choices, along with their design inspiration are:

  • Artemis:
    • Data-Driven: Templates allow (de-)serialization of entities with polymorphism-like behavior (Nested Templates).
    • Performance:
      • Entity Instantiation: Repeated, or mass instantiation of Entities can be done through Templates which cache operations on demand.
      • Cache-Friendly-er: Entities are just IDs, Components reside in Arrays(Struct/Class) as to enable memory alignment.
      • Entity Composition: Sets of Components are translated into IDs to which a Family subscribes. Lookups are cached upon use to ensure
      • TODO: Batching of mutations on entities as base implementation.
  • Entitas:
    • Programmer-Friendly: Code generation provides DSL on components/events. (E.g.: entity.Health() instead of entity.GetComponent<Health>())
    • Reactive Design: Allow logic to react to changes on Components. Combined with
    • GC-Friendly: Pooling of Components (through DSL)

Aside from the features gleaned from other frameworks, Artitas comes with new features of its own:

  • Relationships: Links between Entities and other Entities, strings or types which are maintained and updated by the framework on changes to a single side.
    • Tags: Link a unique Entity to a string or Type. (E.g.: "CurrentPlayer", "Selected")
    • Groups*: Link multiple Entities to a string or Type. (E.g.: "Items")
    • One-to-One/Many: Links between a single entity and another, or group of entities. (E.g.: Enemy, Controller <-> Controlling, Owner <-> Owns)
    • Cascade: Allows an Entity to subscribe to all changes in Components of target Entity. These changes will then be copied into the entity as well. (E.g.: Create a Group entity and have all Entities target as Cascade.)
  • Event-Driven: Systems can subscribe to events which can be thrown in the world.
  • Hotspot Optimization: The results of operations that mutate entities (Add/Remove Component) and cause an Entity to register to different Families are only calculated once. The programmer does not need to manually define which operations to optimize, as they are done so by the framework.
  • Lifecycle Clarity: The lifecycle of Entity, Components are all well documented and defined.
⚠️ **GitHub.com Fallback** ⚠️