2.8 KiB
2.8 KiB
Project Overview: Godot C# Movement Tests
This project is a high-performance 3D character controller for Godot 4.x using C# 13 and .NET 9. It focuses on modular movement systems (Dash, Mantle, Stairs) and robust combat mechanics (Damage, Health, Knockback) decoupled through interfaces.
Core Architecture
- Modular Systems: The
PlayerController.csacts as a central hub for multiple specialized "Systems" (e.g.,DashSystem,MantleSystem,HeadSystem,StairsSystem). - State Management: Uses
GodotStateChartsfor complex movement and action states. Look for state transitions and triggers within the system scripts. - Interface-Driven Design: Located in
/interfaces/, these define how objects interact (e.g.,IDamageable,IHealthable,IKnockbackable). Always implement these interfaces for new interactable entities. - Node Composition: Most systems are attached to the
PlayerControllerscene as child nodes and initialized via their respectiveInit()methods or exported fields.
Key Directories
/scenes/player_controller/: Contains the main player scene, the centralPlayerController.cs, and its sub-systems./scenes/player_controller/components/: Modular logic for specific features like Dash, Mantle, and Weapons./interfaces/: Core C# interfaces and shared records (e.g.,DamageRecord,HealthChangedRecord)./tests/: Automated unit and integration tests usingGdUnit4andxUnit.
Coding Standards & Idioms
- C# 13 & .NET 9: Use modern C# features (records, primary constructors, collection expressions).
- Godot Partial Classes: All Godot scripts must be
partialand use[GlobalClass]where appropriate for editor visibility. - RustyOptions: The project uses
RustyOptionsfor safer null handling and result types (Option<T>,Result<T, E>). - Signals: Use
[Signal]and theEventHandlerpattern for Godot signals. - Dependency Injection: Systems are typically assigned to fields in
PlayerControllervia the editor orGetNode<T>()in_Ready().
LLM Interaction Tips
- Partial Classes: When suggesting changes to
PlayerController.csor systems, remember they arepartial. Large files likePlayerController.cs(2500+ lines) are often split or contain many regions. - Node Hierarchy: Always check
PlayerController.tscnor system scenes (head_system.tscn) when dealing with node references (GetNode). - GdUnit4: For testing, follow the pattern in
tests/PlayerMovementTest.cs. UseISceneRunnerto simulate inputs and await frames/milliseconds. - Vector Operations: Use Godot's built-in
Vector3methods for movement logic. The project often usesGlobalPositionandDirectionTo. - Boilerplate: When creating new systems, mirror the
Init()and_PhysicsProcesspatterns found in existing systems likeDashSystem.csorMantleSystem.cs.