# World Map Fantasy Naming & Hover System

This system adds fantasy-style names to your procedurally generated world map and provides interactive hover tooltips with highlighting.

## Features

### 🏰 Fantasy Names
- **Towns**: Names like "Ironhaven", "Dragonbridge", "Stormhold"
- **Villages**: Names like "Littlehollow", "Peaceful meadow", "Rabbit's end"
- **Forests**: Names like "Ancient Wildwood", "Whispering Grove", "Dark Thicket"
- **Water Bodies**: Names like "Crystal Lake", "Dragon Sea", "Silver Waters"

### 🖱️ Interactive Hover System
- **Tooltips**: Hover over named locations to see their names
- **Highlighting**: Primary highlight on hovered tile, secondary highlight on connected tiles
- **Smart Grouping**: Related tiles (like 3x3 towns) are grouped under one name

## Setup Instructions

### Automatic Setup (Recommended)
1. Add the `MapSceneSetup` component to any GameObject in your scene
2. Check "Auto Setup On Start" (enabled by default)
3. Play the scene - everything will be set up automatically!

### Manual Setup
1. Ensure your scene has a `WorldMapGenerator` component
2. Add a Camera with `MapCameraController` component
3. Create a GameObject with `TooltipSystem` and `UIDocument` components
4. Create a GameObject with `TileHoverHandler` component

## Components Overview

### 🎯 Core Components

#### `FantasyNameGenerator`
- Static class with name generation methods
- Generates unique fantasy names for different location types
- Prevents duplicate names within regions

#### `TileHoverHandler`
- Detects mouse hover over map tiles
- Groups tiles into named regions using flood-fill algorithms
- Handles highlighting of tiles and connected regions
- Manages name assignment to tiles

#### `TooltipSystem`
- Singleton pattern for global tooltip management
- Creates and positions tooltips dynamically
- Follows mouse cursor with smart positioning

#### `MapSceneSetup`
- Helper component for easy scene setup
- Context menu options for setup and map regeneration
- Automatically configures all required components

## Usage

### In Play Mode
1. **Move Camera**: Use WASD keys to move around the map
2. **Zoom**: Use mouse scroll wheel to zoom in/out
3. **View Names**: Hover mouse over towns, villages, forests, or water bodies
4. **See Connections**: Notice how related tiles (like town areas) highlight together

### Name Generation Rules
- **Towns**: Get 3x3 tile areas, all tiles share the same name
- **Villages**: Single tiles with individual names
- **Forests**: Connected forest regions share names (minimum 5 tiles)
- **Water Bodies**: Connected water areas share names (minimum 3 tiles)

### Highlighting System
- **Primary**: Yellow highlight on the exact tile you're hovering
- **Secondary**: Lighter yellow on connected tiles of the same named region
- **Materials**: Automatically created if not assigned in inspector

## Customization

### Name Lists
Edit the arrays in `FantasyNameGenerator.cs` to customize:
- `townPrefixes` / `townSuffixes` for town names
- `villagePrefixes` / `villageSuffixes` for village names
- `forestPrefixes` / `forestSuffixes` for forest names
- `waterPrefixes` / `lakeSuffixes` / `oceanSuffixes` for water names

### Highlight Materials
In the `TileHoverHandler` component inspector:
- `Highlight Material`: Primary highlight (default: yellow)
- `Secondary Highlight Material`: Connected tiles (default: light yellow)

### Minimum Region Sizes
In `TileHoverHandler.cs`, adjust these values:
- Forest regions: Change `>= 5` in `NameForests()` method
- Water regions: Change `>= 3` in `NameWaterBodies()` method

## Debugging

### Context Menu Options
Right-click on `MapSceneSetup` component:
- **Setup Scene**: Manually set up all required components
- **Regenerate Map**: Create a new map with new names

### Console Logs
The system provides debug output for:
- Scene setup progress
- Name generation statistics
- Component creation confirmations

### Public Methods
- `TileHoverHandler.GetTileName(int x, int y)`: Get the name of a specific tile
- `MapSceneSetup.RegenerateMap()`: Generate a new map programmatically

## Performance Notes

- Names are generated once when the map is created
- Hover detection uses Unity's physics raycast system
- Materials are cached to avoid creating duplicates
- Flood-fill algorithms run once during name assignment

## Troubleshooting

### No Tooltips Appearing
- Ensure `TooltipSystem` exists in scene with `UIDocument` component
- Check that tiles have colliders (auto-added by `WorldMapGenerator`)

### No Highlighting
- Verify `TileHoverHandler` component exists in scene
- Check that highlight materials are created/assigned

### Names Not Showing
- Ensure map generation completed before hovering
- Check console for name generation debug messages

## Future Enhancements

Potential additions you could implement:
- Road and river names
- Mountain range names
- Cultural/regional naming themes
- Name persistence between sessions
- Custom name import from files
