@musashishao/agent-kit 1.9.0 → 1.9.1

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 (125) hide show
  1. package/.agent/agents/ai-asset-factory.md +700 -0
  2. package/.agent/agents/ai-audio-factory.md +503 -0
  3. package/.agent/agents/game-developer.md +4 -4
  4. package/.agent/agents/orchestrator.md +113 -3
  5. package/.agent/agents/project-planner.md +67 -0
  6. package/.agent/agents/unity-mobile-master.md +949 -0
  7. package/.agent/mcp/config/registry.json +65 -51
  8. package/.agent/mcp/servers/notebooklm/README.md +114 -0
  9. package/.agent/mcp/servers/notebooklm/package.json +35 -0
  10. package/.agent/mcp/servers/notebooklm/src/auth/chrome.ts +225 -0
  11. package/.agent/mcp/servers/notebooklm/src/auth/index.ts +1 -0
  12. package/.agent/mcp/servers/notebooklm/src/index.ts +516 -0
  13. package/.agent/mcp/servers/notebooklm/src/services/index.ts +3 -0
  14. package/.agent/mcp/servers/notebooklm/src/services/library.ts +217 -0
  15. package/.agent/mcp/servers/notebooklm/src/services/notebooklm.ts +380 -0
  16. package/.agent/mcp/servers/notebooklm/tsconfig.json +15 -0
  17. package/.agent/mcp-gateway/README.md +169 -20
  18. package/.agent/mcp-gateway/package.json +22 -7
  19. package/.agent/mcp-gateway/src/auth/index.ts +55 -0
  20. package/.agent/mcp-gateway/src/auth/middleware.ts +242 -0
  21. package/.agent/mcp-gateway/src/auth/oauth.ts +462 -0
  22. package/.agent/mcp-gateway/src/auth/scopes.ts +227 -0
  23. package/.agent/mcp-gateway/src/index.ts +252 -105
  24. package/.agent/mcp-gateway/src/observability/index.ts +5 -0
  25. package/.agent/mcp-gateway/src/observability/otel.ts +405 -0
  26. package/.agent/mcp-gateway/src/transports/index.ts +5 -0
  27. package/.agent/mcp-gateway/src/transports/streamableHttp.ts +235 -0
  28. package/.agent/rules/CODEX.md +89 -0
  29. package/.agent/rules/CODE_RULES.md +73 -0
  30. package/.agent/rules/GEMINI.md +25 -0
  31. package/.agent/rules/MEMORY_STATE.md +110 -0
  32. package/.agent/rules/REFERENCE.md +33 -141
  33. package/.agent/rules/REF_SKILLS.md +116 -0
  34. package/.agent/rules/REF_WORKFLOWS.md +81 -0
  35. package/.agent/scripts/ak_cli.py +106 -5
  36. package/.agent/scripts/memory_manager.py +48 -9
  37. package/.agent/skills/anti-hallucination/SKILL.md +295 -0
  38. package/.agent/skills/anti-hallucination/scripts/check_hallucination.py +299 -0
  39. package/.agent/skills/bifurcation-analysis/SKILL.md +56 -0
  40. package/.agent/skills/brainstorming/SKILL.md +80 -6
  41. package/.agent/skills/decision-memory/SKILL.md +317 -0
  42. package/.agent/skills/emergence-detector/SKILL.md +230 -0
  43. package/.agent/skills/emergence-detector/scripts/check_emergence.py +265 -0
  44. package/.agent/skills/explained-qa/SKILL.md +142 -0
  45. package/.agent/skills/explained-qa/game-terminology.md +214 -0
  46. package/.agent/skills/game-development/ai-dialogue-engine/SKILL.md +442 -0
  47. package/.agent/skills/game-development/ai-graphics-generator/SKILL.md +463 -0
  48. package/.agent/skills/game-development/ai-playtest-framework/SKILL.md +570 -0
  49. package/.agent/skills/game-development/camera-systems/SKILL.md +607 -0
  50. package/.agent/skills/game-development/card-battle-engine/SKILL.md +618 -0
  51. package/.agent/skills/game-development/character-controller-3d/SKILL.md +908 -0
  52. package/.agent/skills/game-development/cloud-save-sync/SKILL.md +527 -0
  53. package/.agent/skills/game-development/combat-system/SKILL.md +748 -0
  54. package/.agent/skills/game-development/compliance-rating/SKILL.md +277 -0
  55. package/.agent/skills/game-development/crossplatform-build/SKILL.md +386 -0
  56. package/.agent/skills/game-development/cultivation-progression/SKILL.md +520 -0
  57. package/.agent/skills/game-development/data-driven-balance/SKILL.md +535 -0
  58. package/.agent/skills/game-development/game-analytics-integrator/SKILL.md +410 -0
  59. package/.agent/skills/game-development/game-audio-advanced/SKILL.md +646 -0
  60. package/.agent/skills/game-development/game-economy-designer/SKILL.md +375 -0
  61. package/.agent/skills/game-development/game-marketing/SKILL.md +85 -0
  62. package/.agent/skills/game-development/game-state-manager/SKILL.md +883 -0
  63. package/.agent/skills/game-development/hybrid-game-spec/SKILL.md +220 -0
  64. package/.agent/skills/game-development/inventory-quest/SKILL.md +747 -0
  65. package/.agent/skills/game-development/liveops/SKILL.md +308 -0
  66. package/.agent/skills/game-development/localization/SKILL.md +286 -0
  67. package/.agent/skills/game-development/mobile-input-patterns/SKILL.md +343 -0
  68. package/.agent/skills/game-development/monetization-strategy/SKILL.md +94 -0
  69. package/.agent/skills/game-development/multiplayer-master/SKILL.md +727 -0
  70. package/.agent/skills/game-development/narrative-branching/SKILL.md +593 -0
  71. package/.agent/skills/game-development/procedural-level-ai/SKILL.md +367 -0
  72. package/.agent/skills/game-development/prototyping-rapid/SKILL.md +205 -0
  73. package/.agent/skills/game-development/spec-ecosystem/SKILL.md +155 -0
  74. package/.agent/skills/game-development/spec-ecosystem/decision-log-format.md +129 -0
  75. package/.agent/skills/game-development/spec-ecosystem/templates/PLAN-template.md +178 -0
  76. package/.agent/skills/game-development/spec-ecosystem/templates/SPEC-template.md +110 -0
  77. package/.agent/skills/game-development/spec-ecosystem/templates/TASKS-template.md +156 -0
  78. package/.agent/skills/game-development/survival-systems/SKILL.md +493 -0
  79. package/.agent/skills/game-development/testing-qa/SKILL.md +270 -0
  80. package/.agent/skills/game-development/unity-mobile-optimization/SKILL.md +271 -0
  81. package/.agent/skills/intent-capture/SKILL.md +65 -0
  82. package/.agent/skills/mcp-composition/SKILL.md +362 -0
  83. package/.agent/skills/mcp-observability/SKILL.md +323 -0
  84. package/.agent/skills/mcp-security/SKILL.md +314 -0
  85. package/.agent/skills/trust-spectrum/SKILL.md +291 -0
  86. package/.agent/skills/vibe-coding-guard/SKILL.md +328 -0
  87. package/.agent/templates/AGENTS.game.md +63 -0
  88. package/.agent/templates/docs/WORKFLOW_GUIDE.en.md +100 -0
  89. package/.agent/templates/docs/WORKFLOW_GUIDE.vi.md +100 -0
  90. package/.agent/workflows/ai-agent.md +2 -0
  91. package/.agent/workflows/autofix.md +1 -0
  92. package/.agent/workflows/brainstorm.md +1 -0
  93. package/.agent/workflows/context.md +1 -0
  94. package/.agent/workflows/create.md +39 -8
  95. package/.agent/workflows/dashboard.md +1 -0
  96. package/.agent/workflows/debug.md +14 -0
  97. package/.agent/workflows/deploy.md +14 -0
  98. package/.agent/workflows/enhance.md +44 -0
  99. package/.agent/workflows/gamekit-init.md +177 -0
  100. package/.agent/workflows/gamekit-launch.md +338 -0
  101. package/.agent/workflows/gamekit-plan.md +204 -0
  102. package/.agent/workflows/gamekit-qa.md +153 -0
  103. package/.agent/workflows/gamekit-spec.md +243 -0
  104. package/.agent/workflows/gamekit-tasks.md +208 -0
  105. package/.agent/workflows/marketing.md +2 -0
  106. package/.agent/workflows/next.md +1 -0
  107. package/.agent/workflows/orchestrate.md +12 -0
  108. package/.agent/workflows/pentest.md +2 -0
  109. package/.agent/workflows/plan.md +42 -0
  110. package/.agent/workflows/preview.md +1 -0
  111. package/.agent/workflows/quality.md +1 -0
  112. package/.agent/workflows/saas.md +2 -0
  113. package/.agent/workflows/spec.md +42 -0
  114. package/.agent/workflows/status.md +1 -0
  115. package/.agent/workflows/test.md +14 -0
  116. package/.agent/workflows/ui-ux-pro-max.md +1 -0
  117. package/bin/cli.js +411 -111
  118. package/package.json +1 -2
  119. package/.agent/agents/game-asset-curator.md +0 -317
  120. package/.agent/agents/game-narrative-designer.md +0 -310
  121. package/.agent/agents/game-qa-agent.md +0 -441
  122. package/.agent/workflows/game-prototype.md +0 -154
  123. package/docs/AI_DATA_INFRASTRUCTURE.md +0 -288
  124. package/docs/CHANGELOG_AI_INFRA.md +0 -141
  125. package/docs/MIGRATION_GUIDE_V1.9.md +0 -55
@@ -0,0 +1,156 @@
1
+ # TASKS Template for Game Projects
2
+
3
+ > Executable task list generated from PLAN. Track progress with checkboxes.
4
+
5
+ ---
6
+
7
+ ## 📋 Project Info
8
+
9
+ **Game:** [Game Name]
10
+ **Based on:** `PLAN-{game-slug}.md`
11
+ **Started:** [Date]
12
+ **Target Completion:** [Date]
13
+
14
+ ---
15
+
16
+ ## 📊 Progress Overview
17
+
18
+ | Phase | Status | Progress |
19
+ |-------|--------|----------|
20
+ | Phase 1: Core Systems | 🔄 | 0/X tasks |
21
+ | Phase 2: Gameplay | ⏳ | 0/X tasks |
22
+ | Phase 3: UI & Polish | ⏳ | 0/X tasks |
23
+ | Phase 4: Audio & Effects | ⏳ | 0/X tasks |
24
+ | Phase X: Verification | ⏳ | 0/X checks |
25
+
26
+ **Legend:** ✅ Done | 🔄 In Progress | ⏳ Waiting | ❌ Blocked
27
+
28
+ ---
29
+
30
+ ## Phase 1: Core Systems
31
+
32
+ ### 1.1 [Task Name]
33
+ - [ ] **Task:** [Description]
34
+ - **Agent:** `[agent-name]`
35
+ - **Input:** [What's needed]
36
+ - **Output:** [What's produced]
37
+ - **Verify:** [How to check done]
38
+ - **Notes:** [Any additional context]
39
+
40
+ ### 1.2 [Task Name]
41
+ - [ ] **Task:** [Description]
42
+ - **Agent:** `[agent-name]`
43
+ - **Depends on:** 1.1
44
+ - **Input:** [What's needed]
45
+ - **Output:** [What's produced]
46
+ - **Verify:** [How to check done]
47
+
48
+ ---
49
+
50
+ ## Phase 2: Gameplay
51
+
52
+ ### 2.1 [Task Name]
53
+ - [ ] **Task:** [Description]
54
+ - **Agent:** `[agent-name]`
55
+ - **Depends on:** Phase 1
56
+ - **Input:** [What's needed]
57
+ - **Output:** [What's produced]
58
+ - **Verify:** [How to check done]
59
+
60
+ ### 2.2 [Task Name]
61
+ - [ ] **Task:** [Description]
62
+ - **Agent:** `[agent-name]`
63
+ - **Depends on:** 2.1
64
+ - **Input:** [What's needed]
65
+ - **Output:** [What's produced]
66
+ - **Verify:** [How to check done]
67
+
68
+ ---
69
+
70
+ ## Phase 3: UI & Polish
71
+
72
+ ### 3.1 [Task Name]
73
+ - [ ] **Task:** [Description]
74
+ - **Agent:** `[agent-name]`
75
+ - **Depends on:** Phase 2
76
+ - **Input:** [What's needed]
77
+ - **Output:** [What's produced]
78
+ - **Verify:** [How to check done]
79
+
80
+ ---
81
+
82
+ ## Phase 4: Audio & Effects
83
+
84
+ ### 4.1 [Task Name]
85
+ - [ ] **Task:** [Description]
86
+ - **Agent:** `[agent-name]`
87
+ - **Depends on:** None (parallel)
88
+ - **Input:** [What's needed]
89
+ - **Output:** [What's produced]
90
+ - **Verify:** [How to check done]
91
+
92
+ ---
93
+
94
+ ## Phase X: Verification
95
+
96
+ ### Build Verification
97
+ - [ ] **Build compiles without errors**
98
+ - Command: `[build command]`
99
+ - Expected: Build artifact created
100
+
101
+ - [ ] **Build size acceptable**
102
+ - Target: < [X] MB
103
+ - Actual: [X] MB
104
+
105
+ ### Performance Verification
106
+ - [ ] **Frame rate stable**
107
+ - Target: 60 FPS on [device]
108
+ - Test: Play for 5 minutes
109
+
110
+ - [ ] **Memory usage acceptable**
111
+ - Target: < [X] MB peak
112
+ - Test: Profile for 10 minutes
113
+
114
+ ### Feature Verification
115
+ - [ ] **Core loop works**
116
+ - Test: [Action] → [Reward] → [Progression]
117
+
118
+ - [ ] **All AC from SPEC met**
119
+ - [ ] AC1: [criterion]
120
+ - [ ] AC2: [criterion]
121
+ - [ ] AC3: [criterion]
122
+
123
+ ### Quality Verification
124
+ - [ ] **No critical bugs**
125
+ - [ ] **Audio plays correctly**
126
+ - [ ] **Save/Load works**
127
+ - [ ] **UI responsive on all supported devices**
128
+
129
+ ---
130
+
131
+ ## 📝 Session Log
132
+
133
+ ### [Date] - Session 1
134
+ **Completed:**
135
+ - [x] Task 1.1
136
+ - [x] Task 1.2
137
+
138
+ **Blockers:**
139
+ - [None / Description of blocker]
140
+
141
+ **Next Session:**
142
+ - [ ] Task 2.1
143
+
144
+ ---
145
+
146
+ ## ✅ Completion
147
+
148
+ > [!NOTE]
149
+ > Đánh dấu khi TOÀN BỘ tasks và Phase X hoàn thành.
150
+
151
+ - [ ] **All tasks completed**
152
+ - [ ] **Phase X verification passed**
153
+ - [ ] **CHANGELOG updated**
154
+
155
+ **Completed on:** [Date]
156
+ **Total time:** [X hours/days]
@@ -0,0 +1,493 @@
1
+ ---
2
+ name: survival-systems
3
+ description: Comprehensive survival game mechanics. Crafting systems, hunger/thirst/stamina, base building, resource gathering, day-night cycles, weather systems, and environmental hazards for Unity.
4
+ ---
5
+
6
+ # Survival Systems Skill
7
+
8
+ > **Purpose**: Build immersive survival games with interconnected systems.
9
+
10
+ ## When to Use
11
+ - Building survival/crafting games
12
+ - Implementing resource management
13
+ - Creating base building mechanics
14
+ - Designing environmental systems
15
+
16
+ ---
17
+
18
+ ## 1. Core Survival Stats
19
+
20
+ ### Stat Architecture
21
+ ```csharp
22
+ [CreateAssetMenu(fileName = "SurvivalConfig", menuName = "Game/Survival/Config")]
23
+ public class SurvivalConfig : ScriptableObject
24
+ {
25
+ [Header("Hunger")]
26
+ public float maxHunger = 100f;
27
+ public float hungerDecayRate = 1f; // per minute
28
+ public float starvingDamageRate = 5f; // HP per minute when hunger = 0
29
+
30
+ [Header("Thirst")]
31
+ public float maxThirst = 100f;
32
+ public float thirstDecayRate = 1.5f;
33
+ public float dehydrationDamageRate = 8f;
34
+
35
+ [Header("Stamina")]
36
+ public float maxStamina = 100f;
37
+ public float staminaRegenRate = 10f;
38
+ public float sprintStaminaCost = 15f;
39
+
40
+ [Header("Temperature")]
41
+ public float optimalTemp = 20f;
42
+ public float tempTolerance = 10f; // ±10 degrees comfortable
43
+ public float freezingDamageRate = 3f;
44
+ public float heatstrokeDamageRate = 3f;
45
+ }
46
+ ```
47
+
48
+ ### Survival Manager
49
+ ```csharp
50
+ public class SurvivalManager : MonoBehaviour
51
+ {
52
+ [SerializeField] private SurvivalConfig _config;
53
+
54
+ public float Hunger { get; private set; }
55
+ public float Thirst { get; private set; }
56
+ public float Stamina { get; private set; }
57
+ public float BodyTemperature { get; private set; }
58
+
59
+ // Events for UI binding
60
+ public event Action<float> OnHungerChanged;
61
+ public event Action<float> OnThirstChanged;
62
+ public event Action<float> OnStaminaChanged;
63
+ public event Action<float> OnTemperatureChanged;
64
+
65
+ private void Start()
66
+ {
67
+ Hunger = _config.maxHunger;
68
+ Thirst = _config.maxThirst;
69
+ Stamina = _config.maxStamina;
70
+ BodyTemperature = _config.optimalTemp;
71
+ }
72
+
73
+ private void Update()
74
+ {
75
+ float dt = Time.deltaTime / 60f; // Convert to per-minute
76
+
77
+ // Decay stats
78
+ ModifyHunger(-_config.hungerDecayRate * dt);
79
+ ModifyThirst(-_config.thirstDecayRate * dt);
80
+
81
+ // Apply damage at zero
82
+ if (Hunger <= 0) ApplyStarvingDamage(dt);
83
+ if (Thirst <= 0) ApplyDehydrationDamage(dt);
84
+
85
+ // Regenerate stamina
86
+ if (!IsSprinting) ModifyStamina(_config.staminaRegenRate * Time.deltaTime);
87
+ }
88
+
89
+ public void Eat(FoodItem food)
90
+ {
91
+ ModifyHunger(food.hungerRestore);
92
+ ModifyThirst(food.thirstRestore);
93
+ GameEvents.OnPlayerAte?.Invoke(food);
94
+ }
95
+
96
+ public void Drink(float amount)
97
+ {
98
+ ModifyThirst(amount);
99
+ GameEvents.OnPlayerDrank?.Invoke(amount);
100
+ }
101
+ }
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 2. Crafting System
107
+
108
+ ### Recipe Data Structure
109
+ ```csharp
110
+ [CreateAssetMenu(fileName = "Recipe", menuName = "Game/Crafting/Recipe")]
111
+ public class CraftingRecipe : ScriptableObject
112
+ {
113
+ public string recipeName;
114
+ public Sprite icon;
115
+
116
+ [Header("Ingredients")]
117
+ public IngredientSlot[] ingredients;
118
+
119
+ [Header("Output")]
120
+ public ItemData outputItem;
121
+ public int outputQuantity = 1;
122
+
123
+ [Header("Requirements")]
124
+ public CraftingStation requiredStation;
125
+ public float craftingTime = 2f;
126
+ public int requiredLevel = 1;
127
+
128
+ [Header("Discovery")]
129
+ public bool startsUnlocked = false;
130
+ public string[] unlockConditions; // "kill_boss_1", "find_blueprint"
131
+ }
132
+
133
+ [System.Serializable]
134
+ public struct IngredientSlot
135
+ {
136
+ public ItemData item;
137
+ public int quantity;
138
+ }
139
+
140
+ public enum CraftingStation
141
+ {
142
+ Hand, // No station needed
143
+ Workbench,
144
+ Forge,
145
+ ChemistryTable,
146
+ Kitchen
147
+ }
148
+ ```
149
+
150
+ ### Crafting Manager
151
+ ```csharp
152
+ public class CraftingManager : MonoBehaviour
153
+ {
154
+ [SerializeField] private CraftingRecipe[] _allRecipes;
155
+
156
+ private HashSet<string> _unlockedRecipes = new();
157
+ private InventoryManager _inventory;
158
+
159
+ public bool CanCraft(CraftingRecipe recipe)
160
+ {
161
+ // Check if unlocked
162
+ if (!recipe.startsUnlocked && !_unlockedRecipes.Contains(recipe.name))
163
+ return false;
164
+
165
+ // Check ingredients
166
+ foreach (var ingredient in recipe.ingredients)
167
+ {
168
+ if (!_inventory.HasItem(ingredient.item, ingredient.quantity))
169
+ return false;
170
+ }
171
+
172
+ // Check station
173
+ if (!HasAccessToStation(recipe.requiredStation))
174
+ return false;
175
+
176
+ return true;
177
+ }
178
+
179
+ public IEnumerator Craft(CraftingRecipe recipe, Action onComplete)
180
+ {
181
+ if (!CanCraft(recipe)) yield break;
182
+
183
+ // Consume ingredients
184
+ foreach (var ingredient in recipe.ingredients)
185
+ {
186
+ _inventory.RemoveItem(ingredient.item, ingredient.quantity);
187
+ }
188
+
189
+ // Crafting time
190
+ GameEvents.OnCraftingStarted?.Invoke(recipe);
191
+ yield return new WaitForSeconds(recipe.craftingTime);
192
+
193
+ // Add output
194
+ _inventory.AddItem(recipe.outputItem, recipe.outputQuantity);
195
+ GameEvents.OnItemCrafted?.Invoke(recipe.outputItem, recipe.outputQuantity);
196
+
197
+ onComplete?.Invoke();
198
+ }
199
+
200
+ public void UnlockRecipe(string recipeName)
201
+ {
202
+ _unlockedRecipes.Add(recipeName);
203
+ GameEvents.OnRecipeUnlocked?.Invoke(recipeName);
204
+ }
205
+ }
206
+ ```
207
+
208
+ ---
209
+
210
+ ## 3. Base Building
211
+
212
+ ### Building Piece System
213
+ ```csharp
214
+ [CreateAssetMenu(fileName = "BuildingPiece", menuName = "Game/Building/Piece")]
215
+ public class BuildingPiece : ScriptableObject
216
+ {
217
+ public string pieceName;
218
+ public GameObject prefab;
219
+ public GameObject ghostPrefab; // Transparent preview
220
+
221
+ [Header("Placement")]
222
+ public PieceCategory category;
223
+ public Vector3 gridSize = Vector3.one;
224
+ public bool requiresFoundation = false;
225
+ public bool canStack = true;
226
+
227
+ [Header("Stats")]
228
+ public float maxHealth = 100f;
229
+ public float repairCostMultiplier = 0.5f;
230
+
231
+ [Header("Cost")]
232
+ public IngredientSlot[] buildCost;
233
+ }
234
+
235
+ public enum PieceCategory
236
+ {
237
+ Foundation,
238
+ Wall,
239
+ Floor,
240
+ Roof,
241
+ Door,
242
+ Window,
243
+ Furniture,
244
+ Workstation,
245
+ Storage,
246
+ Defense
247
+ }
248
+ ```
249
+
250
+ ### Placement System
251
+ ```csharp
252
+ public class BuildingPlacer : MonoBehaviour
253
+ {
254
+ [SerializeField] private LayerMask _groundLayer;
255
+ [SerializeField] private LayerMask _snapLayer;
256
+ [SerializeField] private Material _validPlacementMat;
257
+ [SerializeField] private Material _invalidPlacementMat;
258
+
259
+ private BuildingPiece _currentPiece;
260
+ private GameObject _ghostInstance;
261
+ private bool _canPlace;
262
+
263
+ public void StartPlacing(BuildingPiece piece)
264
+ {
265
+ _currentPiece = piece;
266
+ _ghostInstance = Instantiate(piece.ghostPrefab);
267
+ }
268
+
269
+ private void Update()
270
+ {
271
+ if (_ghostInstance == null) return;
272
+
273
+ // Raycast for position
274
+ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
275
+ if (Physics.Raycast(ray, out RaycastHit hit, 100f, _groundLayer | _snapLayer))
276
+ {
277
+ Vector3 position = SnapToGrid(hit.point);
278
+ _ghostInstance.transform.position = position;
279
+
280
+ // Check validity
281
+ _canPlace = CheckPlacementValid(position);
282
+ UpdateGhostMaterial(_canPlace);
283
+ }
284
+
285
+ // Rotate
286
+ if (Input.GetKeyDown(KeyCode.R))
287
+ {
288
+ _ghostInstance.transform.Rotate(0, 90, 0);
289
+ }
290
+
291
+ // Place
292
+ if (Input.GetMouseButtonDown(0) && _canPlace)
293
+ {
294
+ PlacePiece();
295
+ }
296
+
297
+ // Cancel
298
+ if (Input.GetMouseButtonDown(1))
299
+ {
300
+ CancelPlacing();
301
+ }
302
+ }
303
+
304
+ private Vector3 SnapToGrid(Vector3 position)
305
+ {
306
+ float gridSize = _currentPiece.gridSize.x;
307
+ return new Vector3(
308
+ Mathf.Round(position.x / gridSize) * gridSize,
309
+ position.y,
310
+ Mathf.Round(position.z / gridSize) * gridSize
311
+ );
312
+ }
313
+ }
314
+ ```
315
+
316
+ ---
317
+
318
+ ## 4. Day-Night Cycle
319
+
320
+ ### Time System
321
+ ```csharp
322
+ public class DayNightCycle : MonoBehaviour
323
+ {
324
+ [Header("Time Settings")]
325
+ [SerializeField] private float _dayLengthMinutes = 20f; // Real minutes per game day
326
+ [SerializeField] private float _startTime = 6f; // 6 AM
327
+
328
+ [Header("Lighting")]
329
+ [SerializeField] private Light _sunLight;
330
+ [SerializeField] private Gradient _skyColorGradient;
331
+ [SerializeField] private AnimationCurve _sunIntensityCurve;
332
+
333
+ public float CurrentHour { get; private set; }
334
+ public int CurrentDay { get; private set; } = 1;
335
+ public bool IsNight => CurrentHour < 6f || CurrentHour >= 20f;
336
+
337
+ public event Action<int> OnNewDay;
338
+ public event Action OnNightStarted;
339
+ public event Action OnDayStarted;
340
+
341
+ private float _timeScale;
342
+ private bool _wasNight;
343
+
344
+ private void Start()
345
+ {
346
+ CurrentHour = _startTime;
347
+ _timeScale = 24f / (_dayLengthMinutes * 60f); // Hours per real second
348
+ }
349
+
350
+ private void Update()
351
+ {
352
+ // Advance time
353
+ CurrentHour += _timeScale * Time.deltaTime;
354
+
355
+ // New day
356
+ if (CurrentHour >= 24f)
357
+ {
358
+ CurrentHour -= 24f;
359
+ CurrentDay++;
360
+ OnNewDay?.Invoke(CurrentDay);
361
+ }
362
+
363
+ // Day/Night transitions
364
+ bool isNightNow = IsNight;
365
+ if (isNightNow && !_wasNight)
366
+ {
367
+ OnNightStarted?.Invoke();
368
+ GameEvents.OnNightStarted?.Invoke();
369
+ }
370
+ else if (!isNightNow && _wasNight)
371
+ {
372
+ OnDayStarted?.Invoke();
373
+ GameEvents.OnDayStarted?.Invoke();
374
+ }
375
+ _wasNight = isNightNow;
376
+
377
+ // Update lighting
378
+ UpdateLighting();
379
+ }
380
+
381
+ private void UpdateLighting()
382
+ {
383
+ float t = CurrentHour / 24f;
384
+
385
+ // Rotate sun
386
+ _sunLight.transform.rotation = Quaternion.Euler((t * 360f) - 90f, 170f, 0);
387
+
388
+ // Intensity
389
+ _sunLight.intensity = _sunIntensityCurve.Evaluate(t);
390
+
391
+ // Sky color
392
+ RenderSettings.ambientSkyColor = _skyColorGradient.Evaluate(t);
393
+ }
394
+ }
395
+ ```
396
+
397
+ ---
398
+
399
+ ## 5. Resource Nodes
400
+
401
+ ### Harvestable Resources
402
+ ```csharp
403
+ [CreateAssetMenu(fileName = "ResourceNode", menuName = "Game/Survival/ResourceNode")]
404
+ public class ResourceNodeData : ScriptableObject
405
+ {
406
+ public string nodeName;
407
+ public ResourceType type;
408
+
409
+ [Header("Harvesting")]
410
+ public ToolType requiredTool;
411
+ public int minToolTier = 0;
412
+ public int hitsToHarvest = 3;
413
+
414
+ [Header("Drops")]
415
+ public LootDrop[] drops;
416
+
417
+ [Header("Respawn")]
418
+ public float respawnTimeSeconds = 300f;
419
+ public bool canRespawn = true;
420
+ }
421
+
422
+ public enum ResourceType { Tree, Rock, Ore, Bush, Animal, Fish }
423
+ public enum ToolType { None, Axe, Pickaxe, Shovel, FishingRod }
424
+
425
+ public class ResourceNode : MonoBehaviour, IDamageable
426
+ {
427
+ [SerializeField] private ResourceNodeData _data;
428
+
429
+ private int _remainingHits;
430
+ private bool _depleted;
431
+
432
+ public void TakeDamage(DamageInfo damage)
433
+ {
434
+ // Check tool requirement
435
+ if (!HasCorrectTool(damage.toolType, damage.toolTier))
436
+ {
437
+ GameEvents.OnWrongTool?.Invoke(_data.requiredTool);
438
+ return;
439
+ }
440
+
441
+ _remainingHits--;
442
+ PlayHitEffect();
443
+
444
+ if (_remainingHits <= 0)
445
+ {
446
+ Harvest();
447
+ }
448
+ }
449
+
450
+ private void Harvest()
451
+ {
452
+ // Spawn drops
453
+ foreach (var drop in _data.drops)
454
+ {
455
+ int quantity = Random.Range(drop.minQuantity, drop.maxQuantity + 1);
456
+ SpawnDrop(drop.item, quantity);
457
+ }
458
+
459
+ _depleted = true;
460
+
461
+ if (_data.canRespawn)
462
+ {
463
+ StartCoroutine(RespawnAfterDelay());
464
+ }
465
+ else
466
+ {
467
+ Destroy(gameObject);
468
+ }
469
+ }
470
+ }
471
+ ```
472
+
473
+ ---
474
+
475
+ ## Anti-Patterns
476
+
477
+ | ❌ Don't | ✅ Do |
478
+ |----------|-------|
479
+ | Hardcode decay rates | Use ScriptableObject configs |
480
+ | Tick every frame | Use time-based intervals |
481
+ | Complex nested if-else | Use state machines |
482
+ | Ignore player feedback | Show clear UI indicators |
483
+ | One giant manager | Separate concerns (Hunger, Thirst, etc.) |
484
+
485
+ ---
486
+
487
+ ## Related Skills
488
+ - `game-development/inventory-quest` - Inventory system
489
+ - `game-development/game-state-manager` - Save/Load
490
+ - `game-development/game-economy-designer` - Resource balancing
491
+
492
+ ## Related Workflows
493
+ - `/game-hybrid` - Development workflow