MuharremTozan/Agentic-Duel / .agent/skills/unity-command-pattern
unity-command-pattern
VerifiedEncapsulate actions as objects for queuing, undo/redo, and async execution.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 584 B |
| assets/code/Command.cs.txt | markdown | 1.3 KB |
| references/guide.md | markdown | 1.4 KB |
references/guide.md
View on GitHub# Command Pattern Guide
The Command Pattern encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.
## 1. The Core Architecture
- **Command**: An object wrapping a method.
- **Invoker**: The object that calls `Execute()` (and manages queuing/history).
- **Receiver**: The object that the command acts upon (e.g., Player).
## 2. Choosing Your Path (Hybrid Design)
### A. The "Pro" Path (Async Combo System)
Use this for systems where order and timing matter (Combos, Spells, Turn-Based Actions).
1. **Interfaces**: Commands implement `ICommand` which returns a `Task`.
2. **Invoker**: Use `CommandInvoker` to `await` each command. This ensures an "Attack" finishes its animation before a "Jump" begins.
3. **Parameterization**: Pass the target/parameters in the constructor of the Command object.
### B. The "Light" Path (ScriptableObject Actions)
Use this for simple, data-driven interactions like UI buttons or context-menu actions.
1. **Template**: Create a `CommandSO` asset.
2. **Execution**: Pass the target `GameObject` as a parameter to the `Execute(target)` method.
3. **Usage**: Drag the asset into a UnityEvent field (like `Button.onClick`).
## 3. Advanced Usage: Undo/Redo
To support Undo, keep a `Stack<ICommand>` in your Invoker. Each command must implement an `Undo()` method that reverses the action performed in `Execute()`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |