+audience listening

+audience ignoring double jokes
This commit is contained in:
Mikhail Aristov 2024-01-28 09:45:39 +01:00
parent 226313c974
commit 5b6a039132
1 changed files with 16 additions and 2 deletions

View File

@ -12,6 +12,9 @@ extends Node2D
@export_enum("angry", "neutral", "happy", "laugh") var expression @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] = [ var known_faces : Array[String] = [
"res://scenes/faces/face_curly.tscn", "res://scenes/faces/face_curly.tscn",
"res://scenes/faces/face_jenny.tscn", "res://scenes/faces/face_jenny.tscn",
@ -80,9 +83,9 @@ func _process(delta):
if laughter_left >= 0: if laughter_left >= 0:
laughter_left -= delta laughter_left -= delta
if mood > profile.happy_threshold * .5: if not is_listening and mood > profile.happy_threshold * .5:
mood -= profile.happiness_decay * delta 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 mood += profile.lashout_decay * delta
@ -135,6 +138,17 @@ func set_random_face():
face = face_res.instantiate() face = face_res.instantiate()
head.add_child(face) 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): func on_joke(joke: Joke):
var mood_change = profile.joke_mood_mapping.get(joke.type, 0) var mood_change = profile.joke_mood_mapping.get(joke.type, 0)
update_mood(mood_change) update_mood(mood_change)