Skip to content

Add World method to remove components.#248

Merged
waynemwashuma merged 3 commits into
wimaengine:devfrom
waynemwashuma:world-remove-component
Sep 11, 2025
Merged

Add World method to remove components.#248
waynemwashuma merged 3 commits into
wimaengine:devfrom
waynemwashuma:world-remove-component

Conversation

@waynemwashuma
Copy link
Copy Markdown
Collaborator

@waynemwashuma waynemwashuma commented Sep 11, 2025

Objective

Introduces core proper remove() method for entities on the World.

Solution

The changes include enhanced World by adding remove() method that allows removing specific components from entities while maintaining proper ECS architecture with archetype transitions and hook calls.

Showcase

This example shows how to use the new method:

class Position { x = 0; y = 0; }
class Velocity { dx = 1; dy = 1; }
class Renderable { /* ... */ }

const world = new World()
  .registerType(Position)
  .registerType(Velocity)
  .registerType(Renderable);

const entity = world.spawn([new Position(), new Velocity(), new Renderable()]);

// Later, remove the Velocity component
world.remove(entity, [Velocity]);

// Entity now only has Position and Renderable components

Migration Guide

No breaking changes to existing APIs.

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

This method acts to remove components from an entity.
@waynemwashuma waynemwashuma self-assigned this Sep 11, 2025
@waynemwashuma waynemwashuma added type:enhancement New feature or request mod:ecs labels Sep 11, 2025
@waynemwashuma waynemwashuma linked an issue Sep 11, 2025 that may be closed by this pull request
@waynemwashuma waynemwashuma marked this pull request as ready for review September 11, 2025 12:14
@waynemwashuma waynemwashuma merged commit 31c6a0b into wimaengine:dev Sep 11, 2025
5 checks passed
@waynemwashuma waynemwashuma deleted the world-remove-component branch September 11, 2025 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:ecs type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a method to remove component(s) from an entity

1 participant