# littlehan3/unrealgame architecture

> Architecture diagram of the GitHub repository littlehan3/unrealgame, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/littlehan3/unrealgame
- Repository: https://github.com/littlehan3/unrealgame

## Overview

##### Project type and purpose
- This is a C++-based Unreal Engine survival-action game combining TPS and Souls-like melee combat.
- Core gameplay revolves around a single player character (AMainCharacter) with modular combat and skill subsystems, and AI-driven enemies.

##### File structure
- All gameplay code lives in top-level .cpp/.h files—no separate “Source/” subdirs.
- Key class groups:
- Character & Game Mode: AMainCharacter, MainGameModeBase
- Components: USkillComponent, UMeleeCombatComponent, MainCharacterHealthComponent
- Weapons & Projectiles: Rifle, MachineGun, Cannon, AimSkill*Projectile, Skill3Projectile
- Enemy & AI: AEnemy, EnemyAIController, AnimNotify_*, EnemyAnimInstance
- Build/config: Locomotion.Build.cs
- No explicit UI or networking folders—focus is strictly single-player core logic, AI, effects, animation, physics.

##### Extracted architectural insights from the README
- The author refactored AMainCharacter into three SRP-compliant pieces:
- AMainCharacter handles input, state, weapon hold logic, animation variables.
- USkillComponent handles all ranged/aimed skills, cooldowns, projectile spawning, skill logic.
- Enemy behaviors are encapsulated in AEnemy (state, damage, death) + EnemyAIController (movement, attack logic, dodge, jump attack) + AnimNotifies for animation-driven events.
- Effects and sound use Niagara and Unreal’s Audio system. Collision/trace logic uses LineTrace and SphereTrace API.

