Skip to content

Make Timer a component#263

Merged
waynemwashuma merged 4 commits intowimaengine:devfrom
waynemwashuma:make-timer-a-component
Sep 20, 2025
Merged

Make Timer a component#263
waynemwashuma merged 4 commits intowimaengine:devfrom
waynemwashuma:make-timer-a-component

Conversation

@waynemwashuma
Copy link
Collaborator

@waynemwashuma waynemwashuma commented Sep 20, 2025

Objective

Refactors the Timer to become a proper ECS component. It moves the Timer from a standalone type to a component that can be attached to entities and automatically updated by the engine's systems.

Solution

The solution involved restructuring the Timer implementation to follow ECS patterns:

  • Moved Timer to components: Converted Timer to a component type
  • Added system-based updates: Created system that automatically updates all Timer components
  • Integrated with TimePlugin: Registered Timer as a component type and added the update system
  • Maintained API compatibility: All existing Timer methods and functionality remain unchanged

Showcase

The Timer now works as a proper ECS component:

// Create entity with Timer component
commands
  .spawn()
  .insertPrefab([
    new Timer({
      mode: TimerMode.Repeat,
      duration: 10,
      speed: 1.0
    })
  ])
  .build()

// Timer is automatically updated by the engine
// No manual update calls needed

Migration Guide

No breaking changes.

Checklist

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

@waynemwashuma waynemwashuma self-assigned this Sep 20, 2025
@waynemwashuma waynemwashuma added type:change mod:time This PR/issue affect the time package labels Sep 20, 2025
@waynemwashuma waynemwashuma marked this pull request as ready for review September 20, 2025 21:23
@waynemwashuma waynemwashuma merged commit f0612ad into wimaengine:dev Sep 20, 2025
5 checks passed
@waynemwashuma waynemwashuma deleted the make-timer-a-component branch September 20, 2025 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:time This PR/issue affect the time package type:change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant