Tree("Root") {
    Composite(Sequence) {
        BTC.InitializeSpeechManager()
        //BTC.SetSpeechRecognitionLanguage("it-IT")

        //RunTree("32_Grotto_Story_B_Grotto_Intro")

        RunTree("32_Grotto_Kueche_Intro")
        RunTree("32_Grotto_Kueche_Zwiebeln_schneiden")
        RunTree("32_Grotto_Kueche_alles_gefunden")
        //RunTree("32_Grotto_Kueche_Kochen_Anzahl")
        //RunTree("32_Grotto_Kueche_Zusammen_Kochen")
        //RunTree("32_Grotto_Im_Grotto_Essen_Intro")
        
    }
}

Tree("32_Grotto_Story_B_Grotto_Intro") {
    Composite(Sequence) {
        BTC.SynthesizeText("So, da wären wir. Willkommen in Nonnas Grotto! Ich mag die Busfahrt hier hoch. Und ich mag auch diese Aussicht. Hast du schon ein paar Fotos gemacht?")
        BTC.SpeechOutputEnded()
        BTC.Wait(5)

        BTC.SynthesizeText("Hast du gewusst, dass auch im Kanton Graubünden italienisch gesprochen wird?")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Intro.3")
        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Intro.4")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        BTC.SynthesizeText("Sogar in 4 Tälern: hier im Val Mesolcina, im Val Calanca, im Val Bregaglio und im Valposchiavo. Oh, die Nonna ruft an!")
        BTC.SpeechOutputEnded()

        // --- Story B Grotto - Telefonat ---
        BTC.SynthesizeText("Hallo Nonna.")
        BTC.SpeechOutputEnded()

        BTC.SynthesizeText("Hallo Francesca. Bist du schon angekommen?")
        BTC.SpeechOutputEnded()

        BTC.SynthesizeText("Ja, wir sind soeben angekommen. Ich bin nicht alleine heute, ich habe noch jemanden mitgebracht.")
        BTC.SpeechOutputEnded()

        BTC.SynthesizeText("Oh, wie schön, wer ist es denn?")
        BTC.SpeechOutputEnded()

        BTC.SynthesizeText("Stell dich doch gleich selbst vor.")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Telefonat.6")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        // --- Story B Grotto - Begruessung ---
        BTC.SynthesizeText("Hallo, willkommen im Grotto. Wie war denn die Reise?")
        BTC.SpeechOutputEnded()

        // --- Story B Grotto - Antwort_Reise ---
        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Reise.1")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        BTC.SynthesizeText("Wie gefällt dir denn das Misox?")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Reise.5")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        BTC.SynthesizeText("Ich möchte nirgends sonst auf der Welt leben. Möchtest du denn mit Francesca in der Küche etwas aushelfen oder wartest du im Garten auf sie?")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Sequence) {
                BTC.UserStartedSpeechInput()
                
                Composite(Selector) {
                    // -- Selector 1: Intent erkannt
                    Composite(Sequence) {
                        BTC.SpeechIntentRecognized()

                        // Intent erkannt
                        Composite(Race) {
                            Composite(Sequence) {
                                BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
                                BTC.ClearPossbileSpeechIntents()
                                RunTree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Kueche")
                            }
                            Composite(Sequence) {
                                BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
                                BTC.ClearPossbileSpeechIntents()
                                RunTree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Grotto")
                            }
                        }
                    }

                    // -- Selector 2: Intent nicht erkannt
                    Composite(Sequence) {
                        // --- Story B Grotto - Nachfrage Nonna Grotto ---
                        // SpeechIntentRecognized Failed: kein Intent erkannt
                        BTC.SynthesizeText("Was wolltest du sagen? Ich habe es nicht verstanden. Möchtest du mithelfen oder lieber im Garten warten?")
                        BTC.SpeechOutputEnded()
                
                        BTC.StartSpeechIntentRecognition()
                        Composite(Race) {
                            Composite(Sequence) {
                                BTC.UserStartedSpeechInput()
                                BTC.SpeechIntentRecognized()

                                Composite(Race) {
                                    Composite(Sequence) {
                                        BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
                                        BTC.ClearPossbileSpeechIntents()
                                        RunTree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Kueche")
                                    }
                                    Composite(Sequence) {
                                        BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
                                        BTC.ClearPossbileSpeechIntents()
                                        RunTree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Grotto")
                                    }
                                }
                            }

                            Composite(Sequence) {
                                BTC.Wait(5)
                                BTC.CompareUserSpeechInputStarted(false)
                                BTC.AbortSpeechEventListener()
                                BTC.StopSpeechIntentRecognition()
                                BTC.ClearPossbileSpeechIntents()

                                BTC.CompareUserSpeechInputStarted(true)
                            }
                        }
                    }

                    // Selector 3: Fallback Button
                    Composite(Sequence) {
                        Composite(Marathon) {
                            BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Küche")
                            BTC.Show("GO.HANDMENU.Option1Button")
                            BTC.Set("TextMeshPro.HANDMENU.Option2Button", "text", "Garten")
                            BTC.Show("GO.HANDMENU.Option2Button")
                        }

                        Composite(Race) {
                            Composite(Sequence) {
                                // Kueche
                                BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
                                BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option2Button")
                                BTC.Hide("GO.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option2Button")
                                RunTree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Kueche")
                            }
                            Composite(Sequence) {
                                // Garten
                                BTC.Run("NamedEventTrigger.HANDMENU.Option2Button")
                                BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option2Button")
                                RunTree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Grotto")
                            }
                        }
                    }
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.AbortSpeechEventListener()
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()

                // --- Bilder Bergell ---
                //BTC.Run("LoadScene.NEXT.35Slideshow")
            }
        }
    }
}

Tree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Kueche") {
// --- Story B Grotto - Antwort Nonna Kueche ---
    Composite(Sequence) {
        BTC.SynthesizeText("Oh, das ist wunderbar, vielen Dank! Anschliessend seid ihr selbstverständlich zum Essen eingeladen.")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Kueche.2")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        // --- Story B Grotto - Outro ---
        BTC.SynthesizeText("Francesca, der Risotto sollte gekocht werden, du weisst ja, was zu tun ist, oder? Das Rezept habe ich euch hingelegt. Also dann, wir sehen uns später sicher noch. Ich bin ja so froh, dass ihr zwei eingesprungen seid! Ciao!")
        BTC.SpeechOutputEnded()

        BTC.SynthesizeText("Ciao Nonna.")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Outro.3")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        RunTree("32_Grotto_Kueche_Intro")
    }
}

Tree("32_Grotto_Story_B_Grotto_Antwort_Nonna_Grotto") {
// --- Story B Grotto - Antwort Nonna Grotto ---
    Composite(Sequence) {
        BTC.SynthesizeText("Okay gut, mach es dir gemütlich. Hast du etwas zum Lesen dabei?")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.2")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        BTC.SynthesizeText("Prima, viel Spass noch und dann guten Appetit!")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.6")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        BTC.SynthesizeText("Wenn du magst, kannst du in der Zwischenzeit auch meine Fotos aus dem Bergell anschauen, die ich kürzlich gemacht habe. Auf dem Tisch ist eine VR-Brille. Damit kannst du die Bilder in 3D anschauen.")
        BTC.SpeechOutputEnded()

        // Option VR Brille Bilder und Buch anschauen fehlt
        BTC.Wait(10)

        // Szenenuebergang fehlt
        BTC.SynthesizeText("So, das war anstrengend, aber ich glaube, der Risotto ist gut geworden. Was hast du in dieser Zeit gemacht?")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.11")
        BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.12")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }

        BTC.SynthesizeText("Das klingt gut. So, nun habe ich aber Hunger. Lass uns was bestellen.")
        BTC.SpeechOutputEnded()
        RunTree("32_Grotto_Im_Grotto_Essen_Intro")
    }
}

