Skip to content
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
This repository was archived by the owner on Jul 29, 2026. It is now read-only.

refactor: remove GameObject dep from DelayedComponentEnabler #248

Description

@ThorstenSuckow

Summary

DelayedComponentEnabler::defer() currently accepts a GameObject parameter and performs entity-level operations (has(), disableComponent()) directly inside the component. This violates the data-oriented design principle that components should be pure data containers without dependencies on entity abstractions.

Current State

// DelayedComponentEnabler.ixx
import helios.engine.ecs.GameObject;

void defer(
    helios::engine::ecs::GameObject gameObject,
    helios::engine::ecs::types::ComponentTypeId componentTypeId,
    const float delta
) {
    assert(delta > 0 && "delta must be greater than 0");

    const bool hasCmp = gameObject.has(componentTypeId);
    assert(hasCmp && "ComponentTypeId not part of GameObject");

    gameObject.disableComponent(componentTypeId);

    // ... update deferredComponents_ list
}

The component imports helios.engine.ecs.GameObject solely for this method, creating an upward dependency from the data layer (component) to the entity layer (GameObject).

Proposed Change

  1. Remove the GameObject parameter from defer(). The method should only record the deferred component entry (type ID + delay):

    void defer(ComponentTypeId componentTypeId, float delta);
  2. Move the has() assertion and disableComponent() call into the system or the calling code (e.g. DelayedComponentEnablerSystem, DelayedComponentEnablerInitializer, or the listener that invokes defer()).

  3. Remove import helios.engine.ecs.GameObject from the component module.

Affected Files

  • include/helios/engine/mechanics/lifecycle/components/DelayedComponentEnabler.ixx
  • include/helios/engine/mechanics/lifecycle/systems/DelayedComponentEnablerSystem.ixx
  • include/helios/engine/runtime/spawn/behavior/initializers/DelayedComponentEnablerInitializer.ixx
  • All call sites that invoke defer() with a GameObject (e.g. MatchStateListener.ixx)

Motivation

  • Components should remain lightweight, self-contained data holders.
  • Entity-level logic (has, disableComponent) belongs in systems or orchestrating code.
  • Removing the dependency simplifies the module graph and aligns with the project's ECS architecture.

Labels

refactor, ecs

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions