@leejungkiin/awkit 1.7.1 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/bin/awk.js +576 -84
  2. package/core/CLAUDE.md +1 -1
  3. package/core/GEMINI.md +148 -167
  4. package/core/GEMINI.md.bak +149 -116
  5. package/core/skill-runtime-manifest.json +3 -0
  6. package/docs/Claude Fable 5.md +3826 -0
  7. package/docs/android_kotlin_system_instruction.md +210 -0
  8. package/docs/brainstorm_ponytail_integration.md +146 -0
  9. package/docs/brainstorm_smart_setup.md +113 -0
  10. package/docs/deep-research-report (1).md +293 -0
  11. package/docs/history/GEMINI.v1.md +135 -0
  12. package/docs/history/brainstorm_antigravity_unified_architecture.v1.md +105 -0
  13. package/docs/history/implementation_plan.v1.md +58 -0
  14. package/package.json +4 -1
  15. package/scripts/artifact-storage.js +130 -0
  16. package/scripts/automation-gate.js +35 -2
  17. package/scripts/claude-plan.js +76 -0
  18. package/scripts/dependency-manager.js +210 -0
  19. package/scripts/exec-rtk.js +11 -5
  20. package/scripts/i18n-helper.js +381 -0
  21. package/scripts/multi-model-pipeline.js +144 -0
  22. package/skill-packs/mobile-ios/pack.json +4 -2
  23. package/skill-packs/reverse-engineering/pack.json +1 -0
  24. package/skills/CATALOG.md +20 -0
  25. package/skills/GEMINI.md +9 -1
  26. package/skills/TRIGGER_INDEX.md +10 -0
  27. package/skills/ai-music/SKILL.md +275 -0
  28. package/skills/android-re-analyzer/SKILL.md +238 -0
  29. package/skills/android-re-analyzer/references/api-extraction-patterns.md +119 -0
  30. package/skills/android-re-analyzer/references/call-flow-analysis.md +176 -0
  31. package/skills/android-re-analyzer/references/fernflower-usage.md +115 -0
  32. package/skills/android-re-analyzer/references/jadx-usage.md +116 -0
  33. package/skills/android-re-analyzer/references/setup-guide.md +221 -0
  34. package/skills/android-re-analyzer/scripts/check-deps.sh +129 -0
  35. package/skills/android-re-analyzer/scripts/decompile.sh +375 -0
  36. package/skills/android-re-analyzer/scripts/find-api-calls.sh +118 -0
  37. package/skills/android-re-analyzer/scripts/install-dep.sh +448 -0
  38. package/skills/animal-island-ui-style/SKILL.md +1450 -0
  39. package/skills/app-store-review-agent/SKILL.md +164 -0
  40. package/skills/app-store-review-agent/references/guidelines/README.md +154 -0
  41. package/skills/app-store-review-agent/references/guidelines/by-app-type/ai_apps.md +37 -0
  42. package/skills/app-store-review-agent/references/guidelines/by-app-type/all_apps.md +50 -0
  43. package/skills/app-store-review-agent/references/guidelines/by-app-type/crypto_finance.md +31 -0
  44. package/skills/app-store-review-agent/references/guidelines/by-app-type/games.md +31 -0
  45. package/skills/app-store-review-agent/references/guidelines/by-app-type/health_fitness.md +31 -0
  46. package/skills/app-store-review-agent/references/guidelines/by-app-type/kids.md +27 -0
  47. package/skills/app-store-review-agent/references/guidelines/by-app-type/macos.md +38 -0
  48. package/skills/app-store-review-agent/references/guidelines/by-app-type/social_ugc.md +32 -0
  49. package/skills/app-store-review-agent/references/guidelines/by-app-type/subscription_iap.md +34 -0
  50. package/skills/app-store-review-agent/references/guidelines/by-app-type/vpn.md +18 -0
  51. package/skills/app-store-review-agent/references/rules/design/minimum_functionality.md +96 -0
  52. package/skills/app-store-review-agent/references/rules/design/sign_in_with_apple.md +54 -0
  53. package/skills/app-store-review-agent/references/rules/entitlements/unused_entitlements.md +83 -0
  54. package/skills/app-store-review-agent/references/rules/metadata/accurate_metadata.md +54 -0
  55. package/skills/app-store-review-agent/references/rules/metadata/apple_trademark.md +99 -0
  56. package/skills/app-store-review-agent/references/rules/metadata/china_storefront.md +72 -0
  57. package/skills/app-store-review-agent/references/rules/metadata/competitor_terms.md +56 -0
  58. package/skills/app-store-review-agent/references/rules/metadata/subscription_metadata.md +81 -0
  59. package/skills/app-store-review-agent/references/rules/privacy/privacy_manifest.md +84 -0
  60. package/skills/app-store-review-agent/references/rules/privacy/unnecessary_data.md +60 -0
  61. package/skills/app-store-review-agent/references/rules/subscription/misleading_pricing.md +63 -0
  62. package/skills/app-store-review-agent/references/rules/subscription/missing_tos_pp.md +54 -0
  63. package/skills/awf-ponytail/SKILL.md +91 -0
  64. package/skills/awf-ponytail-review/SKILL.md +67 -0
  65. package/skills/awf-session-restore/SKILL.md +3 -3
  66. package/skills/brainstorm-agent/SKILL.md +11 -2
  67. package/skills/brainstorm-agent/templates/brief-template.md +8 -0
  68. package/skills/claude-planner/SKILL.md +47 -0
  69. package/skills/code-review/SKILL.md +87 -0
  70. package/skills/expo-game-development/SKILL.md +163 -0
  71. package/skills/flutter/LICENSE.txt +202 -0
  72. package/skills/flutter/SKILL.md +127 -0
  73. package/skills/flutter-project-creater/LICENSE.txt +202 -0
  74. package/skills/flutter-project-creater/SKILL.md +106 -0
  75. package/skills/game-developer/SKILL.md +163 -0
  76. package/skills/game-developer/references/ecs-patterns.md +501 -0
  77. package/skills/game-developer/references/multiplayer-networking.md +475 -0
  78. package/skills/game-developer/references/performance-optimization.md +422 -0
  79. package/skills/game-developer/references/unity-patterns.md +271 -0
  80. package/skills/game-developer/references/unreal-cpp.md +352 -0
  81. package/skills/generate-gui-assets/SKILL.md +305 -0
  82. package/skills/generate-gui-assets/agents/openai.yaml +4 -0
  83. package/skills/generate-gui-assets/references/catalog-schema.md +58 -0
  84. package/skills/generate-gui-assets/references/extraction-techniques.md +21 -0
  85. package/skills/generate-gui-assets/references/prompt-patterns.md +58 -0
  86. package/skills/generate-gui-assets/scripts/__pycache__/clean_chroma_edges.cpython-311.pyc +0 -0
  87. package/skills/generate-gui-assets/scripts/build_gui_contact_sheet.py +51 -0
  88. package/skills/generate-gui-assets/scripts/clean_chroma_edges.py +262 -0
  89. package/skills/generate-gui-assets/scripts/copy_approved_icons.py +64 -0
  90. package/skills/generate-gui-assets/scripts/prepare_gui_asset_run.py +91 -0
  91. package/skills/generate-gui-assets/scripts/suggest_grid_options.py +63 -0
  92. package/skills/generate-gui-assets/scripts/validate_gui_catalog.py +50 -0
  93. package/skills/godot-game-development/SKILL.md +142 -0
  94. package/skills/hatch-pet/LICENSE.txt +201 -0
  95. package/skills/hatch-pet/SKILL.md +420 -0
  96. package/skills/hatch-pet/agents/openai.yaml +4 -0
  97. package/skills/hatch-pet/references/animation-rows.md +29 -0
  98. package/skills/hatch-pet/references/codex-pet-contract.md +35 -0
  99. package/skills/hatch-pet/references/qa-rubric.md +60 -0
  100. package/skills/hatch-pet/scripts/__pycache__/clean_chroma_edges.cpython-311.pyc +0 -0
  101. package/skills/hatch-pet/scripts/clean_chroma_edges.py +262 -0
  102. package/skills/hatch-pet/scripts/compose_atlas.py +150 -0
  103. package/skills/hatch-pet/scripts/derive_running_left_from_running_right.py +143 -0
  104. package/skills/hatch-pet/scripts/extract_strip_frames.py +323 -0
  105. package/skills/hatch-pet/scripts/finalize_pet_run.py +382 -0
  106. package/skills/hatch-pet/scripts/generate_pet_images.py +287 -0
  107. package/skills/hatch-pet/scripts/inspect_frames.py +246 -0
  108. package/skills/hatch-pet/scripts/make_contact_sheet.py +96 -0
  109. package/skills/hatch-pet/scripts/package_custom_pet.py +108 -0
  110. package/skills/hatch-pet/scripts/pet_job_status.py +117 -0
  111. package/skills/hatch-pet/scripts/prepare_pet_run.py +673 -0
  112. package/skills/hatch-pet/scripts/queue_pet_repairs.py +172 -0
  113. package/skills/hatch-pet/scripts/record_imagegen_result.py +250 -0
  114. package/skills/hatch-pet/scripts/render_animation_videos.py +134 -0
  115. package/skills/hatch-pet/scripts/render_animation_videos.sh +5 -0
  116. package/skills/hatch-pet/scripts/validate_atlas.py +139 -0
  117. package/skills/i18n-orchestrator/SKILL.md +37 -0
  118. package/skills/ios-simulator-skill/SKILL.md +390 -0
  119. package/skills/ios-simulator-skill/scripts/accessibility_audit.py +300 -0
  120. package/skills/ios-simulator-skill/scripts/app_launcher.py +326 -0
  121. package/skills/ios-simulator-skill/scripts/app_state_capture.py +400 -0
  122. package/skills/ios-simulator-skill/scripts/appearance.py +385 -0
  123. package/skills/ios-simulator-skill/scripts/build_and_test.py +348 -0
  124. package/skills/ios-simulator-skill/scripts/clipboard.py +103 -0
  125. package/skills/ios-simulator-skill/scripts/common/__init__.py +61 -0
  126. package/skills/ios-simulator-skill/scripts/common/cache_utils.py +289 -0
  127. package/skills/ios-simulator-skill/scripts/common/device_utils.py +462 -0
  128. package/skills/ios-simulator-skill/scripts/common/env_config.py +35 -0
  129. package/skills/ios-simulator-skill/scripts/common/hang_pipeline.py +862 -0
  130. package/skills/ios-simulator-skill/scripts/common/hang_sessions.py +490 -0
  131. package/skills/ios-simulator-skill/scripts/common/idb_utils.py +180 -0
  132. package/skills/ios-simulator-skill/scripts/common/screenshot_utils.py +338 -0
  133. package/skills/ios-simulator-skill/scripts/container.py +668 -0
  134. package/skills/ios-simulator-skill/scripts/gesture.py +394 -0
  135. package/skills/ios-simulator-skill/scripts/hang_watcher.py +1533 -0
  136. package/skills/ios-simulator-skill/scripts/keyboard.py +391 -0
  137. package/skills/ios-simulator-skill/scripts/localization_audit.py +483 -0
  138. package/skills/ios-simulator-skill/scripts/location.py +467 -0
  139. package/skills/ios-simulator-skill/scripts/log_monitor.py +493 -0
  140. package/skills/ios-simulator-skill/scripts/model_inspector.py +645 -0
  141. package/skills/ios-simulator-skill/scripts/navigator.py +461 -0
  142. package/skills/ios-simulator-skill/scripts/privacy_manager.py +310 -0
  143. package/skills/ios-simulator-skill/scripts/push_notification.py +240 -0
  144. package/skills/ios-simulator-skill/scripts/screen_mapper.py +296 -0
  145. package/skills/ios-simulator-skill/scripts/sim_health_check.sh +245 -0
  146. package/skills/ios-simulator-skill/scripts/sim_list.py +299 -0
  147. package/skills/ios-simulator-skill/scripts/simctl_boot.py +312 -0
  148. package/skills/ios-simulator-skill/scripts/simctl_create.py +316 -0
  149. package/skills/ios-simulator-skill/scripts/simctl_delete.py +357 -0
  150. package/skills/ios-simulator-skill/scripts/simctl_erase.py +351 -0
  151. package/skills/ios-simulator-skill/scripts/simctl_shutdown.py +290 -0
  152. package/skills/ios-simulator-skill/scripts/simulator_selector.py +375 -0
  153. package/skills/ios-simulator-skill/scripts/status_bar.py +250 -0
  154. package/skills/ios-simulator-skill/scripts/test_recorder.py +323 -0
  155. package/skills/ios-simulator-skill/scripts/visual_diff.py +235 -0
  156. package/skills/ios-simulator-skill/scripts/xcode/__init__.py +13 -0
  157. package/skills/ios-simulator-skill/scripts/xcode/builder.py +397 -0
  158. package/skills/ios-simulator-skill/scripts/xcode/cache.py +204 -0
  159. package/skills/ios-simulator-skill/scripts/xcode/config.py +178 -0
  160. package/skills/ios-simulator-skill/scripts/xcode/reporter.py +343 -0
  161. package/skills/ios-simulator-skill/scripts/xcode/xcresult.py +451 -0
  162. package/skills/ios-visual-qa-strategist/SKILL.md +111 -0
  163. package/skills/ios-visual-qa-strategist/agents/openai.yaml +4 -0
  164. package/skills/ios-visual-qa-strategist/references/ios-tool-selection.md +61 -0
  165. package/skills/ios-visual-qa-strategist/references/minimal-capture-policy.md +56 -0
  166. package/skills/ios-visual-qa-strategist/references/visual-reasoning-heuristics.md +53 -0
  167. package/skills/orchestrator/SKILL.md +0 -20
  168. package/skills/persistent-storage/SKILL.md +55 -0
  169. package/skills/short-maker/SKILL.md +23 -0
  170. package/skills/short-maker/scripts/effects.js +56 -0
  171. package/skills/short-maker/scripts/shortmaker-bridge.js +332 -0
  172. package/skills/short-maker/scripts/videomix.js +601 -0
  173. package/skills/short-maker/templates/hyperframes/cinematic-character.template.html +172 -0
  174. package/skills/short-maker/templates/hyperframes/index.template.html +194 -0
  175. package/skills/smali-to-kotlin/SKILL.md +128 -0
  176. package/skills/smali-to-kotlin/examples/getting-started/tech-stack.md +58 -0
  177. package/skills/smali-to-kotlin/examples/pipeline/data-ui-parity.md +118 -0
  178. package/skills/smali-to-kotlin/examples/pipeline/scanner-and-bootstrap.md +106 -0
  179. package/skills/smali-to-kotlin/library-patterns.md +189 -0
  180. package/skills/smali-to-kotlin/phase-0-discovery.md +128 -0
  181. package/skills/smali-to-kotlin/phase-1-architecture.md +166 -0
  182. package/skills/smali-to-kotlin/phase-2-blueprint-ui.md +347 -0
  183. package/skills/smali-to-kotlin/phase-2-blueprint.md +228 -0
  184. package/skills/smali-to-kotlin/phase-3-build.md +248 -0
  185. package/skills/smali-to-kotlin/phase-3-logic-build.md +268 -0
  186. package/skills/smali-to-kotlin/smali-reading-guide.md +310 -0
  187. package/skills/smali-to-kotlin/templates/app-map.md +101 -0
  188. package/skills/smali-to-kotlin/templates/architecture.md +142 -0
  189. package/skills/smali-to-kotlin/templates/blueprint.md +145 -0
  190. package/skills/spec-gate/SKILL.md +6 -2
  191. package/skills/symphony-enforcer/SKILL.md +8 -0
  192. package/skills/symphony-enforcer/examples/mindful-stop.md +2 -0
  193. package/skills/symphony-enforcer/examples/three-phase.md +16 -0
  194. package/skills/symphony-enforcer/examples/trigger-points.md +7 -1
  195. package/skills/unity-game-development/SKILL.md +231 -0
  196. package/skills/video-edit/SKILL.md +36 -0
  197. package/skills/video-edit/scripts/video_edit.py +324 -0
  198. package/templates/project-identity/android.json +2 -2
  199. package/templates/project-identity/backend-nestjs.json +2 -2
  200. package/templates/project-identity/expo.json +2 -2
  201. package/templates/project-identity/ios.json +2 -2
  202. package/templates/project-identity/web-nextjs.json +2 -2
  203. package/templates/setup-mapping.json +48 -0
  204. package/templates/specs/design-template.md +161 -71
  205. package/templates/specs/requirements-template.md +65 -133
  206. package/templates/specs/task-spec-template.xml +3 -0
  207. package/workflows/_uncategorized/critic.md +40 -0
  208. package/workflows/_uncategorized/git-rebase-flow.md +81 -0
  209. package/workflows/_uncategorized/image-gen.md +118 -0
  210. package/workflows/_uncategorized/multi-model-pipeline.md +60 -0
  211. package/workflows/_uncategorized/pixel-gen.md +86 -0
  212. package/workflows/_uncategorized/pixel-setup.md +90 -0
  213. package/workflows/_uncategorized/ponytail-review.md +59 -0
  214. package/workflows/_uncategorized/reverse-android-build.md +222 -0
  215. package/workflows/_uncategorized/reverse-android-design.md +139 -0
  216. package/workflows/_uncategorized/reverse-android-discover.md +150 -0
  217. package/workflows/_uncategorized/reverse-android-scan.md +158 -0
  218. package/workflows/_uncategorized/reverse-android.md +143 -0
  219. package/workflows/_uncategorized/reverse-ios-build.md +240 -0
  220. package/workflows/_uncategorized/reverse-ios-design.md +112 -0
  221. package/workflows/_uncategorized/reverse-ios-discover.md +120 -0
  222. package/workflows/_uncategorized/reverse-ios-scan.md +155 -0
  223. package/workflows/_uncategorized/reverse-ios.md +152 -0
  224. package/workflows/_uncategorized/safety-router.md +34 -0
  225. package/workflows/_uncategorized/teach.md +89 -0
  226. package/workflows/_uncategorized/verify-ui.md +53 -0
  227. package/workflows/_uncategorized/visualize-screenshots.md +34 -0
  228. package/workflows/ads/ads-analyst.md +201 -0
  229. package/workflows/ads/ads-audit.md +106 -0
  230. package/workflows/ads/ads-optimize.md +97 -0
  231. package/workflows/ads/ads-targeting.md +241 -0
  232. package/workflows/ads/adsExpert.md +160 -0
  233. package/workflows/ads/smali-ads-config.md +400 -0
  234. package/workflows/ads/smali-ads-flow.md +331 -0
  235. package/workflows/ads/smali-ads-interstitial.md +377 -0
  236. package/workflows/ads/smali-ads-native.md +382 -0
  237. package/workflows/context/teach.md +89 -0
  238. package/workflows/gitnexus.md +8 -8
  239. package/workflows/lifecycle/brainstorm.md +43 -0
  240. package/workflows/lifecycle/code.md +5 -0
  241. package/workflows/lifecycle/init.md +23 -5
  242. package/workflows/lifecycle/multi-model-pipeline.md +60 -0
  243. package/workflows/quality/ponytail-review.md +59 -0
  244. package/workflows/roles/critic.md +40 -0
  245. package/workflows/roles/safety-router.md +34 -0
