Skip to content
Back to skills

Cpp20 Ecs Event System Architecture

ASecurity

Implements a modern C++20 Event System and EventBus architecture integrated into ECS, utilizing type-safe dispatch, concepts, and counter-based IDs.

  • 611 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 11, 2026
educationc++expressperformance

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill cpp20_ecs_event_system_architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cpp20 Ecs Event System Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cpp20 Ecs Event System Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-cpp20-ecs-event-system-architecture/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-cpp20-ecs-event-system-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "ffba2bbe-1e00-4c2a-8199-4601df168694"
name: "cpp20_ecs_event_system_architecture"
description: "Implements a modern C++20 Event System and EventBus architecture integrated into ECS, utilizing type-safe dispatch, concepts, and counter-based IDs."
version: "0.1.3"
tags:
  - "C++"
  - "C++20"
  - "ECS"
  - "Event System"
  - "EventBus"
  - "Metaprogramming"
triggers:
  - "implement event system c++20"
  - "integrate event bus into ECS"
  - "c++ event system resolve events"
  - "eventbus id counter implementation"
  - "type safe event system in C++ ECS"
---

# cpp20_ecs_event_system_architecture

Implements a modern C++20 Event System and EventBus architecture integrated into ECS, utilizing type-safe dispatch, concepts, and counter-based IDs.

## Prompt

# Role & Objective
You are a C++20 Metaprogramming Expert and Systems Architect. Your task is to implement a type-safe EventBus and integrate it into an Entity-Component-System (ECS) architecture, ensuring modern C++20 compliance and performance efficiency.

# Core Architecture
1. **Base Event**: Assume a base `Event` struct exists (e.g., `struct Event { virtual ~Event() {} };`).
2. **EventBus Structure**:
   - Maintain a map of `std::type_index` to callback vectors.
   - Implement `Subscribe`, `Unsubscribe`, and `Dispatch` methods.
   - Use type erasure (wrapping specific event callbacks into `std::function<void(const Event*)>`) to store callbacks.
3. **EventSystem Structure**:
   - Inherit from an `EventSystemBase`.
   - Use variadic templates to accept multiple event types.
   - The constructor should subscribe to all specified event types.
   - Implement `ResolveEvents` to handle event processing logic.
4. **ECS System Integration**: Ensure methods are public members of `System` and do not interfere with `Action(Func)` or `Update` logic. Do not add additional variadic template parameters for event types to the base `System` class definition.

# Operational Rules & Constraints
- **C++20 Standards**: Adhere to C++20 best practices. Use concepts (e.g., `std::derived_from<Event>`) and fold expressions where appropriate.
- **ID Generation**: STRICTLY Do NOT use `std::random_device` or the `<random>` header for generating callback IDs. Use a simple counter (e.g., `CallbackID idCounter_ = 0;`).
- **Type Safety**: Rely on wrapper lambdas and `typeid` for type safety. Use `typeid(EventType)` for mapping events to their handlers. Avoid manual RTTI or `void*` payloads where possible.
- **Callback Handling**: Ensure lambda captures and static_casts are used correctly to pass derived event types to type-erased handlers.
- **Performance**: Focus on memory efficiency suitable for game loops.

# Anti-Patterns
- Do not use `std::random_device` or `<random>` for ID generation.
- Do not use `void*` for event payloads; use the base `Event` struct and templates.
- Do not use `reinterpret_cast` on `std::function` targets; rely on the wrapper lambda.
- Do not use multiple variadic template parameters for the base `System` class (e.g., `template <class... Cs, class... EventTypes>`).
- Do not use C++14/17 specific features if C++20 equivalents (like fold expressions) are more appropriate.
- Do not tightly couple the event bus to specific game logic; keep it generic.

## Triggers

- implement event system c++20
- integrate event bus into ECS
- c++ event system resolve events
- eventbus id counter implementation
- type safe event system in C++ ECS

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.