icdev-monitor
Production monitoring with log analysis, metric collection, alerting, and self-healing trigger. Use when setting up monitoring or investigating a production issue.
- License 许可
- Apache-2.0
- 所属仓库
- icdev-ai/icdev
- 最近更新
- 2026-11-09
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- ss14-eventbus
- description
- Architectural guide to EventBus in Space Station 14 - strict event taxonomy, subscription storage, dispatch logic and internal optimization mechanisms.
03 SKILL.md 正文
? EventBus architecture in SS14
EventBus is the central nervous system of the Space Station 14 (RobustToolbox) engine. It orchestrates communication between systems and entities, implementing a highly optimized dispatch mechanism without unnecessary allocations. ?
?️ Basic Architecture
EventBus is implemented through the IEventBus interface and combines two different event paradigms:
- Broadcast Events: Global events sent to all subscribers of a certain type. ?
- Directed Events: Events targeting a specific entity are sent only to components on that entity. ?
? Internal Storage
To achieve high performance, EventBus supports several specialized data structures:
-
Broadcast Subscriptions (
_eventData):- Dictionary
Type->EventData. - Stores a list of all global subscribers for each event type.
- Used for broadcast events and system notifications.
- Dictionary
-
Directed Subscriptions (
_eventSubsand_compEventSubs):- Array structure of arrays (jagged array), indexed by
CompIdx(Component Index). _eventSubs[CompIdx]: MapsEventType->Handler.- Allows you to search for component handlers for a specific event in O(1). ⚡
- Divided into general events and optimized Component Events (see below).
- Array structure of arrays (jagged array), indexed by
-
Entity Event Tables (
_entEventTables):- Dictionary stored for each active
EntityUid. - Displays
EventType->LinkedList<CompIdx>. - Keeps track of which components on a specific entity are listening to a specific event.
- This prevents iterating through all entity components to find listeners. ??
- Dictionary stored for each active
? Event Paradigms
1. Broadcast Events (RaiseEvent) ?
- Target: No specific entity. Global scope.
- Uses: Communication between systems, global game state changes (for example,
GameRunLevelChangedEvent), round notifications. - Dispatching:
- Looks up
EventDatafor the event type. - Iterates over all registered
IEntityEventSubscriber(mostly EntitySystems). - Supports
ByRefevents for performance with zero allocations.
- Looks up
2. Directed Events (RaiseLocalEvent) ?
- Target: Specific
EntityUid. - Usage: Interactions, damage, UI clicks, anything that happens to the entity.
- Dispatching:
- Finds
EventTablefor the target entity. - Finds a list of component indices (
CompIdx) subscribed to this event type. - Gets the actual component instances from
EntityManager. - Calls the cached handler delegate for each component.
- Finds
- Performance: Highly optimized. Uses
refstructures andUnsafe.Asto avoid boxingstructevents. ?
3. Component Events (RaiseComponentEvent) ?
- Target: A specific instance of
IComponenton an entity. - Application: Network processing, specialized component updates.
- Optimization:
- Bypasses the search in the
EventTableentity. - Directly calls a handler for a specific component instance.
- Used internally for
HandleComponentStateand network replication to minimize overhead.
- Bypasses the search in the
? Mechanics of Subscriptions
Registration ?
Subscriptions are usually registered during EntitySystem.Initialize():
- Directed:
SubscribeLocalEvent<TComp, TEvent>(Handler)-> RegistersHandlerin_eventSubsforTComp. - Broadcast:
SubscribeEvent<TEvent>(Handler)-> RegistersHandlerto_eventData.
###Ordering ?
Events/Subscriptions support explicit ordering using the before and after types.
- EventBus topologically sorts handlers based on these constraints.
- This ensures a deterministic order of execution (e.g. the armor system handles damage before the health system).
- ⚠️ Warning: Circular dependencies in order will throw an exception on initialization.
?️ Optimization Techniques
EventBus uses aggressive optimization to support thousands of events per tick:
- Ref Events (
ByRefEventAttribute): Events can be marked for passing by reference. This avoids copying large structures. ?➡️ - Unit Structs: Internally, the bus uses the
ref UnitandUnsafe.Aspointers to erase event argument types without boxing them intoobject. ?♂️ - Frozen Collections: After initialization, subscription dictionaries are "frozen" (
FrozenDictionary) to optimize read performance. ❄️ - Struct Events: Most events are structures (
struct) rather than classes (class) to eliminate pressure on the garbage collector (GC). ?️
⛔ Critical Limitations
- Lock Subscriptions: You cannot subscribe/unsubscribe while dispatching events (unless you use options with
Queue). The bus is blocked during iteration. ? - Overhead of Generics: The bus minimizes the use of generics in hot paths to avoid JIT overhead for each event type.
- Thread Safety: EventBus is not thread safe. All events must be raised on the main thread. ?
04 同仓库更多 Skills
icdev
Work inside an ICDEV project from any coding harness -- the icdev-unified MCP tools, the `icdev` CLI, kanban claim/release, worktree-first branching, and where ICDEV's pre-tool guard lives. Use when a repo has CLAUDE.md/AGENTS.md naming ICDEV, a kanban task id (e.g. omx-dx-02), or you need an ICDEV tool.
icdev-worktree
Create and manage isolated git worktrees for parallel ICDEV™ task execution. Use when invoking /icdev-worktree.
icdev-test
Run the full test suite (pytest unit + behave BDD) with coverage reporting and compliance tracking. Use when validating code quality and coverage before a release.
icdev-status
Display comprehensive project status including compliance, security, deployment, and agent health. Use when checking overall project health or preparing a status report.
icdev-simulate
Run Digital Program Twin simulations and generate COAs for requirements. Use when simulating program scenarios or generating courses of action.
icdev-secure
Run comprehensive security scanning (SAST, dependency audit, secret detection, container scan). Use when scanning code or containers for security vulnerabilities before deployment.