Tree("32_Grotto_Kueche_Intro") {
// --- Kueche - Intro ---
    Composite(Sequence) {
        // Initialization
        BTC.Run("StudioEventEmitter.STATIC.Ambi3D")

        BTC.Run("AudioSource.AUDIO.Kueche1FIntro")

        // Schuerze greifen
        BTC.Run("GO/NamedGrabEvent.INTERACTABLES.Schuerze")
        BTC.Hide("GO/NamedGrabEvent.INTERACTABLES.Schuerze")

        BTC.SynthesizeText("Lies mir bitte das Rezept vor.")
        BTC.SpeechOutputEnded()

        BTC.AddPossbileSpeechIntent("Kueche.Intro.3")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Selector) {
                Composite(Sequence) {
                    BTC.UserStartedSpeechInput()
                    BTC.SpeechIntentRecognized()
                    BTC.ClearPossbileSpeechIntents()
                }

                // Intent nicht erkannt
                Composite(Sequence) {
                    Decorator(Inverter) {
                        BTC.CompareUserSpeechInputStarted(false)
                    }
                    BTC.ClearPossbileSpeechIntents()
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.AbortSpeechEventListener()
                BTC.StopSpeechIntentRecognition()

                BTC.SynthesizeText("Was brauchen wir? Bitte lies mir das Rezept vor.")
                BTC.SpeechOutputEnded()

                BTC.StartSpeechIntentRecognition()

                Composite(Race) {
                    // -- Race 1: User sagt etwas
                    Composite(Selector) {
                        Composite(Sequence) {
                            BTC.UserStartedSpeechInput()
                            BTC.SpeechIntentRecognized()
                            BTC.ClearPossbileSpeechIntents()
                        }

                        // Intent nicht erkannt
                        Composite(Sequence) {
                            BTC.ClearPossbileSpeechIntents()
                        }
                    }

                    // -- Race 2: User sagt nichts
                    Composite(Sequence) {
                        BTC.Wait(5)
                        BTC.CompareUserSpeechInputStarted(false)
                        BTC.AbortSpeechEventListener()
                        BTC.StopSpeechIntentRecognition()
                        BTC.ClearPossbileSpeechIntents()
                    }
                }
            }
        }

        BTC.Run("AudioSource.AUDIO.Kueche3FIntro")

        // Pilze leuchten
        // momentan nur 1 Pilz
        BTC.Enable("NamedOutline.INTERACTABLES.Pilz01")

        Composite(Race) {
            Composite(Sequence) {
                // Pilze ins Wasser Glas legen
                BTC.Set("Collider.INTERACTABLES.GlassWasserTrigger", "otherTag", "Steinpilze")
                BTC.Run("Collider.INTERACTABLES.GlassWasserTrigger")
            }
            Composite(Sequence) {
                // Keine Reaction
                BTC.Wait(5)
                // --- Kueche - Steinpilze Hilfe ---
                BTC.Run("AudioSource.AUDIO.Kueche1FSteinpilze")
                // Pilze ins Wasser Glas legen
                BTC.Run("Collider.INTERACTABLES.GlassWasserTrigger")
            }
        }
        BTC.Disable("NamedOutline.INTERACTABLES.Pilz01")
    } 
}

