MuharremTozan/Agentic-Duel / .agent/skills/unity-abstract-factory
unity-abstract-factory
VerifiedFactory pattern for creating families of related objects. Supports both ScriptableObject composition and simple prefab instantiation.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 741 B |
| assets/code/EquipmentFactory.cs.txt | markdown | 1.1 KB |
| assets/code/Factory.cs.txt | markdown | 1.0 KB |
| references/guide.md | markdown | 1.6 KB |
references/guide.md
View on GitHub# Abstract Factory Pattern Guide
This skill implements the Abstract Factory pattern to help you manage the complexity of creating objects, especially families of related objects (like a Knight's full equipment set: Sword + Shield + Armor).
## 1. The Core Idea: Decoupling Creation
Instead of `new Sword()` inside your `Knight` class, you ask a Factory: `factory.CreateWeapon()`. Use `ScriptableObject` factories to make this drag-and-drop in the Unity Inspector.
## 2. Choosing Your Path (Hybrid Design)
### A. The "Pro" Path (Abstract Factory with ScriptableObjects)
Use this when you have interchangeable "themes" or "loadouts".
**Example**: An RPG with `FireMage`, `IceMage`, `Necromancer`. Each needs a distinct Staff, Spell, and Robe.
1. **Define Interfaces**: `IWeapon`, `IShield`.
2. **Create Concrete Factories**: `FireWeaponFactory : AbstractFactory<IWeapon>`, `IceWeaponFactory : AbstractFactory<IWeapon>`.
3. **Use Composition**: Create an `EquipmentFactory` SO that references a `WeaponFactory` and a `ShieldFactory`.
4. **Drag-and-Drop**: Now you can create a `FireMageKit` asset and assign the fire factories. Your `PlayerSpawner` just needs a reference to `EquipmentFactory`.
### B. The "Light" Path (Simple Prefab Factory)
Use this for simple spawning (bullets, enemies, loot).
1. Use `SimplePrefabFactory<T>`.
2. Pass it an array of prefabs in the constructor.
3. Call `.Create()` to get an instance.
## 3. Benefits
- **Hot-Swapping**: Change an enemy's entire behavior/look by swapping one SO asset in the Inspector.
- **Open/Closed Principle**: Add new weapons (LaserGun) without changing the Player code. Just make a new Factory.
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: 198k | 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 |