# voxelboy/mobileuo architecture

> Architecture diagram of the GitHub repository voxelboy/mobileuo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/voxelboy/mobileuo
- Repository: https://github.com/voxelboy/mobileuo

## Overview

##### Main Components Overview
The system can be broken down into these key components:

a. Core Game Engine Layer:
- ClassicUO Integration (Assets/Scripts/ClassicUO/)
- XNA Emulation Layer (Assets/Scripts/XNAEmulator/)
- Unity Integration Components

b. Mobile-Specific Layer:
- Touch Input System
- Mobile UI Components
- Platform-Specific Features

c. Network Layer:
- Server Communication
- Protocol Handlers
- Encryption Systems

**[Mobile Device]**

- [Unity Engine Layer]
- UnityBatcher
- Mobile Input Handlers
- UI System

- [MobileUO Core]
- State Management
- BootState
- GameState
- ServerConfigurationState

- Client Runner
- User Preferences

- [ClassicUO Integration]
- Game Logic
- Rendering System
- Asset Management

- [XNA Emulation Layer]
- Graphics
- Input
- Audio

- [Network Layer]
- Packet Handlers
- Encryption
- Server Discovery

##### Key Relationships to Highlight

a. Data Flow:
- User Input → Mobile Input Handlers → Game Logic
- Game Logic → Rendering System → Unity Display
- Network Data → Packet Handlers → Game State

b. State Management:
- How the StateManager controls different game states
- Relationship between states and UI

##### Important Architectural Patterns

- MVC Pattern (evident in the UI implementation)
- State Pattern (for game state management)
- Observer Pattern (for event handling)
- Factory Pattern (for object creation)

##### Integration Points

Integration points between:
- Unity and ClassicUO
- Mobile platform and game logic
- Network layer and game state
- Input system and game logic

##### Additional Elements

Supporting elements:
- Version information
- System requirements
- External dependencies

##### Security Layer

Security-related components:
- Encryption systems
- Network security
- Data validation

Remember to maintain a balance between detail and clarity, focusing on the most important architectural elements while avoiding overwhelming detail in less critical areas.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Mobile["Mobile Device"]
        direction TB
        
        subgraph Unity["Unity Engine Layer"]
            direction TB
            UB["Unity Batcher"]:::unity
            MIH["Mobile Input Handlers"]:::unity
            UIS["UI System"]:::unity
        end

        subgraph Core["MobileUO Core"]
            direction TB
            CR["Client Runner"]:::core
            UP["User Preferences"]:::core
            
            subgraph SM["State Management"]
                direction TB
                BS["Boot State"]:::state
                GS["Game State"]:::state
                SCS["Server Configuration State"]:::state
            end
        end

        subgraph CUO["ClassicUO Integration"]
            direction TB
            GL["Game Logic"]:::classicuo
            RS["Rendering System"]:::classicuo
            AM["Asset Management"]:::classicuo
        end

        subgraph XNA["XNA Emulation Layer"]
            direction TB
            GFX["Graphics"]:::xna
            INP["Input"]:::xna
            AUD["Audio"]:::xna
        end

        subgraph NET["Network Layer"]
            direction TB
            NC["Net Client"]:::network
            PH["Packet Handlers"]:::network
            ENC["Encryption"]:::network
            SD["Server Discovery"]:::network
        end

        subgraph Mobile_Specific["Mobile-Specific Features"]
            direction TB
            TIS["Touch Input System"]:::mobile
            MUI["Mobile UI Components"]:::mobile
            PF["Platform Features"]:::mobile
        end
    end

    %% Relationships
    MIH --> GL
    TIS --> GL
    GL --> RS
    RS --> UB
    NC --> PH
    PH --> GS
    CR --> GL
    CR --> NC

    %% Click Events
    click UB "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/UnityBatcher.cs"
    click TIS "https://github.com/voxelboy/mobileuo/tree/master/Assets/Plugins/Lean/"
    click MUI "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/MobileJoystick.cs"
    click PF "https://github.com/voxelboy/mobileuo/blob/master/Assets/Editor/iOSPostBuild/iOSPostBuildScript.cs"
    click NC "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/ClassicUO/src/Network/NetClient.cs"
    click PH "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/ClassicUO/src/Network/PacketHandlers.cs"
    click ENC "https://github.com/voxelboy/mobileuo/tree/master/Assets/Scripts/ClassicUO/src/Network/Encryption/"
    click BS "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/States/BootState.cs"
    click GS "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/States/GameState.cs"
    click SCS "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/States/ServerConfigurationState.cs"
    click CR "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/ClientRunner.cs"
    click UP "https://github.com/voxelboy/mobileuo/blob/master/Assets/Scripts/UserPreferences.cs"
    click GL "https://github.com/voxelboy/mobileuo/tree/master/Assets/Scripts/ClassicUO/src/"
    click XNA "https://github.com/voxelboy/mobileuo/tree/master/Assets/Scripts/XNAEmulator/"

    %% Styling
    classDef unity fill:#4287f5
    classDef core fill:#42f554
    classDef classicuo fill:#f542aa
    classDef xna fill:#f5a142
    classDef network fill:#f5f242
    classDef mobile fill:#42f5f5
    classDef state fill:#b042f5
```
