MuharremTozan/Agentic-Duel / .agent/skills/unity-composition-pattern
unity-composition-pattern
UnverifiedImplements "Composition over Inheritance" using ScriptableObject configs and C# Tuples. Replaces deep class hierarchies with modular, has-a relationships.
Unity Composition Pattern
A fundamental design skill to prevent "Inheritance Hell." This pattern replaces 10 specific classes (e.g., RedStone, GoldStone) with one generic class that composes behaviors from ScriptableObject assets.
Core Features
- Has-A Logic: Objects define their properties through members (Configs) rather than their base class type.
- SO-to-Runtime Bridge: Uses ScriptableObjects as static data templates that generate dynamic runtime instances.
- Tuple Deconstruction: Uses C# ValueTuples to return multi-part data from composite objects without extra boilerplate.
- Hierarchy Flattening: Drastically reduces the number of C# files needed by offloading variations to Project Assets.
Core Files (Max 3)
EntityConfigSO.cs.txt: Base class for creating interchangeable data packets.ModularEntity.cs.txt: The generic container that holds one or more configurations.CompositionExample.cs.txt: Demonstrates resource harvesting with Tuple destructuring.
Usage
1. Identify "Is-A" vs "Has-A"
- Bad:
ElectricCar : Car : Vehicle(Inheritance) - Good:
Vehiclehas anEngineConfig(Composition)
2. Multi-Value Returns (Tuples)
Instead of internal state-tracking:
public (int gold, int weight) Gather() => (10, 5);
// Client destructures instantly:
var (g, w) = node.Gather();
3. Strategy via SO
Attach different EntityConfigSO assets to the same ModularEntity to change its identity in the Inspector.
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: 196k | 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: 192k | 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: 192k | 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: 192k | Updated | Claude CodeCodex | Verified | Install |