From 5b6a039132b5d587dab696f916a8514ddba05829 Mon Sep 17 00:00:00 2001 From: Mikhail Aristov <12281487+MikhailAristov@users.noreply.github.com> Date: Sun, 28 Jan 2024 09:45:39 +0100 Subject: [PATCH] +audience listening +audience ignoring double jokes --- godot/scenes/crowd/person.gd | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/godot/scenes/crowd/person.gd b/godot/scenes/crowd/person.gd index 6de18e4..f4d59ba 100644 --- a/godot/scenes/crowd/person.gd +++ b/godot/scenes/crowd/person.gd @@ -12,6 +12,9 @@ extends Node2D @export_enum("angry", "neutral", "happy", "laugh") var expression +var is_listening : bool = false +var last_joke_heard : Joke.JokeType = -1 + var known_faces : Array[String] = [ "res://scenes/faces/face_curly.tscn", "res://scenes/faces/face_jenny.tscn", @@ -80,9 +83,9 @@ func _process(delta): if laughter_left >= 0: laughter_left -= delta - if mood > profile.happy_threshold * .5: + if not is_listening and mood > profile.happy_threshold * .5: mood -= profile.happiness_decay * delta - elif mood < profile.lashout_threshold * .9: + elif not is_listening and mood < profile.lashout_threshold * .9: mood += profile.lashout_decay * delta @@ -135,6 +138,17 @@ func set_random_face(): face = face_res.instantiate() head.add_child(face) +func on_joke_start(): + is_listening = true + +func on_joke_finish(joke: Joke): + is_listening = false + var mood_change = profile.joke_mood_mapping.get(joke.type, 0) + if joke.type == last_joke_heard: + mood_change = max(0, mood_change) + update_mood(mood_change) + last_joke_heard = joke.type + func on_joke(joke: Joke): var mood_change = profile.joke_mood_mapping.get(joke.type, 0) update_mood(mood_change)