# mav-666/snake architecture

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

- Interactive diagram: https://gitdiagram.com/mav-666/snake
- Repository: https://github.com/mav-666/snake

## Overview

##### Project Type and Purpose
- The project is a Unity-based 2D puzzle game (“Wire up”) where the player controls a snake-like entity (a “wiggling wire”) through various levels. The game involves connecting/disconnecting wires, physics-based interactions, and environmental puzzles.
- The README highlights that it is level-based (10 levels), with integrated controls for movement and connection/disconnection mechanics, clearly indicating gameplay mechanics tied to electricity and wiring.

##### Main Components
- Unity Engine & Core Systems:
– Unity’s component-based game objects, scenes, and project settings (ProjectSettings folder, URP render pipeline assets, etc.).
- Game Scenes & Levels:
– Levels/Scenes such as Level_0, Level_1, …, Menu, EndScreen, etc.
- Player Input & Control:
- Game Controllers & Managers:
– Components under Assets/Scripts/GameController (e.g., GameManager, Timer, CheckpointHandler, UI controllers) that govern game flow, state, and transitions.
- Gameplay Mechanics – Electricity & Wiring:
– Scripts under Assets/Scripts/Electricity including Battery, Connectable, Transmitter, Couplers, and various SignalHandlers.
– These components handle the core mechanics of connecting/disconnecting wires, electrical signals, and their effects on game objects.
- Specialized Systems:
– Parasite System: Managed through Assets/Scripts/Parasite – controlling special enemy or environmental obstacle behaviours.
– Snake Mechanics System: Found under Assets/Scripts/Snake – implementing the snake-like movement and interactions.
– Visual/Graphics & Animations: Under Assets/Scripts/Graphic and Animation subfolders, handling sprite animations, tween animations (via DOTween under Assets/Plugins/Demigiant), and effects.
- External Libraries / Plugins:
– Dreamteck Splines: A large portion of the Assets/Dreamteck directory indicates this is used for spline-based rendering/physics for wires, paths, or level elements.
– DOTween: For tweening animations and smoother transitions.
– TextMesh Pro: For UI text rendering.
- Assets & Resources Management:
– Art assets (Textures, Prefabs, Materials, Fonts), Audio files, and Resources that get integrated into scenes and control the visual/audio presentation.

##### Architectural Patterns and Design Principles
- The project follows a component-based design intrinsic to Unity. Each GameObject aggregates several MonoBehaviour scripts to provide specific features.
- Separation of concerns is visible – for example, input handling is separate from game logic (GameManager), and electrical behaviors are encapsulated in distinct assemblies (Assets/Scripts/Electricity).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Unity Core Systems"
        U1["Unity Engine"]:::unity
        U2["Project Settings"]:::unity
        U3["Scenes (Menu,EndScreen,Levels)"]:::unity
    end

    subgraph "Gameplay Modules"
        G1["Player Input System"]:::gameplay
        G2["Game Controllers & Managers"]:::gameplay
        G3["Electricity & Wiring System"]:::gameplay
        G4["Parasite System"]:::gameplay
        G5["Snake Mechanics System"]:::gameplay
    end

    subgraph "Visual Systems"
        V1["Animation & Graphics Controllers"]:::visuals
        V2["Assets & Resources Management"]:::assets
    end

    subgraph "External Libraries"
        E1["Dreamteck Splines"]:::external
        E2["DOTween"]:::external
        E3["TextMesh Pro"]:::external
    end

    U1 -->|"updates"| G2
    G1 -->|"commands"| G2
    G2 -->|"controls"| G3
    G2 -->|"manages"| G4
    G2 -->|"manages"| G5
    G2 -->|"sceneControl"| U3
    G3 -->|"triggers"| V1
    G3 -->|"splineUse"| E1
    E1 -->|"wireDisplay"| V1
    E2 -->|"tweening"| V1
    V2 -->|"feedsAssetsTo"| U3
    E3 -->|"uiSupport"| G2

    click U2 "https://github.com/mav-666/snake/tree/master/ProjectSettings"
    click U3 "https://github.com/mav-666/snake/tree/master/Assets/Scenes"
    click G1 "https://github.com/mav-666/snake/blob/master/Assets/PlayerInput.inputactions"
    click G2 "https://github.com/mav-666/snake/tree/master/Assets/Scripts/GameController"
    click G3 "https://github.com/mav-666/snake/tree/master/Assets/Scripts/Electricity"
    click G4 "https://github.com/mav-666/snake/tree/master/Assets/Scripts/Parasite"
    click G5 "https://github.com/mav-666/snake/tree/master/Assets/Scripts/Snake"
    click V1 "https://github.com/mav-666/snake/tree/master/Assets/Scripts/Graphic/Animation"
    click V2 "https://github.com/mav-666/snake/tree/master/Assets/Prefabs"
    click E1 "https://github.com/mav-666/snake/tree/master/Assets/Dreamteck/Splines"
    click E2 "https://github.com/mav-666/snake/tree/master/Assets/Plugins/Demigiant/DOTween"
    click E3 "https://github.com/mav-666/snake/tree/master/Assets/TextMesh Pro"

    classDef unity fill:#ffcc00,stroke:#000,stroke-width:2px;
    classDef gameplay fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef visuals fill:#66ccff,stroke:#000,stroke-width:2px;
    classDef external fill:#ff99cc,stroke:#000,stroke-width:2px;
    classDef assets fill:#ccccff,stroke:#000,stroke-width:2px;
```