Tree("32_Grotto_Kueche_Zwiebeln_schneiden") {
// --- Kueche - Zwiebeln schneiden ---
    Composite(Sequence) {
        BTC.SynthesizeText("Nun kannst du die Zwiebeln schneiden.")
        BTC.SpeechOutputEnded()

        // Zwiebeln schneiden
        BTC.Set("Collider.INTERACTABLES.ZwiebelTrigger", "otherTag", "Messer")
        BTC.Run("Collider.INTERACTABLES.ZwiebelTrigger")
        Composite(Marathon) {
            BTC.Run("StudioEventEmitter.INTERACTABLES.ZwiebelSchneiden")
            BTC.Hide("GO.INTERACTABLES.Zwiebel01")
            BTC.Show("GO.INTERACTABLES.GeschnitteneZwiebe")
        }
        
        BTC.SynthesizeText("Bitte suche nun die anderen Zutaten zusammen. Ich räume in der Zwischenzeit ein bisschen auf.")
        BTC.SpeechOutputEnded()

        // Zutaten leuchten
        Composite(Marathon) {
            BTC.Enable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Bouillon")
            BTC.Show("GO/NamedSocketEvent.SOCKETS.BouillonSocket")
            BTC.Enable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Weisswein")
            BTC.Show("GO/NamedSocketEvent.SOCKETS.WeissweinSocket")
            BTC.Enable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Risotto")
            BTC.Show("GO/NamedSocketEvent.SOCKETS.RisottoSocket")
            BTC.Enable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Olivenoel")
            BTC.Show("GO/NamedSocketEvent.SOCKETS.OlivenoelSocket")
            BTC.Enable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Pfeffer")
            BTC.Show("GO/NamedSocketEvent.SOCKETS.PfefferSocket")
            BTC.Enable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Salz")
            BTC.Show("GO/NamedSocketEvent.SOCKETS.SalzSocket")
        }
        

        // Zutaten auf die Arbeitsflaeche legen mithilfe Sockets
        Composite(Marathon) {
            // Risotto
            Composite(Sequence) {
                //BTC.GetKeyDown("Return")
                BTC.SetBool("RisottoIsSnapped", false)

                Composite(Race) {
                    Composite(Sequence) {
                        // Success
                        BTC.Run("GO/NamedSocketEvent.SOCKETS.RisottoSocket")
                        //BTC.GetKeyDown("Return")
                        BTC.SetBool("RisottoIsSnapped")
                        BTC.Disable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Risotto")
                    }

                    Decorator(Repeat) {
                        Composite(Sequence) {
                            // Fail
                            //BTC.GetKeyDown("Space")
                            BTC.ListenToEvent("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Risotto")
                            BTC.Wait(1)
                            BTC.CompareBool("RisottoIsSnapped", false)

                            // Objekt geht zurueck
                            BTC.SetPosition("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Risotto", -6.824, 1.335, -18.8996)

                            BTC.SynthesizeText("Das hast du an den falschen Ort gestellt.")
                            BTC.SpeechOutputEnded()
                        }
                    }
                }
            } // Sequence

            // Salz
            Composite(Sequence) {
                BTC.SetBool("SalzIsSnapped", false)

                Composite(Race) {
                    Composite(Sequence) {
                        // Success
                        BTC.Run("GO/NamedSocketEvent.SOCKETS.SalzSocket")
                        BTC.SetBool("SalzIsSnapped")
                        BTC.Disable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Salz")
                    }

                    Decorator(Repeat) {
                        Composite(Sequence) {
                            // Fail
                            BTC.ListenToEvent("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Salz")
                            BTC.Wait(1)
                            BTC.CompareBool("SalzIsSnapped", false)

                            // Objekt geht zurueck
                            BTC.SetPosition("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Salz", -6.607, 1.321, -18.8996)

                            BTC.SynthesizeText("Das hast du an den falschen Ort gestellt.")
                            BTC.SpeechOutputEnded()
                        }
                    }
                }
            } // Sequence

            // Pfeffer
            Composite(Sequence) {
                BTC.SetBool("PfefferIsSnapped", false)

                Composite(Race) {
                    Composite(Sequence) {
                        // Success
                        BTC.Run("GO/NamedSocketEvent.SOCKETS.PfefferSocket")
                        BTC.SetBool("PfefferIsSnapped")
                        BTC.Disable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Pfeffer")
                    }

                    Decorator(Repeat) {
                        Composite(Sequence) {
                            // Fail
                            BTC.ListenToEvent("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Pfeffer")
                            BTC.Wait(1)
                            BTC.CompareBool("PfefferIsSnapped", false)

                            // Objekt geht zurueck
                            BTC.SetPosition("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Pfeffer", -6.686, 1.321, -18.8996)

                            BTC.SynthesizeText("Das hast du an den falschen Ort gestellt.")
                            BTC.SpeechOutputEnded()
                        }
                    }
                }
            } // Sequence

            // Weisswein
            Composite(Sequence) {
                BTC.SetBool("WeissweinIsSnapped", false)

                Composite(Race) {
                    Composite(Sequence) {
                        // Success
                        BTC.Run("GO/NamedSocketEvent.SOCKETS.WeissweinSocket")
                        BTC.SetBool("WeissweinIsSnapped")
                        BTC.Disable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Weisswein")
                    }

                    Decorator(Repeat) {
                        Composite(Sequence) {
                            // Fail
                            BTC.ListenToEvent("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Weisswein")
                            BTC.Wait(1)
                            BTC.CompareBool("WeissweinIsSnapped", false)

                            // Objekt geht zurueck
                            BTC.SetPosition("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Weisswein", -6.58, 1.451, -19.0233)

                            BTC.SynthesizeText("Das hast du an den falschen Ort gestellt.")
                            BTC.SpeechOutputEnded()
                        }
                    }
                }
            } // Sequence

            // Bouillon
            Composite(Sequence) {
                BTC.SetBool("BouillonIsSnapped", false)

                Composite(Race) {
                    Composite(Sequence) {
                        // Success
                        BTC.Run("GO/NamedSocketEvent.SOCKETS.BouillonSocket")
                        BTC.SetBool("BouillonIsSnapped")
                        BTC.Disable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Bouillon")
                    }

                    Decorator(Repeat) {
                        Composite(Sequence) {
                            // Fail
                            BTC.ListenToEvent("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Bouillon")
                            BTC.Wait(1)
                            BTC.CompareBool("BouillonIsSnapped", false)

                            // Objekt geht zurueck
                            BTC.SetPosition("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Bouillon", -6.947, 1.402, -18.995)

                            BTC.SynthesizeText("Das hast du an den falschen Ort gestellt.")
                            BTC.SpeechOutputEnded()
                        }
                    }
                }
            } // Sequence

            // Olivenoel
            Composite(Sequence) {
                BTC.SetBool("OlivenoelIsSnapped", false)

                Composite(Race) {
                    Composite(Sequence) {
                        // Success
                        BTC.Run("GO/NamedSocketEvent.SOCKETS.OlivenoelSocket")
                        BTC.SetBool("OlivenoelIsSnapped")
                        BTC.Disable("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Olivenoel")
                    }

                    Decorator(Repeat) {
                        Composite(Sequence) {
                            // Fail
                            BTC.ListenToEvent("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Olivenoel")
                            BTC.Wait(1)
                            BTC.CompareBool("OlivenoelIsSnapped", false)

                            // Objekt geht zurueck
                            BTC.SetPosition("GO/NamedGrabEvent/NamedOutline.INTERACTABLES.Olivenoel", -6.752, 1.449, -19.024)

                            BTC.SynthesizeText("Das hast du an den falschen Ort gestellt.")
                            BTC.SpeechOutputEnded()
                        }
                    }
                }
            } // Sequence
        }

        BTC.Wait(1)

        Composite(Marathon) {
            BTC.Hide("GO/NamedSocketEvent.SOCKETS.OlivenoelSocket")
            BTC.Hide("GO/NamedSocketEvent.SOCKETS.BouillonSocket")
            BTC.Hide("GO/NamedSocketEvent.SOCKETS.WeissweinSocket")
            BTC.Hide("GO/NamedSocketEvent.SOCKETS.PfefferSocket")
            BTC.Hide("GO/NamedSocketEvent.SOCKETS.SalzSocket")
            BTC.Hide("GO/NamedSocketEvent.SOCKETS.RisottoSocket")
        }
       
    }
}


