Skip to content

MuharremTozan/Agentic-Duel / .agent/skills/unity-event-bus

unity-event-bus

Verified

Advanced code-driven event bus with reflection-based bootstrapping. Provides zero-setup global messaging.

assets/code/EventBusExample.cs.txt

View on GitHub
using UnityEngine;

namespace Standard.Events.Bus.Examples {
    /// <summary>
    /// Example of a data-driven event.
    /// Structs are preferred for zero garbage collection.
    /// </summary>
    public struct PlayerLevelUpEvent : IEvent {
        public int NewLevel;
    }

    /// <summary>
    /// Example of a simple trigger event without data.
    /// </summary>
    public struct GameSavedEvent : IEvent { }

    public class EventBusUsageExample : MonoBehaviour {
        // Step 1: Define the binding
        private EventBinding<PlayerLevelUpEvent> _levelUpBinding;

        private void OnEnable() {
            // Step 2: Initialize and Register
            _levelUpBinding = new EventBinding<PlayerLevelUpEvent>(OnPlayerLevelUp);
            EventBus<PlayerLevelUpEvent>.Register(_levelUpBinding);
        }

        private void OnDisable() {
            // Step 3: Deregister
            EventBus<PlayerLevelUpEvent>.Deregister(_levelUpBinding);
        }

        private void OnPlayerLevelUp(PlayerLevelUpEvent @event) {
            Debug.Log($"[Example] Status: Event Received | Player leveled up to {@event.NewLevel}");
        }

        // Raise the event from anywhere
        public void LevelUpPlayer(int level) {
            EventBus<PlayerLevelUpEvent>.Raise(new PlayerLevelUpEvent { NewLevel = level });
        }
    }
}
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall