NEVER commit or push changes to Git without explicit, turn-by-frame consultation and confirmation from the user. Even if a task feels "complete" or the user says "finish the task", you MUST propose the commit message and wait for an explicit "Yes, commit this" for that specific set of changes. This is a zero-tolerance policy.
- Machine: Windows 10 pro
- Unity 6000.3.2f1; 3D project using URP.
- Target platform: PC
- C# gameplay logic separated from UI/presentation.
We follow a Data-Driven Architecture prioritizing strict Logic/View separation. High-level summaries are below; for detailed architectural breakdowns, refer to the specific system notes in the designs/ folder.
- Grid System (Detailed in
designs/grid_system.md):- Logic:
HexData&Grid(Pure C#). - View:
Hex,GridVisualizationManager. - Principle: Logic dictates state; View reacts.
GridVisualizationManagerresolves styling (rims/colors) based on string-based state priorities. Visibility is gated by apriority > 0check (negative priorities hide states while preserving data).
- Logic:
- Unit System (Detailed in
designs/unit_system.md):- Data: JSON-based Schemas and Sets (
Assets/Data/). - Logic:
Unit(UniqueId, stats, team affiliation). GameObject naming convention:UnitName_ID. - View:
UnitVisualization(Models/Anims). Automated lunge animations. - Principle: Units are grid-aware agents. All configuration data is stored in JSON files, managed via the
UnitDataEditorWindow.UnitManagercentralizes the active set and persists it within layout files. Quick-save support vialastLayoutPath.
- Data: JSON-based Schemas and Sets (
- Ruleset & Game Logic (Detailed in
designs/grid_system.md&unit_system.md):- Logic:
Ruleset(Abstract SO),BattleBrothersRuleset. - Management:
GameMaster(Persistent Singleton). - Principle: The Ruleset is the game's "brain," dictating movement costs and grid-state side effects (e.g., Zone of Control). The
PathfinderandUnitsystems query theGameMasterto execute specific gameplay rules. - Combat:
BattleBrothersRulesetuses a bucket-based probability engine for unified resolution of hits, cover interception, and scatter (stray shots). Pathfinding is attack-aware, stopping units at optimal range and visualizing the Area of Attack (AoA).
- Logic:
- Interaction:
ToolManager(Central Hub),PathfindingTool(Real-time pathing),ToggleTool(Base for utility triggers likeGridToolandZoCTool), and various Editor Tools (HexArena menu).
- Central Hub:
GEMINI.mdcontains high-level context, environment details - System Documentation: Detailed architecture, decision logs, and structures for specific systems live in
designs/<system_name>.md. - Policy:
- Always keep documentation high-level in the root file and detailed in the designs.
- User Confirmation: Never delete or significantly restructure documentation without explicit user confirmation.
- Update
designs/files as features are completed and verified.
- Unit Data Management: Use the
Unit Data Editor(HexArenamenu) for all Schema and Unit Set modifications. These changes are auto-saved directly to JSON files. Avoid manual JSON edits unless necessary.
- Understand & Strategize: Analyze the required feature, propose options, select approach with the user.
- Plan: Develop a concise plan and proposed tests for the selected approach.
- Write tests: Write a complete list of tests covering the new feature
- Implement: Write/correct game code
- Testing: Run
python tools/diagnose_unity.py. This is the ONLY acceptable way to verify your changes. Full diagnostics (including tests) must always be run. - Correction loop: Repeat steps 4 and 5 until
diagnose_unity.pyreports "Verification Successful!" with zero console errors and all tests passing. Confirm with the user once this state is reached. - Verification & finalization: Once user confirms feature is done, update documentation, PROPOSE committing.
- Test Persistence: Always store created tests as permanent artifacts in the codebase as long as they remain relevant and the feature they test exists. Never delete tests after verification unless explicitly requested.
- When writing Python, be very concise and prefer brevity over handling all errors etc.
- Flattening & Guard Clauses: Always prioritize flat code structures. Use guard clauses (
if (!condition) return;) and early exits to minimize nesting and improve readability. Refactor deeply nested blocks into a series of top-level checks followed by the "happy path" logic.
- ScrollViews: In custom editors, never use
GUILayout.HeightinsideEditorGUILayout.BeginScrollView. It restricts the layout unnecessarily and often looks poor. - Headers: Never use
[Header("...")]attributes in MonoBehaviours. All section labeling and organization must be handled within the custom editor. - JSON-Only Data: For gameplay configuration (like unit stats), always prefer JSON serialization over Unity Assets. Use the pattern of transient ScriptableObjects loaded from JSON at runtime/editor-time.
- Auto-Save: Custom data editor windows must implement auto-save functionality to prevent data loss. Use
EditorGUI.BeginChangeCheckto detect modifications. - Menu: Centralize specialized project tools under the
HexArenatop-level menu. Avoid creating multiple proprietary menu categories.
- Shell Commands: NEVER use
&&to chain multiple shell commands. Execute each independently. - Screenshots & Visual Inspection - NEVER use MCP for screenshots. ALWAYS use
python tools/capture_unity.py "<purpose>"to capture the Unity window. - Testing & Diagnostics - NEVER use MCP's
read_console,run_tests, ormanage_scene (save)directly. ALWAYS usepython tools/diagnose_unity.py. This is the mandatory "Quality Gate" for the project. Full diagnostics (including tests) are mandatory and MUST always be run. It ensures stability by:- Monitoring Compilation: Intelligently waits for background compilation to stabilize (polling DLL vs CS timestamps) so tests never run on stale code.
- Auditing Console: Performs a deep scan for errors/exceptions while filtering out infrastructure noise.
- Unified Verification: Handles scene saving and test execution in a single atomic pass. If the script fails (exit code 1), you MUST fix the reported errors before proceeding.
- Git Usage:
- CRITICAL: NEVER commit or push without explicit confirmation.
- Mandate: Always stage all changed files when preparing a commit (
git add .). - Efficiency: Avoid running
git diffwhen preparing the commit message as it takes too long. Use the list of changed filenames and your conversation context to describe the changes. - Propose commit messages first, listing all modified files.
- Run each git command independently.
- Scene inspection/Management: Use
manage_gameobjectormanage_scene. - Editing: Break long edits into smaller ones to avoid context matching issues.