ArchSurvivor Conventions
MANDATORY: Apply these namespace and architectural rules when creating or modifying code in the ArchSurvivor project.
🗺️ System Map Read
🔴 MANDATORY: Read
ARCHITECTURE.mdat session start to understand Agents, Skills, and Scripts.
Before coding, answer:
- •What is the GOAL of this agent/skill?
- •What PRINCIPLES must I apply?
- •How does this DIFFER from generic output?
🏗️ Architectural Layers & Namespaces
The project follows a layered architecture. Always use the appropriate namespace based on the file's location.
| Layer | Root Namespace | Folder | Responsibility |
|---|---|---|---|
| Core | _ArchSurvivor.Core | Assets/_ArchSurvivor/Core | Utilities, low-level systems, generic helpers. |
| Domain | _ArchSurvivor.Domain | Assets/_ArchSurvivor/Domain | Entities, Value Objects, Domain Events, Pure Logic. |
| Application | _ArchSurvivor.Application | Assets/_ArchSurvivor/Application | Interfaces, Data Transfer Objects (DTOs), Use Cases. |
| Infrastructure | _ArchSurvivor.Infrastructure | Assets/_ArchSurvivor/Infrastructure | Service implementations (Input, Save, Radar, etc.). |
| Presentation | _ArchSurvivor.Presentation | Assets/_ArchSurvivor.Presentation | MonoBehaviors, UI, Visuals, FSM, KCC. |
📂 Folder Structure
Maintain this structure to ensure architectural integrity and AI readability.
Assets/_ArchSurvivor/
├── _Boot/ # Entry points, ProjectContext, Global Prefabs
├── Application/ # [AsmDef] Interfaces, DTOs, Business Use Cases
├── Core/ # [AsmDef] Cross-cutting concerns, Utilities (GameLog, ZString)
├── Domain/ # [AsmDef] Models, Configs (ScriptableObjects), Pure Logic
├── Infrastructure/ # [AsmDef] Implementations of App Interfaces (LocalSave, Audio)
├── Installers/ # VContainer LifetimeScopes (Project, Game)
└── Presentation/ # [AsmDef] MonoBehaviors, Features, UI
├── Features/ # Organized by Domain Area (Player, Enemies, World)
│ └── Player/
│ ├── Combat/ # HeroCombat, Weapons
│ ├── FSM/ # State Machine, States
│ ├── KCC/ # ArchHeroController, Inputs
│ ├── Logic/ # CharacterFactory, Providers
│ └── Visuals/ # HeroAnimation, Effects
├── Services/ # Presentation-only services (Juice, Flash)
└── UI/ # UI Controllers, Views, UXML
📁 Feature-Specific Namespaces
Within the Presentation layer, code is organized by feature. Namespaces MUST strictly match folder hierarchy. Avoid adding redundant sub-namespaces like .Logic if the folder doesn't exist.
Player / Hero Feature
- •Combat:
_ArchSurvivor.Presentation.Features.Player.Combat - •FSM:
_ArchSurvivor.Presentation.Features.Player.FSM - •KCC:
_ArchSurvivor.Presentation.Features.Player.KCC - •Visuals:
_ArchSurvivor.Presentation.Features.Player.Visuals - •Logic:
_ArchSurvivor.Presentation.Features.Player.Logic
🔌 Third-Party Integration
| Library | Namespace | Usage |
|---|---|---|
| VContainer | VContainer, VContainer.Unity | Dependency Injection. |
| R3 | R3 | Reactive programming, UI binding. |
| Sisus.Init | Sisus.Init | Data injection for MonoBehaviors. |
| RaycastPro | RaycastPro.RaySensors, RaycastPro.Detectors | Ground and range sensing. |
| Animancer | Animancer, Animancer.FSM | Animation system. |
💎 SOLID & Senior Code Style
Apply these principles to maintain a 10/10 codebase.
1. S.O.L.I.D. in Unity
- •S (Single Responsibility): Small classes. If a Script has > 300 lines, split it (e.g., move logic to a non-Mono Domain class).
- •O (Open/Closed): Use
ScriptableObjectconfigs for data. Add new content by creating assets, not modifying code. - •L (Liskov Substitution): Interfaces for everything in
Applicationlayer. - •I (Interface Segregation): Tiny interfaces (e.g.,
IDamageable,IHero). - •D (Dependency Inversion): MANDATORY VContainer injection. Never use
FindObjectOfTypeorStaticsingletons. - •Odin Validation: Use
[Required],[AssetsOnly], and[SceneObjectsOnly]for all serialized references.
2. Code Style & Naming
- •Braces: MANDATORY Egyptian style (Opening brace
{on the same line). - •Variables:
_camelCasefor private fields (with optional_prefix),PascalCasefor public properties/methods. - •Namespaces: Must match folder structure (e.g.,
_ArchSurvivor.Presentation.Features.Player). - •Grouping: Use blank lines to group logical blocks.
- •Null Safety: Use
null!for fields assigned via Inspector/DI. - •Clean Coding: Leverages
ValueTask,UniTask, andrecordfor performance. - •Logging: Always use
GameLog.Info/Warning/Errorfor all Unity components.
🛠️ Common Patterns
Scoped Hero Spawning
When spawning a Hero, always use LifetimeScope.CreateChild to ensure dependencies are properly scoped.
using (VContainer.Unity.LifetimeScope.CreateChild(_objectResolver, builder => {
builder.RegisterInstance(runtimeData);
})) {
SetupInjection(runtimeData);
var go = Object.Instantiate(prefab, position, Quaternion.identity);
_objectResolver.InjectGameObject(go);
}
DI in FSM
Always import VContainer and use [Inject] for state machine dependencies.
using VContainer;
public class HeroStateMachine : MonoBehaviour {
[Inject]
public void Construct(...) { ... }
}