# leonz2019/autorun-rework architecture

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

- Interactive diagram: https://gitdiagram.com/leonz2019/autorun-rework
- Repository: https://github.com/leonz2019/autorun-rework

## Overview

##### Project Components
- Mod Configuration: The file config.cpp likely provides settings or parameters that the mod uses, so represent this as the configuration module.
- Script Functions Group: All the .sqf script files (e.g., fn_addEHKeybind.sqf, fn_onKeyDown.sqf, fn_onload.sqf, fn_checkDisplay.sqf, fn_getAnimation.sqf, fn_getStance.sqf, fn_updateStance.sqf, fn_updateSwimAnim.sqf, etc.) collectively form the core logic. Separate these functions into logical groups based on their purpose (for example, input handling, animation selection, stance switching, and display management).

##### Relationships and Data Flow
- Initialization: The “onload” function (fn_onload.sqf) is likely invoked when the mod activates, loading the configuration and initializing keybinds. Model this as the starting point.
- Stance & Animation Management: Based on the configuration and user input, functions such as fn_getStance.sqf, fn_updateStance.sqf, and fn_getAnimation.sqf determine the proper animation state. These, in turn, trigger visual changes (including swapping images from the “running” directory) and may call fn_updateSwimAnim.sqf and fn_swimToLand.sqf to manage swimming-to-land transitions.
- /Interface: The fn_checkDisplay.sqf function indicates there’s logic to manage or optionally bypass the custom display interface. Indicate a control flow connection between input components and display management.

##### Architectural Patterns and Design Principles
- Resource Integration: The images used for running animations are injected into the mod’s flow when the corresponding animation state is active. Represent these as a resource supplier that feeds into the visual update flow.

##### Technology and Integration
- Language/Framework: Emphasize that the scripting is done in SQF, designed to work seamlessly within the Arma engine.
- Dependencies: Mention the minimal requirements (mod “Zero” without CBA) and that this mod integrates directly with Arma’s event loop and animation system.

##### Detail
- Dependencies between these nodes; for instance, note how fn_getAnimation depends on the system’s current state determined by fn_getStance and the user’s key input.
- Loops or callbacks that maintain continuous state checking or animations.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Initialization & Configuration
    subgraph "Initialization & Configuration"
        config["Configuration Module – config.cpp"]:::config
        onload["Initialization Function – fn_onload.sqf"]:::init
        config --> onload
    end

    %% Input Handling
    subgraph "Input Handling"
        userInput["User Input(GameEvent)"]:::event
        keyDown["Key Down Handler – fn_onKeyDown.sqf"]:::input
        keyBind["Keybind Assignment – fn_addEHKeybind.sqf"]:::input
        userInput --> keyDown
        onload --> keyBind
        keyDown --> keyBind
    end

    %% Animation & Stance Management
    subgraph "Animation & Stance Management"
        getStance["Determine Stance – fn_getStance.sqf"]:::process
        updateStance["Update Stance – fn_updateStance.sqf"]:::process
        getAnim["Get Animation – fn_getAnimation.sqf"]:::process
        updateSwim["Update Swim Animation – fn_updateSwimAnim.sqf"]:::process
        swimToLand["Swim-To-Land Transition – fn_swimToLand.sqf"]:::process
        stopRunning["Stop Running – fn_stopRunning.sqf"]:::process
        keyBind --> getStance
        keyBind --> getAnim
        getStance --> updateStance
        getAnim --> updateSwim
        updateSwim --> swimToLand
        getAnim --> stopRunning
    end

    %% Display & Resource Assets
    subgraph "Display & Resource"
        display["Display/Interface Module – fn_checkDisplay.sqf"]:::display
        resources["Resource Assets (Running Animation Frames)"]:::resource
        updateStance --> display
        swimToLand --> display
        getAnim --> resources
    end

    %% Click Events
    click config "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/config.cpp"
    click onload "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_onload.sqf"
    click keyDown "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_onKeyDown.sqf"
    click keyBind "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_addEHKeybind.sqf"
    click getStance "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_getStance.sqf"
    click updateStance "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_updateStance.sqf"
    click getAnim "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_getAnimation.sqf"
    click updateSwim "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_updateSwimAnim.sqf"
    click swimToLand "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_swimToLand.sqf"
    click stopRunning "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_stopRunning.sqf"
    click display "https://github.com/leonz2019/autorun-rework/blob/main/leon_autorun/fn_checkDisplay.sqf"
    click resources "https://github.com/leonz2019/autorun-rework/tree/main/leon_autorun/running"

    %% Styles
    classDef config fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef init fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef input fill:#FFFF99,stroke:#CCCC00,stroke-width:2px;
    classDef process fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
    classDef display fill:#DDA0DD,stroke:#9932CC,stroke-width:2px;
    classDef resource fill:#F4A460,stroke:#CD853F,stroke-width:2px;
    classDef event fill:#FFEFD5,stroke:#FF7F50,stroke-width:2px;
```