@@ -0,0 +1,501 @@
1
+ # ECS Architecture and Game Patterns
2
+
3
+ ## Entity Component System (ECS)
4
+
5
+ ```csharp
6
+ // Component = pure data (no logic)
7
+ public struct PositionComponent
8
+ {
9
+ public float X;
10
+ public float Y;
11
+ public float Z;
12
+ }
13
+
14
+ public struct VelocityComponent
15
+ {
16
+ public float X;
17
+ public float Y;
18
+ public float Z;
19
+ }
20
+
21
+ public struct HealthComponent
22
+ {
23
+ public int Current;
24
+ public int Max;
25
+ }
26
+
27
+ public struct PlayerTag { } // Marker component
28
+
29
+ // Entity = just an ID
30
+ public struct Entity
31
+ {
32
+ public int Id;
33
+ }
34
+
35
+ // System = logic operating on components
36
+ public class MovementSystem
37
+ {
38
+ public void Update(float deltaTime,
39
+ Span<PositionComponent> positions,
40
+ Span<VelocityComponent> velocities)
41
+ {
42
+ for (int i = 0; i < positions.Length; i++)
43
+ {
44
+ positions[i].X += velocities[i].X * deltaTime;
45
+ positions[i].Y += velocities[i].Y * deltaTime;
46
+ positions[i].Z += velocities[i].Z * deltaTime;
47
+ }
48
+ }
49
+ }
50
+
51
+ // Simple ECS World
52
+ public class World
53
+ {
54
+ private int nextEntityId = 0;
55
+ private Dictionary<int, PositionComponent> positions = new();
56
+ private Dictionary<int, VelocityComponent> velocities = new();
57
+ private Dictionary<int, HealthComponent> healths = new();
58
+
59
+ public Entity CreateEntity()
60
+ {
61
+ return new Entity { Id = nextEntityId++ };
62
+ }
63
+
64
+ public void AddComponent<T>(Entity entity, T component)
65
+ {
66
+ // Store component by entity ID
67
+ }
68
+
69
+ public T GetComponent<T>(Entity entity)
70
+ {
71
+ // Retrieve component for entity
72
+ return default;
73
+ }
74
+ }
75
+ ```
76
+
77
+ ## Object Pool Pattern
78
+
79
+ ```csharp
80
+ public class ObjectPool<T> where T : class, new()
81
+ {
82
+ private readonly Stack<T> pool = new();
83
+ private readonly Func<T> createFunc;
84
+ private readonly Action<T> resetAction;
85
+ private readonly int maxSize;
86
+
87
+ public ObjectPool(Func<T> createFunc, Action<T> resetAction, int initialSize = 10, int maxSize = 100)
88
+ {
89
+ this.createFunc = createFunc;
90
+ this.resetAction = resetAction;
91
+ this.maxSize = maxSize;
92
+
93
+ // Pre-populate pool
94
+ for (int i = 0; i < initialSize; i++)
95
+ {
96
+ pool.Push(createFunc());
97
+ }
98
+ }
99
+
100
+ public T Get()
101
+ {
102
+ if (pool.Count > 0)
103
+ return pool.Pop();
104
+
105
+ return createFunc();
106
+ }
107
+
108
+ public void Return(T obj)
109
+ {
110
+ if (pool.Count < maxSize)
111
+ {
112
+ resetAction?.Invoke(obj);
113
+ pool.Push(obj);
114
+ }
115
+ }
116
+ }
117
+
118
+ // Usage example
119
+ public class BulletManager
120
+ {
121
+ private ObjectPool<Bullet> bulletPool;
122
+
123
+ public void Initialize()
124
+ {
125
+ bulletPool = new ObjectPool<Bullet>(
126
+ createFunc: () => new Bullet(),
127
+ resetAction: (bullet) => bullet.Reset(),
128
+ initialSize: 50,
129
+ maxSize: 200
130
+ );
131
+ }
132
+
133
+ public Bullet SpawnBullet()
134
+ {
135
+ Bullet bullet = bulletPool.Get();
136
+ bullet.Activate();
137
+ return bullet;
138
+ }
139
+
140
+ public void ReturnBullet(Bullet bullet)
141
+ {
142
+ bullet.Deactivate();
143
+ bulletPool.Return(bullet);
144
+ }
145
+ }
146
+ ```
147
+
148
+ ## State Machine Pattern
149
+
150
+ ```csharp
151
+ public interface IState
152
+ {
153
+ void Enter();
154
+ void Update(float deltaTime);
155
+ void Exit();
156
+ }
157
+
158
+ public class StateMachine
159
+ {
160
+ private IState currentState;
161
+
162
+ public void ChangeState(IState newState)
163
+ {
164
+ currentState?.Exit();
165
+ currentState = newState;
166
+ currentState?.Enter();
167
+ }
168
+
169
+ public void Update(float deltaTime)
170
+ {
171
+ currentState?.Update(deltaTime);
172
+ }
173
+ }
174
+
175
+ // Example: Enemy AI States
176
+ public class IdleState : IState
177
+ {
178
+ private readonly EnemyController enemy;
179
+
180
+ public IdleState(EnemyController enemy) => this.enemy = enemy;
181
+
182
+ public void Enter()
183
+ {
184
+ enemy.PlayAnimation("Idle");
185
+ }
186
+
187
+ public void Update(float deltaTime)
188
+ {
189
+ if (enemy.PlayerInRange())
190
+ enemy.StateMachine.ChangeState(new ChaseState(enemy));
191
+ }
192
+
193
+ public void Exit() { }
194
+ }
195
+
196
+ public class ChaseState : IState
197
+ {
198
+ private readonly EnemyController enemy;
199
+
200
+ public ChaseState(EnemyController enemy) => this.enemy = enemy;
201
+
202
+ public void Enter()
203
+ {
204
+ enemy.PlayAnimation("Run");
205
+ }
206
+
207
+ public void Update(float deltaTime)
208
+ {
209
+ if (!enemy.PlayerInRange())
210
+ enemy.StateMachine.ChangeState(new IdleState(enemy));
211
+ else if (enemy.InAttackRange())
212
+ enemy.StateMachine.ChangeState(new AttackState(enemy));
213
+ else
214
+ enemy.MoveTowardsPlayer(deltaTime);
215
+ }
216
+
217
+ public void Exit() { }
218
+ }
219
+ ```
220
+
221
+ ## Command Pattern (Input Handling)
222
+
223
+ ```csharp
224
+ public interface ICommand
225
+ {
226
+ void Execute();
227
+ void Undo();
228
+ }
229
+
230
+ public class MoveCommand : ICommand
231
+ {
232
+ private readonly Transform transform;
233
+ private readonly Vector3 movement;
234
+ private Vector3 previousPosition;
235
+
236
+ public MoveCommand(Transform transform, Vector3 movement)
237
+ {
238
+ this.transform = transform;
239
+ this.movement = movement;
240
+ }
241
+
242
+ public void Execute()
243
+ {
244
+ previousPosition = transform.position;
245
+ transform.position += movement;
246
+ }
247
+
248
+ public void Undo()
249
+ {
250
+ transform.position = previousPosition;
251
+ }
252
+ }
253
+
254
+ public class InputHandler
255
+ {
256
+ private Stack<ICommand> commandHistory = new();
257
+
258
+ public void ExecuteCommand(ICommand command)
259
+ {
260
+ command.Execute();
261
+ commandHistory.Push(command);
262
+ }
263
+
264
+ public void UndoLastCommand()
265
+ {
266
+ if (commandHistory.Count > 0)
267
+ {
268
+ ICommand command = commandHistory.Pop();
269
+ command.Undo();
270
+ }
271
+ }
272
+ }
273
+ ```
274
+
275
+ ## Observer Pattern (Event System)
276
+
277
+ ```csharp
278
+ public class GameEvent<T>
279
+ {
280
+ private event Action<T> listeners;
281
+
282
+ public void Subscribe(Action<T> listener)
283
+ {
284
+ listeners += listener;
285
+ }
286
+
287
+ public void Unsubscribe(Action<T> listener)
288
+ {
289
+ listeners -= listener;
290
+ }
291
+
292
+ public void Trigger(T data)
293
+ {
294
+ listeners?.Invoke(data);
295
+ }
296
+ }
297
+
298
+ // Event hub
299
+ public static class GameEvents
300
+ {
301
+ public static readonly GameEvent<int> OnScoreChanged = new();
302
+ public static readonly GameEvent<float> OnHealthChanged = new();
303
+ public static readonly GameEvent<string> OnGameOver = new();
304
+ }
305
+
306
+ // Subscriber
307
+ public class UIController
308
+ {
309
+ private void OnEnable()
310
+ {
311
+ GameEvents.OnScoreChanged.Subscribe(UpdateScoreDisplay);
312
+ GameEvents.OnHealthChanged.Subscribe(UpdateHealthBar);
313
+ }
314
+
315
+ private void OnDisable()
316
+ {
317
+ GameEvents.OnScoreChanged.Unsubscribe(UpdateScoreDisplay);
318
+ GameEvents.OnHealthChanged.Unsubscribe(UpdateHealthBar);
319
+ }
320
+
321
+ private void UpdateScoreDisplay(int score)
322
+ {
323
+ // Update UI
324
+ }
325
+
326
+ private void UpdateHealthBar(float health)
327
+ {
328
+ // Update UI
329
+ }
330
+ }
331
+
332
+ // Publisher
333
+ public class Player
334
+ {
335
+ public void TakeDamage(float damage)
336
+ {
337
+ health -= damage;
338
+ GameEvents.OnHealthChanged.Trigger(health);
339
+ }
340
+ }
341
+ ```
342
+
343
+ ## Service Locator Pattern
344
+
345
+ ```csharp
346
+ public static class ServiceLocator
347
+ {
348
+ private static Dictionary<Type, object> services = new();
349
+
350
+ public static void Register<T>(T service)
351
+ {
352
+ services[typeof(T)] = service;
353
+ }
354
+
355
+ public static T Get<T>()
356
+ {
357
+ if (services.TryGetValue(typeof(T), out object service))
358
+ return (T)service;
359
+
360
+ throw new Exception($"Service {typeof(T)} not found");
361
+ }
362
+
363
+ public static bool TryGet<T>(out T service)
364
+ {
365
+ if (services.TryGetValue(typeof(T), out object obj))
366
+ {
367
+ service = (T)obj;
368
+ return true;
369
+ }
370
+
371
+ service = default;
372
+ return false;
373
+ }
374
+
375
+ public static void Clear()
376
+ {
377
+ services.Clear();
378
+ }
379
+ }
380
+
381
+ // Usage
382
+ public class GameInitializer
383
+ {
384
+ public void Initialize()
385
+ {
386
+ ServiceLocator.Register<IAudioManager>(new AudioManager());
387
+ ServiceLocator.Register<ISaveSystem>(new SaveSystem());
388
+ ServiceLocator.Register<IInputManager>(new InputManager());
389
+ }
390
+ }
391
+
392
+ public class Player
393
+ {
394
+ private IAudioManager audioManager;
395
+
396
+ public void Start()
397
+ {
398
+ audioManager = ServiceLocator.Get<IAudioManager>();
399
+ }
400
+
401
+ public void PlaySound(string soundName)
402
+ {
403
+ audioManager.PlaySound(soundName);
404
+ }
405
+ }
406
+ ```
407
+
408
+ ## Spatial Partitioning (Grid)
409
+
410
+ ```csharp
411
+ public class SpatialGrid<T>
412
+ {
413
+ private readonly Dictionary<(int, int), List<T>> grid = new();
414
+ private readonly float cellSize;
415
+
416
+ public SpatialGrid(float cellSize)
417
+ {
418
+ this.cellSize = cellSize;
419
+ }
420
+
421
+ private (int, int) GetCell(Vector2 position)
422
+ {
423
+ int x = Mathf.FloorToInt(position.x / cellSize);
424
+ int y = Mathf.FloorToInt(position.y / cellSize);
425
+ return (x, y);
426
+ }
427
+
428
+ public void Insert(Vector2 position, T item)
429
+ {
430
+ var cell = GetCell(position);
431
+ if (!grid.ContainsKey(cell))
432
+ grid[cell] = new List<T>();
433
+
434
+ grid[cell].Add(item);
435
+ }
436
+
437
+ public List<T> Query(Vector2 position, float radius)
438
+ {
439
+ List<T> results = new();
440
+ int cellRadius = Mathf.CeilToInt(radius / cellSize);
441
+
442
+ var centerCell = GetCell(position);
443
+
444
+ for (int x = -cellRadius; x <= cellRadius; x++)
445
+ {
446
+ for (int y = -cellRadius; y <= cellRadius; y++)
447
+ {
448
+ var cell = (centerCell.Item1 + x, centerCell.Item2 + y);
449
+ if (grid.TryGetValue(cell, out List<T> items))
450
+ results.AddRange(items);
451
+ }
452
+ }
453
+
454
+ return results;
455
+ }
456
+
457
+ public void Clear()
458
+ {
459
+ grid.Clear();
460
+ }
461
+ }
462
+ ```
463
+
464
+ ## Double Buffer Pattern (for Rendering/Physics)
465
+
466
+ ```csharp
467
+ public class DoubleBuffer<T>
468
+ {
469
+ private T[] buffers = new T[2];
470
+ private int currentIndex = 0;
471
+
472
+ public DoubleBuffer(T buffer1, T buffer2)
473
+ {
474
+ buffers[0] = buffer1;
475
+ buffers[1] = buffer2;
476
+ }
477
+
478
+ public T Current => buffers[currentIndex];
479
+ public T Next => buffers[1 - currentIndex];
480
+
481
+ public void Swap()
482
+ {
483
+ currentIndex = 1 - currentIndex;
484
+ }
485
+ }
486
+
487
+ // Usage for physics
488
+ public class PhysicsSimulation
489
+ {
490
+ private DoubleBuffer<PhysicsState> stateBuffer;
491
+
492
+ public void Update(float deltaTime)
493
+ {
494
+ // Read from current, write to next
495
+ ComputeNextState(stateBuffer.Current, stateBuffer.Next, deltaTime);
496
+
497
+ // Swap buffers
498
+ stateBuffer.Swap();
499
+ }
500
+ }
501
+ ```