##### Elements
- Clear labels: use class names (AMainCharacter, USkillComponent, AEnemyAIController, etc.)
- Blue rectangles for player classes/components
- Red for enemy/AI classes
- Orange for projectile/effects
- Gray for engine services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Player Layer
    subgraph "Player Layer"
        direction TB
        AMainCharacter["AMainCharacter"]:::player
        MainCharacterHealthComponent["MainCharacterHealthComponent"]:::player
        subgraph "Weapons"
            direction TB
            Rifle["Rifle"]:::player
            MachineGun["MachineGun"]:::player
            Cannon["Cannon"]:::player
            Knife["Knife"]:::player
        end
    end

    %% Gameplay Components
    subgraph "Gameplay Components"
        direction TB
        USkillComponent["USkillComponent"]:::gameplay
        UMeleeCombatComponent["UMeleeCombatComponent"]:::gameplay
    end

    %% Projectiles & Effects
    subgraph "Projectiles & Effects"
        direction TB
        AimSkill2Projectile["AimSkill2Projectile"]:::projectile
        AimSkill3Projectile["AimSkill3Projectile"]:::projectile
        Skill3Projectile["Skill3Projectile"]:::projectile
        PlaySlashEffectForward["PlaySlashEffectForward"]:::projectile
    end

    %% AI Layer
    subgraph "AI Layer"
        direction TB
        EnemyAIController["EnemyAIController"]:::enemy
        AEnemy["AEnemy"]:::enemy
        EnemyAnimInstance["EnemyAnimInstance"]:::enemy
        subgraph "AnimNotifies"
            direction TB
            ANStartAttack["AnimNotify_EnemyStartAttack"]:::enemy
            ANEndAttack["AnimNotify_EnemyEndAttack"]:::enemy
            ANDodgeLaunch["AnimNotify_EnemyDodgeLaunch"]:::enemy
            ANDodgeEnd["AnimNotify_EnemyDodgeLaunchEnd"]:::enemy
        end
    end

    %% Engine Services
    subgraph "Engine Services"
        direction TB
        InputSystem["Input System"]:::engine
        PhysicsCollision["Physics/Collision"]:::engine
        AnimationBP["Animation Blueprint"]:::engine
        TimerManager["TimerManager"]:::engine
        NavMesh["NavMesh"]:::engine
        SoundSystem["Sound System"]:::engine
        Niagara["Niagara System"]:::engine
    end

    %% Game Mode
    MainGameModeBase["MainGameModeBase"]:::engine

    %% Relationships
    AMainCharacter -->|has| USkillComponent
    AMainCharacter -->|has| UMeleeCombatComponent
    AMainCharacter -->|spawns| Rifle
    AMainCharacter -->|spawns| MachineGun
    AMainCharacter -->|spawns| Cannon
    AMainCharacter -->|holds| Knife
    AMainCharacter -->|owns health| MainCharacterHealthComponent

    USkillComponent -->|spawn| AimSkill2Projectile
    USkillComponent -->|spawn| AimSkill3Projectile
    USkillComponent -->|spawn| Skill3Projectile

    AimSkill2Projectile -->|on hit ApplyDamage| AEnemy
    AimSkill3Projectile -->|on hit ApplyDamage| AEnemy
    Skill3Projectile -->|on hit ApplyDamage| AEnemy

    UMeleeCombatComponent -->|enable hit-boxes| AEnemy

    Rifle -->|LineTrace →| MainGameModeBase
    MachineGun -->|LineTrace →| MainGameModeBase
    Cannon -->|LineTrace →| MainGameModeBase

    MainGameModeBase -->|calls TakeDamage| AEnemy

    EnemyAIController -->|controls| AEnemy
    AEnemy -->|uses AnimInstance| EnemyAnimInstance
    EnemyAnimInstance -->|triggers| ANStartAttack
    EnemyAnimInstance -->|triggers| ANEndAttack
    EnemyAnimInstance -->|triggers| ANDodgeLaunch
    EnemyAnimInstance -->|triggers| ANDodgeEnd

    ANStartAttack -->|calls| AEnemy
    ANEndAttack -->|calls| AEnemy
    ANDodgeLaunch -->|calls| AEnemy
    ANDodgeEnd -->|calls| AEnemy

    %% Engine integrations
    InputSystem --> AMainCharacter
    PhysicsCollision --> Rifle
    PhysicsCollision --> UMeleeCombatComponent
    AnimationBP --> AMainCharacter
    AnimationBP --> EnemyAnimInstance
    TimerManager --> USkillComponent
    TimerManager --> EnemyAIController
    NavMesh --> EnemyAIController
    SoundSystem -->|via AnimNotify| PlaySlashEffectForward
    Niagara -->|via AnimNotify| PlaySlashEffectForward

    PlaySlashEffectForward -->|play effect| AMainCharacter
    PlaySlashEffectForward -->|play effect| AEnemy

    %% Click Events
    click AMainCharacter "https://github.com/littlehan3/unrealgame/blob/main/MainCharacter.cpp"
    click MainCharacterHealthComponent "https://github.com/littlehan3/unrealgame/blob/main/MainCharacterHealthComponent.cpp"
    click USkillComponent "https://github.com/littlehan3/unrealgame/blob/main/SkillComponent.cpp"
    click UMeleeCombatComponent "https://github.com/littlehan3/unrealgame/blob/main/MeleeCombatComponent.cpp"
    click Rifle "https://github.com/littlehan3/unrealgame/blob/main/Rifle.cpp"
    click MachineGun "https://github.com/littlehan3/unrealgame/blob/main/MachineGun.cpp"
    click Cannon "https://github.com/littlehan3/unrealgame/blob/main/Cannon.cpp"
    click Knife "https://github.com/littlehan3/unrealgame/blob/main/Knife.cpp"
    click MainGameModeBase "https://github.com/littlehan3/unrealgame/blob/main/MainGameModeBase.cpp"
    click AEnemy "https://github.com/littlehan3/unrealgame/blob/main/Enemy.cpp"
    click EnemyAIController "https://github.com/littlehan3/unrealgame/blob/main/EnemyAIController.cpp"
    click EnemyAnimInstance "https://github.com/littlehan3/unrealgame/blob/main/EnemyAnimInstance.cpp"
    click ANStartAttack "https://github.com/littlehan3/unrealgame/blob/main/AnimNotify_EnemyStartAttack.cpp"
    click ANEndAttack "https://github.com/littlehan3/unrealgame/blob/main/AnimNotify_EnemyEndAttack.cpp"
    click ANDodgeLaunch "https://github.com/littlehan3/unrealgame/blob/main/AnimNotify_EnemyDodgeLaunch.cpp"
    click ANDodgeEnd "https://github.com/littlehan3/unrealgame/blob/main/AnimNotify_EnemyDodgeLaunchEnd.cpp"
    click AimSkill2Projectile "https://github.com/littlehan3/unrealgame/blob/main/AimSkill2Projectile.cpp"
    click AimSkill3Projectile "https://github.com/littlehan3/unrealgame/blob/main/AimSkill3Projectile.cpp"
    click Skill3Projectile "https://github.com/littlehan3/unrealgame/blob/main/Skill3Projectile.cpp"
    click PlaySlashEffectForward "https://github.com/littlehan3/unrealgame/blob/main/PlaySlashEffectForward.cpp"
    click Locomotion "https://github.com/littlehan3/unrealgame/blob/main/Locomotion.Build.cs"

    %% Styles
    classDef player fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef gameplay fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20
    classDef enemy fill:#FFCDD2,stroke:#B71C1C,color:#B71C1C
    classDef projectile fill:#FFE0B2,stroke:#E65100,color:#E65100
    classDef engine fill:#E0E0E0,stroke:#424242,color:#424242
```