Tree("32_Grotto_Kueche_alles_gefunden") {
// --- Kueche - alles gefunden ---
    Composite(Sequence) {
        BTC.SynthesizeText("Super, du hast alles gefunden. Bitte gib nun etwas Olivenöl in den Topf.")
        BTC.SpeechOutputEnded()

        // Oel in Topf geben - ToDo: Particle Trigger
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Olivenoel")
        BTC.Run("Collider.INTERACTABLES.Topf")
        BTC.Run("AudioSource.AUDIO.Kueche2Fallesgefun")

        // Herd anstellen - ToDo: Handling in Story?
        BTC.Run("NamedGrabEvent.STATIC.Herdschalter")
        BTC.Run("StudioEventEmitter.STATIC.HerdplatteAnstelle")

        // Zwiebeln in Topf geben
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Zwiebeln")
        BTC.Run("Collider.INTERACTABLES.Topf")
        BTC.Run("StudioEventEmitter.INTERACTABLES.ZwiebelnInTopf")
        
        BTC.Run("AudioSource.AUDIO.Kueche3Fallesgefun")

        // Frage beantworten
        BTC.AddPossbileSpeechIntent("Kueche.alles_gefunden.4")
        BTC.AddPossbileSpeechIntent("Kueche.alles_gefunden.6")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Sequence) {
                BTC.UserStartedSpeechInput()
                
                Composite(Selector) {
                    // -- Selector 1: Intent erkannt
                    Composite(Sequence) {
                        BTC.SpeechIntentRecognized()

                        // Intent erkannt
                        Composite(Race) {
                            Composite(Sequence) {
                                BTC.CompareIntentID("Kueche.alles_gefunden.4")
                                BTC.ClearPossbileSpeechIntents()
                                RunTree("32_Grotto_Kueche_Interesse_Kochen")
                            }
                            Composite(Sequence) {
                                BTC.CompareIntentID("Kueche.alles_gefunden.6")
                                BTC.ClearPossbileSpeechIntents()
                                RunTree("32_Grotto_Kueche_Zusammen_Kochen")
                            }
                        }
                    }

                    // -- Selector 2: Intent nicht erkannt
                    Composite(Sequence) {
                        BTC.ClearPossbileSpeechIntents()

                        // Fallback Button
                        Composite(Marathon) {
                            BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Ja")
                            BTC.Show("GO.HANDMENU.Option1Button")
                            BTC.Set("TextMeshPro.HANDMENU.Option2Button", "text", "Nein")
                            BTC.Show("GO.HANDMENU.Option2Button")
                        }

                        Composite(Race) {
                            Composite(Sequence) {
                                // Ja
                                BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
                                BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option2Button")
                                BTC.Hide("GO.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option2Button")
                                RunTree("32_Grotto_Kueche_Interesse_Kochen")
                            }
                            Composite(Sequence) {
                                // Nein
                                BTC.Run("NamedEventTrigger.HANDMENU.Option2Button")
                                BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option2Button")
                                RunTree("32_Grotto_Kueche_Zusammen_Kochen")
                            }
                        }
                    }
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.AbortSpeechEventListener()
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()

                // Fallback Button
                Composite(Marathon) {
                    BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Ja")
                    BTC.Show("GO.HANDMENU.Option1Button")
                    BTC.Set("TextMeshPro.HANDMENU.Option2Button", "text", "Nein")
                    BTC.Show("GO.HANDMENU.Option2Button")
                }

                Composite(Race) {
                    Composite(Sequence) {
                        // Ja
                        BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
                        BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option2Button")
                        BTC.Hide("GO.HANDMENU.Option1Button")
                        BTC.Hide("GO.HANDMENU.Option2Button")
                        RunTree("32_Grotto_Kueche_Interesse_Kochen")
                    }
                    Composite(Sequence) {
                        // Nein
                        BTC.Run("NamedEventTrigger.HANDMENU.Option2Button")
                        BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option1Button")
                        BTC.Hide("GO.HANDMENU.Option1Button")
                        BTC.Hide("GO.HANDMENU.Option2Button")
                        RunTree("32_Grotto_Kueche_Zusammen_Kochen")
                    }
                }
            }
        }        
    }
}

Tree("32_Grotto_Kueche_Interesse_Kochen") {
// --- Kueche - Interesse Kochen ---
    Composite(Sequence) {
        BTC.Run("AudioSource.AUDIO.Kueche1FInteresseK")
        // ToDo: Freie Antwort als Speech Input
        BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Lasagne")
        BTC.Show("GO.HANDMENU.Option1Button")
        BTC.SetBool("32_Grotto_Kueche_Interesse_Kochen_Button_Clicked", false)

        Composite(Race) {
            Composite(Sequence) {
                // Lieblingsessen nennen
                BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
                BTC.SetBool("32_Grotto_Kueche_Interesse_Kochen_Button_Clicked")
                BTC.Hide("GO.HANDMENU.Option1Button")
                RunTree("32_Grotto_Kueche_Kochen_Anzahl")
            }
            Composite(Sequence) {
                // keine Antwort
                BTC.Wait(5)
                BTC.CompareBool("32_Grotto_Kueche_Interesse_Kochen_Button_Clicked", false)
                BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option1Button")
                BTC.Hide("GO.HANDMENU.Option1Button")
                RunTree("32_Grotto_Kueche_Zusammen_Kochen")
            }
        }
    }
}

Tree("32_Grotto_Kueche_Kochen_Anzahl") {
// --- Kueche - Kochen Anzahl ---
    Composite(Sequence) {
        BTC.Run("AudioSource.AUDIO.Kueche1FKochenAnza")

        // Frage beantworten
        BTC.AddPossbileSpeechIntent("Kueche.Kochen_Anzahl.2")
        BTC.AddPossbileSpeechIntent("Kueche.Kochen_Anzahl.4")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Sequence) {
                BTC.UserStartedSpeechInput()
                
                Composite(Selector) {
                    // -- Selector 1: Intent erkannt
                    Composite(Sequence) {
                        BTC.SpeechIntentRecognized()

                        // Intent erkannt
                        Composite(Race) {
                            Composite(Sequence) {
                                BTC.CompareIntentID("Kueche.Kochen_Anzahl.2")
                                BTC.ClearPossbileSpeechIntents()
                                RunTree("32_Grotto_Kueche_Selbststaendig_Kochen")
                            }
                            Composite(Sequence) {
                                BTC.CompareIntentID("Kueche.Kochen_Anzahl.4")
                                BTC.ClearPossbileSpeechIntents()
                                RunTree("32_Grotto_Kueche_Zusammen_Kochen")
                            }
                        }
                    }

                    // -- Selector 2: Intent nicht erkannt
                    Composite(Sequence) {
                        BTC.ClearPossbileSpeechIntents()

                        // Fallback Button
                        Composite(Marathon) {
                            BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "sehr oft")
                            BTC.Show("GO.HANDMENU.Option1Button")
                            BTC.Set("TextMeshPro.HANDMENU.Option2Button", "text", "selten")
                            BTC.Show("GO.HANDMENU.Option2Button")
                        }

                        Composite(Race) {
                            Composite(Sequence) {
                                // sehr oft
                                BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
                                BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option2Button")
                                BTC.Hide("GO.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option2Button")
                                RunTree("32_Grotto_Kueche_Selbststaendig_Kochen")
                            }
                            Composite(Sequence) {
                                // selten
                                BTC.Run("NamedEventTrigger.HANDMENU.Option2Button")
                                BTC.AbortEventListener("NamedEventTrigger.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option1Button")
                                BTC.Hide("GO.HANDMENU.Option2Button")
                                RunTree("32_Grotto_Kueche_Zusammen_Kochen")
                            }
                        }
                    }
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.AbortSpeechEventListener()
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
                RunTree("32_Grotto_Kueche_Zusammen_Kochen")
            }
        }        
    }
}

Tree("32_Grotto_Kueche_Zusammen_Kochen") {
// --- Kueche - Zusammen Kochen ---
    Composite(Sequence) {
        BTC.Run("AudioSource.AUDIO.Kueche1FZusammenKo")

        // Risotto in Topf geben
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Risotto")
        BTC.Run("Collider.INTERACTABLES.Topf")

        // Ruehren
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Loeffel")
        BTC.Run("Collider.INTERACTABLES.Topf")
        BTC.Wait(2) // Wie lange ruehren?
        BTC.Run("AudioSource.AUDIO.Kueche2FZusammenKo")

        // Wein leuchtet
        BTC.Enable("NamedGrabEvent/NamedOutline.INTERACTABLES.Weisswein")

        // Wein greifen
        BTC.Run("NamedGrabEvent/NamedOutline.INTERACTABLES.Weisswein")
        BTC.Disable("NamedGrabEvent/NamedOutline.INTERACTABLES.Weisswein")
        
        // Wein in Topf giessen - Todo: Particle Trigger
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Weisswein")
        BTC.Run("Collider.INTERACTABLES.Topf")
        BTC.StopSound("StudioEventEmitter.INTERACTABLES.ZwiebelnInTopf")
        BTC.Run("StudioEventEmitter.INTERACTABLES.Abloeschen")

        Composite(Marathon) {
            Composite(Sequence) {
                BTC.Wait(6)
                BTC.SetFloat("StudioEventEmitter.INTERACTABLES.Abloeschen", "blubbern.transition", 1)
                BTC.Show("GO.INTERACTABLES.ChangeSound") // Ruehren
            }

            Composite(Sequence) {
                BTC.Run("AudioSource.AUDIO.Kueche3FZusammenKo")
            }
        }
        
        // Bouillon leuchtet
        BTC.Enable("NamedGrabEvent/NamedOutline.INTERACTABLES.Bouillon")

        // Bouillon greifen
        BTC.Run("NamedGrabEvent/NamedOutline.INTERACTABLES.Bouillon")
        BTC.Disable("NamedGrabEvent/NamedOutline.INTERACTABLES.Bouillon")

        // Bouillon in Topf geben - Todo: Particle Trigger
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Bouillon")
        BTC.Run("Collider.INTERACTABLES.Topf")
        BTC.Run("AudioSource.AUDIO.Kueche4FZusammenKo")

        // Glas Wasser mit Steinpilze in Topf geben
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Steinpilze")
        BTC.Run("Collider.INTERACTABLES.Topf")

        //RunTree("32_Grotto_Kueche_Parmigiano")
        RunTree("32_Grotto_Im_Grotto_Essen_Intro")
    }
}

Tree("32_Grotto_Kueche_Selbststaendig_Kochen") {
// --- Kueche - Selbststaendig Kochen ---
    Composite(Sequence) {
        BTC.Run("AudioSource.AUDIO.Kueche1FSelbststae")
        // Selbstaendig kochen...
        // ...

        RunTree("32_Grotto_Kueche_Parmigiano")
    }
}

Tree("32_Grotto_Kueche_Parmigiano") {
// --- Kueche - Parmigiano ---
    Composite(Sequence) {
        BTC.SynthesizeText("Schau, ich habe dir den Parmigiano hingestellt. Du kannst ihn nun in den Topf geben.")
        BTC.SpeechOutputEnded()

        // Parmigiano in Topf geben
        BTC.Run("NamedGrabEvent.INTERACTABLES.Parmigiano")
        BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Parmigiano")
        BTC.Run("Collider.INTERACTABLES.Topf")

        BTC.SynthesizeText("Bist du fertig?")
        BTC.SpeechOutputEnded()

        // Antwort User
        // ToDo: Sprache fehlt
        BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Ja")
        BTC.Show("GO.HANDMENU.Option1Button")
        Composite(Race) {
            BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
            BTC.Wait(5)
        }
        BTC.Hide("GO.HANDMENU.Option1Button")

        BTC.SynthesizeText("Bitte stelle den Risotto hier hin.")
        BTC.SpeechOutputEnded()

        // Stelle für Pfanne leuchtet
        BTC.Enable("Collider/NamedOutline.INTERACTABLES.TopfUntersetzer")

        // Pfanne rueber stellen
        BTC.Run("NamedGrabEvent.INTERACTABLES.Topf")
        BTC.Set("Collider/NamedOutline.INTERACTABLES.TopfUntersetzer", "otherTag", "Topf")
        BTC.Run("Collider/NamedOutline.INTERACTABLES.TopfUntersetzer")
        BTC.Disable("Collider/NamedOutline.INTERACTABLES.TopfUntersetzer")
        // ToDo: Fallback Keine Reaktion 

        BTC.Run("AudioSource.AUDIO.Kueche5FZusammenKo")
        BTC.Run("AudioSource.AUDIO.Kueche6FZusammenKo")

        // --- Kueche - Outro ---
        BTC.Run("AudioSource.AUDIO.Kueche1GOutro")
        BTC.SynthesizeText("Ich bin Giuseppe, Francescas Grossonkel. Und wer bist du?")
        BTC.SpeechOutputEnded()

        // Name sagen
        BTC.AddPossbileSpeechIntent("Kueche.Outro.4")
        BTC.StartSpeechIntentRecognition()

        Composite(Race) {
            // -- Race 1: User sagt etwas
            Composite(Sequence) {
                BTC.UserStartedSpeechInput()
                
                Composite(Selector) {
                    // -- Selector 1: Intent erkannt
                    Composite(Sequence) {
                        BTC.SpeechIntentRecognized()
                        BTC.ClearPossbileSpeechIntents()
                    }

                    // -- Selector 2: Intent nicht erkannt
                    Composite(Sequence) {
                        BTC.ClearPossbileSpeechIntents()

                        // Fallback Button
                        BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Mein Name ist User.")
                        BTC.Show("GO.HANDMENU.Option1Button")
                        BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
                        BTC.Hide("GO.HANDMENU.Option1Button")
                    }
                }
            }

            // -- Race 2: User sagt nichts
            Composite(Sequence) {
                BTC.Wait(5)
                BTC.CompareUserSpeechInputStarted(false)
                BTC.AbortSpeechEventListener()
                BTC.StopSpeechIntentRecognition()
                BTC.ClearPossbileSpeechIntents()
            }
        }        

        BTC.Run("AudioSource.AUDIO.Kueche3GOutro")
        BTC.Run("AudioSource.AUDIO.Kueche2GOutro")
    }
}

Tree("32_Grotto_Im_Grotto_Essen_Intro") {
// --- Im Grotto Essen - Intro ---
    Composite(Sequence) {
        BTC.Wait(10)

        // Initialization
        Composite(Marathon) {
            BTC.SetPosition("GO.XRInteractionHandsSetup.XROrigin", -3.837, 0, -10.676)
            BTC.SetPosition("GO.HANDMENU", -3.837, 0, -10.676)
            BTC.Run("StudioEventEmitter.STATIC.KuechenAmbi")
            BTC.Run("StudioEventEmitter.AUDIO.Ambi2D")
            BTC.StopSound("StudioEventEmitter.STATIC.Ambi3D")
            BTC.StopSound("StudioEventEmitter.STATIC.HerdplatteAnstelle")
            BTC.StopSound("StudioEventEmitter.INTERACTABLES.Abloeschen")
        }

        BTC.GetKeyDown("Return")

    }
}

Tree("32_Grotto_Kueche_Hide") {
    Composite(Sequence) {
        // Go to scene 3.5 Slideshow
        BTC.GetKeyDown("Return")
        BTC.Run("LoadScene.NEXT.35Slideshow")
    }
}