Skip to content

Add namespaces for components and systems for easier file structure#88

Open
W3NDO wants to merge 2 commits intoecsx-framework:masterfrom
W3NDO:develop/namespace
Open

Add namespaces for components and systems for easier file structure#88
W3NDO wants to merge 2 commits intoecsx-framework:masterfrom
W3NDO:develop/namespace

Conversation

@W3NDO
Copy link

@W3NDO W3NDO commented Mar 3, 2026

When using ecsx, entities are entirely conceptual. I however struggle with keeping everything in my head as the number of components or systems grow. This pull request adds a flag on the systems and components generator --namespace that allows creating the associated files in specific namespaces.

For instance, If we have a game simulation where we have a ship entity(conceptual) with XPosition, YPosition, HealthPoints and Armor components, we could run

  mix ecsx.gen.component HealthPoints integer --namespace Ship
  mix ecsx.gen.component Armor integer --namespace Ship
  mix ecsx.gen.component XPosition integer --namespace Shared
  mix ecsx.gen.component YPosition integer --namespace Shared

and end up with this folder structure:

|-- Components
  |-- Ship
    |-- health_points.ex
    |-- armor.ex
  |-- Shared
    |-- x_position.ex
    |-- y_position.ex

I have added tests to ensure that the components and systems are correctly added to the manager.ex and that the files are correctly generated. Similarly the file content is updated accordingly so that a file like health_points.ex will contain:

  defmodule MyApp.Components.Ship.HealthPoints do
    @moduledoc """
    Documentation for HealthPointsComponent components.
    """
    use ECSx.Component,
      value: :integer
  end

W3NDO added 2 commits March 3, 2026 12:02
- Added a namespace flag for easier organisation of components and systems
- fixed formatting
@W3NDO W3NDO changed the title Develop/namespace Add namespaces for components and systems for easier file structure Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant