godot-game-loop-harvest
SKILL.md
Godot Game Loop: Harvest
Implement decoupled, data-driven gathering mechanics. This system handles tool validation, depletion, and respawning.
1. Component Reference
| Component | Asset | Description |
|---|---|---|
| Resource Data | resource_data.gd | Resource: Defines health, yield, and tool requirements. |
| Tool Data | harvest_tool_data.gd | Resource: Defines damage, type, and tier. |
| Harvestable Node | harvestable_node.gd | StaticBody3D: The world interaction entity. |
| Respawn Manager | harvest_respawn_manager.gd | Node: (Singleton) Manages world persistence. |
| Inventory Manager | harvest_inventory_manager.gd | Node: Hub for resource collection. |
2. Implementation Guide
Step 1: Resource Setup
- Create a
HarvestResourceDataresource in the inspector. - Configure
Required Tool Type(e.g., "pickaxe", "axe") andRequired Tier. - Set
Yield Range(Vector2i) and optionalItem Scenefor physical drops.
Step 2: Node Configuration
- Attach
harvestable_node.gdto aStaticBody3Dnode. - Assign the
ResourceDatafrom Step 1. - Assign a child
Node3D(e.g., a Mesh) tomesh_to_shakefor visual feedback. - Physics: Ensure the node is on Layer 1 for interaction.
Step 3: Global Systems (Recommended)
- Add
harvest_respawn_manager.gdas an Autoload namedHarvestRespawnManager. - The
HarvestableNodewill automatically use this manager if it is found at/root/HarvestRespawnManager.
3. Interaction & Signals
Calling Hits
When a player interacts (e.g., via RayCast), call apply_hit(tool_data).
if collider is HarvestableNode:
collider.apply_hit(player_tool)
Signal Map
| Signal | Payload | Integration |
|---|---|---|
harvested |
(data, amount) |
Connect to InventoryManager.add_resource. |
took_damage |
(curr, max) |
Connect to a Progress Bar or Damage Popups. |
interaction_failed |
(reason: String) |
Handles "wrong_tool" or "low_tier" UI feedback. |
4. Engineering Standards
- Physics: Depleted nodes shift to Layer 16 (Inactive) and hide while respawning.
- Yield Logic: Quantity is randomized based on the resource's
yield_range. - Feedback: Tactile feedback via
mesh_to_shakeis essential for game "juice."
5. Verification Checklist
- Shake: Mesh shakes slightly upon a valid hit.
- Validation: Emits
interaction_failedif tool/tier requirements are unmet. - Depletion: Node hides and collision disables at 0 health.
- Drops: Spawns
item_sceneat the node's position upon harvest. - Respawn: Node reappears and re-enables collision after
respawn_time.
Weekly Installs
14
Repository
thedivergentai/…c-skillsGitHub Stars
35
First Seen
8 days ago
Security Audits
Installed on
gemini-cli14
amp14
cline14
github-copilot14
codex14
kimi-cli14