$npx -y skills add thedivergentai/GD-Agentic-Skills --skill godot-genre-rtsExpert blueprint for real-time strategy games including unit selection (drag box, shift-add), command systems (move, attack, gather), pathfinding (NavigationAgent2D with RVO avoidance), fog of war (SubViewport mask shader), resource economy (gather/build loop), and AI opponents (
| 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: Real-Time Strategy (RTS) |
| 8 | |
| 9 | Expert blueprint for RTS games balancing strategy, micromanagement, and performance. |
| 10 | |
| 11 | ## NEVER Do (Expert Anti-Patterns) |
| 12 | |
| 13 | ### Unit Logic & Pathfinding |
| 14 | - NEVER allow pathfinding "Jitter" when moving group units; strictly **stagger path queries** and enable **RVO Avoidance** only when units are in motion to save CPU cycles. |
| 15 | - NEVER update RVO avoidance every frame for all units; strictly use **Avoidance Threading** (Project Settings) and replace static units with `NavigationObstacle`. |
| 16 | - NEVER let units get stuck in infinite path loops; strictly implement a **timeout and IDLE state** if a destination is unreachable. |
| 17 | - NEVER use `_process()` on hundreds of individual units; strictly use a central **UnitManager** or `_physics_process` only when required. |
| 18 | - NEVER calculate unit visibility manually for Fog of War; strictly use a **Shader-based mask** (SubViewport + ColorRect) for GPU efficiency. |
| 19 | - NEVER process unit AI or pathfinding synchronously for mass groups; strictly offload to **`WorkerThreadPool`** and stagger path updates. |
| 20 | - NEVER use high-poly visual meshes as NavMesh source geometry; strictly use simplified **Collision Shapes** for baking. |
| 21 | |
| 22 | ### Interaction & Commands |
| 23 | - NEVER forget **Command Queuing** (Shift-Click); strictly store an `Array[Command]` and implement a "Force Move/Attack" bypass. |
| 24 | - NEVER create excessive micromanagement; strictly automate low-level tasks like **auto-aggro range** and auto-return for resource gathering. |
| 25 | - NEVER use exact floating-point equality (==) for grid or timers; strictly use `is_equal_approx()` for deterministic triggers. |
| 26 | - NEVER rely on the visual SceneTree for selection data; strictly maintain a **Typed Selection Set** of `RefCounted` or `Resource` objects for deterministic serialization and netcode. |
| 27 | - NEVER forget **Command Queuing**; strictly implement a **Command Pattern** using serializable `Dictionary` or `JSON` states for save-game and multiplayer playback. |
| 28 | - NEVER forget to **duplicate_deep()** globally shared Resources; otherwise, modifying one unit's data (e.g., stats) affects all. |
| 29 | |
| 30 | ### Performance & Simulation |
| 31 | - NEVER render thousands of units using separate `MeshInstance3D` nodes; strictly use **`MultiMeshInstance`** with **`INSTANCE_CUSTOM`** data to drive unique GPU-side state animations (walking/attacking/color). |
| 32 | - NEVER calculate transforms for mass units on the main thread; strictly use **`WorkerThreadPool`** to push buffers to `RenderingServer.multimesh_set_buffer()`. |
| 33 | - NEVER update every unit's navigation path in the same frame; strictly use random timers to **stagger updates**. |
| 34 | - NEVER use standard Strings for high-frequency AI state identifiers; strictly use **StringName** (&"harvesting") for pointer-speed comparisons. |
| 35 | - NEVER allow simulation coordinates to exceed 8192 units without float-precision management; strictly use world-origin shifts. |
| 36 | - NEVER use `CSGShape3D` for building placement ghosts; strictly use optimized static `ArrayMesh` geometry. |
| 37 | |
| 38 | --- |
| 39 | |
| 40 | ## 🛠 Expert Components (scripts/) |
| 41 | |
| 42 | ### Original Expert Patterns |
| 43 | - [selection_manager_marquee_2d.gd](scripts/selection_manager_marquee_2d.gd) - Professional-grade unit selection system with drag-box, unit filtering, and shift-add support. |
| 44 | |
| 45 | ### Modular Components |
| 46 | - [rts_army_manager.gd](scripts/rts_army_manager.gd) - Multithreaded AI update system for managing mass units on background cores. |
| 47 | - [selection_manager_raycast_3d.gd](scripts/selection_manager_raycast_3d.gd) - Optimized 3D selection using direct PhysicsServer raycasting. |
| 48 | - [rts_path_query_pool.gd](scripts/rts_path_query_pool.gd) - Pooled Navigation query system to prevent memory allocations. |
| 49 | - [navigation_mask_helper.gd](scripts/navigation_mask_helper.gd) - Bitmask utilities for dynamic navigation layers and avoidance. |
| 50 | - [rts_targeting_logic.gd](scripts/rts_targeting_logic.gd) - Distance-squared performance optimization for mass enemy filtering. |
| 51 | - [rts_group_commander.gd](scripts/rts_group_commander.gd) - SceneTree group broadcasting pattern for decoupled mass units. |
| 52 | - [rts_unit_stat_duplicator.gd](scri |