-- =============================================================================
-- Dialogue: Basic Show via Event System
-- =============================================================================
-- This example demonstrates how to show a simple dialogue box using the
-- EventBus "dialogue_show" event.
--
-- The DialogueSystem is a singleton (no ECS component needed). It listens
-- for "dialogue_show" events and displays the text directly.
--
-- Event payload parameters:
--   "text"           (string) - Narration text to display
--   "speaker"        (string) - Optional speaker name (shown above text)
--   "choices"        (table)  - Array of choice label strings (optional)
-- =============================================================================

-- ---------------------------------------------------------------------------
-- 1. Show a simple narration (no choices)
-- ---------------------------------------------------------------------------
-- Send a "dialogue_show" event with just text. The dialogue box will appear
-- and the player can click anywhere to dismiss it.

ecs.send_event("dialogue_show", {
    text = "Welcome to the world of World2!",
    speaker = "Narrator"
})

print("Sent basic narration dialogue")

-- ---------------------------------------------------------------------------
-- 2. Show dialogue with player choices
-- ---------------------------------------------------------------------------
-- When "choices" is provided as a table, the dialogue box shows
-- buttons instead of click-to-progress. The player must pick one.

ecs.send_event("dialogue_show", {
    text = "Where would you like to go?",
    speaker = "Guide",
    choices = { "The Forest", "The Village", "The Mountains" }
})

print("Sent dialogue with choices")

-- ---------------------------------------------------------------------------
-- 3. Show dialogue without a speaker name
-- ---------------------------------------------------------------------------

ecs.send_event("dialogue_show", {
    text = "A mysterious voice echoes through the chamber..."
})

print("Sent anonymous narration")

-- ---------------------------------------------------------------------------
-- 4. Multi-line dialogue (use \n for line breaks)
-- ---------------------------------------------------------------------------

ecs.send_event("dialogue_show", {
    text = "Greetings, traveler.\n\nI have been expecting you.\nThe prophecy spoke of your arrival.",
    speaker = "Elder Marcus"
})

print("Sent multi-line dialogue")

-- =============================================================================
-- Summary
-- =============================================================================
-- To show dialogue from Lua:
--   1. Call ecs.send_event("dialogue_show", { text = "...", speaker = "...", choices = { ... } })
--   2. Required: text = "The narration text"
--   3. Optional: speaker = "Speaker Name"
--   4. Optional: choices = { "Choice1", "Choice2", "Choice3" } (table of strings)
--   5. No ECS entity or component needed — DialogueSystem is a singleton
-- =============================================================================

print("Dialogue basic show examples completed!")
