Skip to content

[feat] PauseComponent#3656

Merged
jyoung4242 merged 13 commits intomainfrom
PauseComponent
Mar 29, 2026
Merged

[feat] PauseComponent#3656
jyoung4242 merged 13 commits intomainfrom
PauseComponent

Conversation

@jyoung4242
Copy link
Copy Markdown
Contributor

PR Description: Pause System Component Implementation

Overview
Implements a comprehensive pause system for the Excalibur game engine using the ECS (Entity Component System) architecture, allowing selective pausing of entities while maintaining fine-grained control over game state.

Changes Made
Core Components:

PauseComponent - New ECS component tracking pause state and pausability with paused (read-only) and canPause properties
PauseSystem - New ECS system that manages pause state across entities, listening to scene pause/resume events and updating component states accordingly
ActorArgs: added canPause:boolean as optional argument

Scene Integration:

Added pauseScene() and resumeScene() methods to Scene class
Integrated PauseSystem into scene initialization
Scene events emit pause/resume notifications for UI and other systems
all default system updates now monitor pause status

Exports:

Exported PauseComponent from ECS module index
Exported PauseSystem from main engine utilities

Documentation:

Added comprehensive 12-pausing.mdx guide covering:
System overview and architecture
Quick start examples
PauseComponent properties and usage
Scene event handling for pause menus

Testing:

Added full test suite in pause-spec.ts with 12+ test cases covering:

System initialization
Scene event handling
Per-entity pause control
Multi-entity scenarios
Dynamic property changes
Resume/pause toggling

Key Features
Selective entity pausing (only pause entities with canPause: true)
Non-pausable entities continue updating during scene pause
Clean scene-level pause/resume API
Event-driven architecture for UI integration
Full backward compatibility

@jyoung4242 jyoung4242 requested a review from eonarheim January 6, 2026 15:00
@jyoung4242 jyoung4242 changed the title PauseComponent [feat] PauseComponent Jan 6, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 6, 2026

Deploying excaliburjs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 70a39b3
Status: ✅  Deploy successful!
Preview URL: https://a9da4128.excaliburjs.pages.dev
Branch Preview URL: https://pausecomponent.excaliburjs.pages.dev

View logs

@kamranayub
Copy link
Copy Markdown
Member

Oops, I didn't want to "delete" it from the tree, just revert/delete it from the PR 🙃


The Pause System consists of two main components:

- **`PauseComponent`** - A component that already is attached to [Actors](/docs/actors)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: flip 'already' and 'is'. (A component that is already ...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do


public systemType = SystemType.Update;
public query: Query<ComponentCtor<TransformComponent> | ComponentCtor<ColliderComponent>>;
public query: Query<ComponentCtor<TransformComponent> | ComponentCtor<ColliderComponent> | typeof PauseComponent>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would one reach for ComponentCtor<T> vs straight up typeof ...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't know the answer to this, i was just following the documented pattern. maybe @eonarheim would know?

Comment on lines +107 to +110
const paused = entity.get(PauseComponent);
if (paused.paused) {
continue;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this go above const colliderComp on line 106 since we wouldn't be using it if paused?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can

Comment thread src/engine/events.ts
}

/**
* Event thown on a pause event in scene
Copy link
Copy Markdown
Contributor

@sweenist sweenist Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: thown => thrown
Same one line 782.
Copy 🍝?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

Comment on lines +27 to +30
paused = entity.get(PauseComponent);
if (paused.paused) {
continue;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth moving this after line 24 since we'll continue if paused?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@jyoung4242
Copy link
Copy Markdown
Contributor Author

@sweenist i can address fixes tomorrow... too tired

@github-actions
Copy link
Copy Markdown

This PR hasn't had any recent activity lately and is being marked as stale automatically.

@github-actions github-actions Bot added the stale This issue or PR has not had any activity recently label Mar 16, 2026
@jyoung4242 jyoung4242 merged commit b636669 into main Mar 29, 2026
12 checks passed
@jyoung4242 jyoung4242 deleted the PauseComponent branch March 29, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue or PR has not had any activity recently

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants