# bluetortoise66/cookieman architecture

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

- Interactive diagram: https://gitdiagram.com/bluetortoise66/cookieman
- Repository: https://github.com/bluetortoise66/cookieman

## Overview

##### Project type and purpose
- From the file tree and minimal README, this is a Unity-based 2D grid/tile‐based game or prototype called “CookieMan.”
- It uses Unity’s Input System, custom grid management code, and Unity RuleTile assets (Path, Wall) to render a tile map in a test scene.

##### File structure
- Top‐level “Assets” directory holds all game content:
- Scenes/TestScene.unity
- Script/ – runtime C# scripts, subdivided into Grid and Ruletile
- Script/Grid/Editor – custom inspector/editor extensions (GridManagerEditor.cs)
- Tileset/ – Prefabs and RuleTile asset definitions
- InputSystem_Actions.inputactions – input mapping
- Sprites – probably spritesheet assets (empty in tree)
- Packages/manifest.json & lock: Unity Package Manager, includes Input System, possibly 2D Tilemap packages.
- ProjectSettings: Unity project configuration (physics, navmesh, graphics, etc.).

##### README
- No further architectural notes beyond project title. All inferences come from code and asset layout.

a. Main components
- Unity Engine Core (runtime host)
- Editor Extensions (GridManagerEditor)
- Input System (mapped actions)
- Grid Subsystem
– GameGrid (data model)
– GridObject (per‐cell state)
– GridManager (manager/orchestrator)
– GridRenderer (draws tiles based on RuleTile assets)
- RuleTile Assets
– Path Ruletile.asset + Wall Ruletile.asset
– Path.cs, Wall.cs (custom behavior)
- Scene & Prefabs
– TestScene.unity loads Prefab BaseMap & attaches GridManager, GridRenderer
- Unity Package Manager & ProjectSettings (configuration layer)

b. Relationships and interactions
- At Edit time: Editor Extensions → configure GridManager settings in Inspector
- At Play time: Player Input → Input System → GridManager triggers updates
- GridManager ↔ GameGrid (reads/writes grid data)
- GameGrid → instantiates/updates GridObject instances
- GridRenderer polls GameGrid & RuleTile assets to render sprites in the Scene
- RuleTile scripts (Path.cs/Wall.cs) define tile‐specific placement logic
- TestScene connects all components; Prefab BaseMap holds default grid layout

c. Architectural patterns and design principles
- MVC‐like separation:
– Model: GameGrid & GridObject
– View: GridRenderer + Unity Tilemap/Renderer
– Controller: GridManager + Input System
- Editor‐tooling for configuration: GridManagerEditor separates edit‐time from runtime.
- Asset‐driven design: RuleTile assets define map logic without code changes.

d. Key technologies and frameworks
- Unity 2020+ (2D Tilemap, ScriptableObjects for RuleTiles)
- Unity Input System (Assets/InputSystem_Actions.inputactions)
- C# custom Editor scripts
- Unity Package Manager for dependency management

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Editor Tools
    subgraph "Editor Tools"
        GMEditor["GridManagerEditor"]:::code
    end

    %% Runtime Flow
    subgraph "Runtime Flow"
        Player["Player Input"]:::external
        subgraph "Controller"
            InputSystem["Input System"]:::asset
            GridManager["GridManager"]:::code
        end
        subgraph "Model"
            GameGrid["GameGrid"]:::code
            GridObject["GridObject"]:::code
        end
        subgraph "View"
            GridRenderer["GridRenderer"]:::code
        end
        Screen["Game Screen"]:::engine
    end

    %% Assets
    subgraph "Assets"
        TestScene["TestScene.unity"]:::asset
        BaseMap["BaseMap Prefab"]:::asset
        subgraph "RuleTile Assets"
            PathAsset["Path Ruletile"]:::asset
            WallAsset["Wall Ruletile"]:::asset
            PathScript["Path.cs"]:::code
            WallScript["Wall.cs"]:::code
        end
    end

    %% Configuration
    subgraph "Configuration"
        Packages["manifest.json"]:::config
        ProjectSettings["ProjectSettings.asset"]:::config
    end

    %% Engine Core
    EngineCore["Unity Engine Core"]:::engine

    %% Relationships
    GMEditor -->|"configures"| GridManager
    Player -->|"input events"| InputSystem
    InputSystem -->|"triggers"| GridManager
    GridManager -->|"reads/writes"| GameGrid
    GameGrid -->|"creates/updates"| GridObject
    GridRenderer -->|"polls"| GameGrid
    GridRenderer -->|"renders"| Screen
    GridManager -->|"notifies"| GridRenderer

    TestScene --> BaseMap
    TestScene --> GridManager
    TestScene --> GridRenderer
    BaseMap -->|"default layout"| GameGrid

    GridRenderer --> PathAsset
    GridRenderer --> WallAsset
    PathScript --> PathAsset
    WallScript --> WallAsset

    Packages --> EngineCore
    ProjectSettings --> EngineCore
    TestScene --> EngineCore
    Player --> EngineCore

    %% Click Events
    click GMEditor "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Script/Grid/Editor/GridManagerEditor.cs"
    click InputSystem "https://github.com/bluetortoise66/cookieman/blob/main/Assets/InputSystem_Actions.inputactions"
    click GameGrid "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Script/Grid/GameGrid.cs"
    click GridObject "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Script/Grid/GridObject.cs"
    click GridManager "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Script/Grid/GridManager.cs"
    click GridRenderer "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Script/Grid/GridRenderer.cs"
    click PathAsset "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Tileset/Path Ruletile.asset"
    click WallAsset "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Tileset/Wall Ruletile.asset"
    click PathScript "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Script/Ruletile/Path.cs"
    click WallScript "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Script/Ruletile/Wall.cs"
    click TestScene "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Scenes/TestScene.unity"
    click BaseMap "https://github.com/bluetortoise66/cookieman/blob/main/Assets/Tileset/BaseMap.prefab"
    click Packages "https://github.com/bluetortoise66/cookieman/blob/main/Packages/manifest.json"
    click ProjectSettings "https://github.com/bluetortoise66/cookieman/blob/main/ProjectSettings/ProjectSettings.asset"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#0000FF,color:#000000
    classDef asset fill:#90EE90,stroke:#008000,color:#000000
    classDef engine fill:#FFA500,stroke:#CC8400,color:#000000
    classDef config fill:#D3D3D3,stroke:#A9A9A9,color:#000000
    classDef external fill:#F5DEB3,stroke:#DAA520,color:#000000
```
