$npx -y skills add thedivergentai/GD-Agentic-Skills --skill godot-genre-sandboxExpert blueprint for sandbox games (Minecraft, Terraria, Garry's Mod) with physics-based interactions, cellular automata, emergent gameplay, and creative tools. Use when building open-world creation games with voxels, element systems, player-created structures, or procedural worl
| 1 | ## Godot 4.7 Baseline |
| 2 | |
| 3 | - Expert patterns in this skill target **Godot 4.7+** (stable, 2026-06-18). |
| 4 | - Consult the [Godot 4.7 migration guide](https://docs.godotengine.org/en/4.7/tutorials/migrating/upgrading_to_godot_4.7.html) when upgrading projects from 4.6. |
| 5 | - **NEVER** assume 4.6 defaults (stretch mode, audio area_mask, RichTextLabel percent flags) without checking 4.7 migration notes. |
| 6 | |
| 7 | # Genre: Sandbox |
| 8 | |
| 9 | Physical simulation, emergent play, and player creativity define this genre. |
| 10 | |
| 11 | ## NEVER Do (Expert Anti-Patterns) |
| 12 | |
| 13 | ### Performance & Scalability |
| 14 | - NEVER use individual `RigidBody` nodes for every block; strictly use **Static Colliders** for the world and reserve physics for dynamic props. |
| 15 | - NEVER simulate the entire world every frame; strictly process **"Dirty" chunks** with active changes. Sleeping chunks must consume zero CPU. |
| 16 | - NEVER update `MultiMesh` buffers every frame; strictly **batch changes** and only rebuild the buffer when a modification completes (e.g., player stops painting). |
| 17 | - NEVER use standard Godot `Nodes` for every grid cell; strictly use **PackedInt32Arrays** or typed Dictionaries to keep RAM overhead minimal. |
| 18 | - NEVER raycast against every individual voxel for placement; strictly use **Grid Quantization** (`floor(pos/size)`) for direct O(1) cell calculation. |
| 19 | - NEVER render every block face in a chunk; strictly generate an `ArrayMesh` that only pushes **visible exterior faces** to the GPU (Culling/Greedy Meshing). |
| 20 | |
| 21 | ### Data & Persistence |
| 22 | - NEVER save raw arrays of every block transform; strictly use **Run-Length Encoding (RLE)** (e.g., "Air x 50,000") to compress uniform spaces. |
| 23 | - NEVER load massive terrain chunks synchronously; strictly use `ResourceLoader.load_threaded_request()` to prevent frame stutter. |
| 24 | - NEVER use standard text `.tscn` files for voxel datasets; strictly use **binary `.res` files** for 10x faster parsing. |
| 25 | - NEVER ignore **Floating-Point Precision limits** (32,768 units); strictly implement floating-origin shifting for massive worlds. |
| 26 | |
| 27 | ### Systems & Architecture |
| 28 | - NEVER hardcode element interactions (`if water and fire`); strictly use a **Property System** where interactions emerge from material attributes (flammability, density). |
| 29 | - NEVER trust client-side placement in multiplayer; strictly require the **Server to validate** bounds and resources. |
| 30 | - NEVER manipulate the SceneTree from background generation threads; strictly use `call_deferred()` or Mutex locks for safety. |
| 31 | - NEVER leave orphaned chunks in memory; strictly track loaded regions and call `queue_free()` on discarded branches. |
| 32 | |
| 33 | --- |
| 34 | |
| 35 | ## 🛠 Expert Components (scripts/) |
| 36 | |
| 37 | ### Original Expert Patterns |
| 38 | - [voxel_chunk_manager.gd](scripts/voxel_chunk_manager.gd) - Professional chunk management using `MultiMeshInstance3D` with batch update logic. |
| 39 | - [cellular_automata_liquid.gd](scripts/cellular_automata_liquid.gd) - Optimized simulation of liquids and powders using property-based density checks. |
| 40 | - [voxel_world.gd](scripts/voxel_world.gd) - Top-level world controller for grid state, tool-based editing, and chunk lifecycle. |
| 41 | |
| 42 | ### Modular Components |
| 43 | - [sandbox_patterns.gd](scripts/sandbox_patterns.gd) - Utility collection for async chunk loading, multithreading, and origin shifting. |
| 44 | |
| 45 | ## Architecture Patterns |
| 46 | |
| 47 | ### 1. Element System (Property-Based Emergence) |
| 48 | Model material properties, not behaviors. Interactions emerge from overlapping properties. |
| 49 | |
| 50 | ```gdscript |
| 51 | # element_data.gd |
| 52 | class_name ElementData extends Resource |
| 53 | |
| 54 | enum Type { SOLID, LIQUID, GAS, POWDER } |
| 55 | @export var id: String = "air" |
| 56 | @export var type: Type = Type.GAS |
| 57 | @export var density: float = 0.0 # For liquid flow direction |
| 58 | @export var flammable: float = 0.0 # 0-1: Chance to ignite |
| 59 | @export var ignition_temp: float = 400.0 |
| 60 | @export var conductivity: float = 0.0 # For electricity/heat |
| 61 | @export var hardness: float = 1.0 # Mining time multiplier |
| 62 | |
| 63 | # EDGE CASE: What if two elements have same density but different types? |
| 64 | # SOLUTION: Use secondary sort (type enum priority: SOLID > LIQUID > POWDER > GAS) |
| 65 | func should_swap_with(other: ElementData) -> bool: |
| 66 | if density == other.density: |
| 67 | return type > other.type # Enum comparison: SOLID(0) > GAS(3) |
| 68 | return density > other.density |
| 69 | ``` |
| 70 | |
| 71 | ### 2. Cellular Automata Grid (Falling Sand Simulation) |
| 72 | Update order matters. Top-down prevents "teleporting" godot-particles. |
| 73 | |
| 74 | ```gdscript |
| 75 | # world_grid.gd |
| 76 | var grid: Dictionary = {} # Vector2i -> ElementData |
| 77 | var dirty_cells: Array[Vector2i] = [] |
| 78 | |
| 79 | func _physics_process(_delta: float) -> void: |
| 80 | # CRITICAL: Sort top-to-bottom to prevent |