# mtfo-org/mtfo architecture

> Architecture diagram of the GitHub repository mtfo-org/mtfo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mtfo-org/mtfo
- Repository: https://github.com/mtfo-org/mtfo

## Overview

MTFO is an LSPDFR plugin that changes GTA V traffic behavior around an emergency response. On duty, it loads settings and starts a controller; while the player drives with lights and siren active, the controller coordinates vehicle yielding, intersection clearing and signal control, and oncoming braking. A separate around-player feature helps traffic pass a stationary or slow player. Road-position analysis supports lane-aware decisions, while shared plugin state tracks active tasks. The excerpts show core handlers and state, but not all controller branches or configuration fields, so uncertain internal links are omitted.

Main entry points: [`TrafficYieldController.cs`](https://github.com/mtfo-org/mtfo/blob/master/TrafficYieldController.cs) (Yield controller), [`Handlers/AroundPlayerHandler.cs`](https://github.com/mtfo-org/mtfo/blob/master/Handlers/AroundPlayerHandler.cs) (Around-player overtaking), [`Utility/Misc.cs`](https://github.com/mtfo-org/mtfo/blob/master/Utility/Misc.cs) (Plugin task state), [`EntryPoint.cs`](https://github.com/mtfo-org/mtfo/blob/master/EntryPoint.cs) (Plugin entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Plugin lifecycle"]
  node_entry["Plugin entry<br/>[EntryPoint.cs]"]
  node_settings["Settings<br/>[Misc.cs]"]
end

subgraph group_orchestration["Response coordination"]
  node_controller["Yield controller"]
end

subgraph group_traffic["Traffic behavior"]
  node_intersection["Intersection control"]
  node_oncoming["Oncoming braking"]
  node_yieldtasker["Lane yielding<br/>[YieldTasker.cs]"]
  node_around["Around-player overtaking"]
end

subgraph group_support["Road analysis and state"]
  node_roadpos["Road position<br/>[RoadPosition.cs]"]
  node_state[("Plugin task state<br/>[Misc.cs]")]
end

node_player(("Emergency responder"))
node_gta(("GTA V world"))
node_lspdfr(("LSPDFR"))

node_lspdfr -->|"duty events"| node_entry
node_entry -->|"loads on duty"| node_settings
node_entry -->|"starts / stops"| node_controller
node_player -->|"drives with siren"| node_gta
node_controller -->|"reads vehicle state"| node_gta
node_controller -->|"reads options"| node_settings
node_controller -->|"dispatches"| node_intersection
node_controller -->|"dispatches"| node_oncoming
node_controller -->|"manages tasks"| node_yieldtasker
node_controller -->|"coordinates logic"| node_around
node_intersection -->|"tasks traffic / lights"| node_gta
node_oncoming -->|"brakes vehicles"| node_gta
node_yieldtasker -->|"directs yielding"| node_gta
node_around -->|"routes around player"| node_gta
node_controller -->|"processes road position"| node_roadpos
node_yieldtasker -->|"calculates lanes"| node_roadpos
node_around -->|"calculates lanes"| node_roadpos
node_controller -->|"tracks active tasks"| node_state
node_intersection -->|"tracks tasked vehicles"| node_state
node_oncoming -->|"tracks braking vehicles"| node_state
node_around -->|"tracks overtake tasks"| node_state

click node_entry "https://github.com/mtfo-org/mtfo/blob/master/EntryPoint.cs"
click node_settings "https://github.com/mtfo-org/mtfo/blob/master/Utility/Misc.cs"
click node_controller "https://github.com/mtfo-org/mtfo/blob/master/TrafficYieldController.cs"
click node_intersection "https://github.com/mtfo-org/mtfo/blob/master/Handlers/IntersectionHandler.cs"
click node_oncoming "https://github.com/mtfo-org/mtfo/blob/master/Handlers/OncomingTrafficHandler.cs"
click node_yieldtasker "https://github.com/mtfo-org/mtfo/blob/master/Handlers/YieldTasker.cs"
click node_around "https://github.com/mtfo-org/mtfo/blob/master/Handlers/AroundPlayerHandler.cs"
click node_roadpos "https://github.com/mtfo-org/mtfo/blob/master/Utility/RoadPosition.cs"
click node_state "https://github.com/mtfo-org/mtfo/blob/master/Utility/Misc.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_settings toneBlue
class node_controller toneAmber
class node_intersection,node_oncoming,node_yieldtasker,node_around toneMint
class node_roadpos,node_state toneRose
class node_player,node_gta,node_lspdfr toneIndigo
```

## Components

### Plugin lifecycle

- [Plugin entry](https://github.com/mtfo-org/mtfo/blob/master/EntryPoint.cs): `EntryPoint.cs`
- [Settings](https://github.com/mtfo-org/mtfo/blob/master/Utility/Misc.cs): `Utility/Misc.cs`

### Response coordination

- [Yield controller](https://github.com/mtfo-org/mtfo/blob/master/TrafficYieldController.cs): `TrafficYieldController.cs`

### Traffic behavior

- [Intersection control](https://github.com/mtfo-org/mtfo/blob/master/Handlers/IntersectionHandler.cs): `Handlers/IntersectionHandler.cs`
- [Oncoming braking](https://github.com/mtfo-org/mtfo/blob/master/Handlers/OncomingTrafficHandler.cs): `Handlers/OncomingTrafficHandler.cs`
- [Lane yielding](https://github.com/mtfo-org/mtfo/blob/master/Handlers/YieldTasker.cs): `Handlers/YieldTasker.cs`
- [Around-player overtaking](https://github.com/mtfo-org/mtfo/blob/master/Handlers/AroundPlayerHandler.cs): `Handlers/AroundPlayerHandler.cs`

### Road analysis and state

- [Road position](https://github.com/mtfo-org/mtfo/blob/master/Utility/RoadPosition.cs): `Utility/RoadPosition.cs`
- [Plugin task state](https://github.com/mtfo-org/mtfo/blob/master/Utility/Misc.cs): `Utility/Misc.cs`

### Other components

- **Emergency responder**
- **GTA V world**
- **LSPDFR**

## Connections

- LSPDFR → Plugin entry: duty events
- Plugin entry → Settings: loads on duty
- Plugin entry → Yield controller: starts / stops
- Emergency responder → GTA V world: drives with siren
- Yield controller → GTA V world: reads vehicle state
- Yield controller → Settings: reads options
- Yield controller → Intersection control: dispatches
- Yield controller → Oncoming braking: dispatches
- Yield controller → Lane yielding: manages tasks
- Yield controller → Around-player overtaking: coordinates logic
- Intersection control → GTA V world: tasks traffic / lights
- Oncoming braking → GTA V world: brakes vehicles
- Lane yielding → GTA V world: directs yielding
- Around-player overtaking → GTA V world: routes around player
- Yield controller → Road position: processes road position
- Lane yielding → Road position: calculates lanes
- Around-player overtaking → Road position: calculates lanes
- Yield controller → Plugin task state: tracks active tasks
- Intersection control → Plugin task state: tracks tasked vehicles
- Oncoming braking → Plugin task state: tracks braking vehicles
- Around-player overtaking → Plugin task state: tracks overtake tasks
