From c1cd50217ff49b4009ac00a76c97f31d76db9a73 Mon Sep 17 00:00:00 2001 From: Poobslag Date: Wed, 3 Jun 2020 08:57:25 -0400 Subject: [PATCH] Seat now references a customer, doesn't 'own' a customer Results screen now says 'Customer' instead of 'Creature' --- src/demo/creature-view-demo.gd | 16 ++-- src/demo/restaurant-scene-demo.gd | 14 +--- src/main/puzzle/Puzzle.tscn | 2 - src/main/puzzle/puzzle.gd | 8 +- src/main/puzzle/results-hud.gd | 2 +- src/main/ui/chat/ChatChoices.tscn | 1 - src/main/world/restaurant/CreatureView.tscn | 2 +- .../world/restaurant/RestaurantScene.tscn | 30 +++++--- src/main/world/restaurant/Seat.tscn | 11 +-- src/main/world/restaurant/creature-loader.gd | 7 ++ src/main/world/restaurant/creature-view.gd | 38 +++------ src/main/world/restaurant/creature.gd | 24 ++++++ src/main/world/restaurant/restaurant-scene.gd | 77 ++++--------------- src/main/world/restaurant/seat.gd | 69 ++++++----------- 14 files changed, 119 insertions(+), 182 deletions(-) diff --git a/src/demo/creature-view-demo.gd b/src/demo/creature-view-demo.gd index ef809acc9..c0c6619d9 100644 --- a/src/demo/creature-view-demo.gd +++ b/src/demo/creature-view-demo.gd @@ -6,7 +6,6 @@ Keys: [F]: Feed the creature [D]: Ring the doorbell [V]: Say something - [P]: Print the current animation details [1-9,0]: Change the creature's size from 10% to 100% [Q,W,E]: Switch to the 1st, 2nd or 3rd creature. brace keys: Change the creature's appearance @@ -23,11 +22,11 @@ func _ready() -> void: func _input(event: InputEvent) -> void: match Utils.key_scancode(event): - KEY_F: $CreatureView/SceneClip/CreatureSwitcher/Scene.feed() - KEY_D: $CreatureView/SceneClip/CreatureSwitcher/Scene.play_door_chime(0) - KEY_V: $CreatureView.play_goodbye_voice() + KEY_F: _creature().feed() + KEY_D: _creature().play_door_chime(0) + KEY_V: _creature().play_goodbye_voice() KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9: - $CreatureView.set_fatness(FATNESS_KEYS[Utils.key_num(event)]) + $CreatureView.get_creature().set_fatness(FATNESS_KEYS[Utils.key_num(event)]) KEY_Q: $CreatureView.set_current_creature_index(0) KEY_W: $CreatureView.set_current_creature_index(1) KEY_E: $CreatureView.set_current_creature_index(2) @@ -46,6 +45,7 @@ func _input(event: InputEvent) -> void: _current_color_index = (_current_color_index + 1) % CreatureLoader.DEFINITIONS.size() Global.creature_queue.push_front(CreatureLoader.DEFINITIONS[_current_color_index]) $CreatureView.summon_creature() - KEY_P: - print($CreatureView/SceneClip/CreatureSwitcher/Scene/Creature/AnimationPlayer.current_animation) - print($CreatureView/SceneClip/CreatureSwitcher/Scene/Creature/AnimationPlayer.is_playing()) + + +func _creature() -> Creature: + return $CreatureView/SceneClip/CreatureSwitcher/Scene.get_creature() diff --git a/src/demo/restaurant-scene-demo.gd b/src/demo/restaurant-scene-demo.gd index f42b881fd..7314bb743 100644 --- a/src/demo/restaurant-scene-demo.gd +++ b/src/demo/restaurant-scene-demo.gd @@ -4,7 +4,6 @@ A demo which shows off the restaurant scene. Keys: [F]: Feed the creature - [P]: Print the current animation details [1-9,0]: Change the creature's size from 10% to 100% brace keys: Change the creature's appearance """ @@ -20,24 +19,19 @@ func _ready() -> void: func _input(event: InputEvent) -> void: match Utils.key_scancode(event): - KEY_F: $RestaurantScene.feed() + KEY_F: $RestaurantScene.get_creature().feed() KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9: - $RestaurantScene.set_fatness(FATNESS_KEYS[Utils.key_num(event)]) + $RestaurantScene.get_creature().set_fatness(FATNESS_KEYS[Utils.key_num(event)]) KEY_BRACELEFT: if _current_color_index == -1: _current_color_index = 0 else: _current_color_index += CreatureLoader.DEFINITIONS.size() _current_color_index = (_current_color_index - 1) % CreatureLoader.DEFINITIONS.size() - Global.creature_queue.push_front(CreatureLoader.DEFINITIONS[_current_color_index]) - $RestaurantScene.summon_creature(1) + $RestaurantScene.summon_creature(CreatureLoader.DEFINITIONS[_current_color_index]) KEY_BRACERIGHT: if _current_color_index == -1: _current_color_index = 0 else: _current_color_index = (_current_color_index + 1) % CreatureLoader.DEFINITIONS.size() - Global.creature_queue.push_front(CreatureLoader.DEFINITIONS[_current_color_index]) - $RestaurantScene.summon_creature(1) - KEY_P: - print($RestaurantScene/Creature/AnimationPlayer.current_animation) - print($RestaurantScene/Creature/AnimationPlayer.is_playing()) + $RestaurantScene.summon_creature(CreatureLoader.DEFINITIONS[_current_color_index]) diff --git a/src/main/puzzle/Puzzle.tscn b/src/main/puzzle/Puzzle.tscn index 8764ebeda..5fd8be5bc 100644 --- a/src/main/puzzle/Puzzle.tscn +++ b/src/main/puzzle/Puzzle.tscn @@ -61,8 +61,6 @@ [ext_resource path="res://src/main/puzzle/chalkboard.gd" type="Script" id=66] [ext_resource path="res://src/main/puzzle/start-end-sfx.gd" type="Script" id=67] - - [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 4 ) diff --git a/src/main/puzzle/puzzle.gd b/src/main/puzzle/puzzle.gd index 3a036bda5..0d8e33870 100644 --- a/src/main/puzzle/puzzle.gd +++ b/src/main/puzzle/puzzle.gd @@ -55,15 +55,15 @@ Parameters: 'fatness_pct' A percent from [0.0-1.0] of how much fatter the creature should get from this bite of food. """ func _feed_creature(fatness_pct: float) -> void: - $CreatureView/SceneClip/CreatureSwitcher/Scene.feed() + $CreatureView.get_creature().feed() if PuzzleScore.game_active: - var old_fatness: float = $CreatureView.get_fatness() + var old_fatness: float = $CreatureView.get_creature().get_fatness() var target_fatness := sqrt(1 + PuzzleScore.get_creature_score() / 50.0) if Scenario.settings.other.tutorial: # make them a tiny amount fatter, so that they'll change when a new level is started target_fatness = min(target_fatness, 1.001) - $CreatureView.set_fatness(lerp(old_fatness, target_fatness, fatness_pct)) + $CreatureView.get_creature().set_fatness(lerp(old_fatness, target_fatness, fatness_pct)) func _on_Hud_start_button_pressed() -> void: @@ -86,7 +86,7 @@ func _on_Playfield_line_cleared(y: int, total_lines: int, remaining_lines: int, if creature_talks: yield(get_tree().create_timer(0.5), "timeout") - $CreatureView/SceneClip/CreatureSwitcher/Scene.play_combo_voice() + $CreatureView.get_creature().play_combo_voice() """ diff --git a/src/main/puzzle/results-hud.gd b/src/main/puzzle/results-hud.gd index 4c1f36cb2..ea3c72e76 100644 --- a/src/main/puzzle/results-hud.gd +++ b/src/main/puzzle/results-hud.gd @@ -143,6 +143,6 @@ func _on_PuzzleScore_after_game_ended() -> void: func _on_ResultsLabel_text_shown(new_text: String) -> void: - if new_text.begins_with("Creature #"): + if new_text.begins_with("Customer #"): var amount := int(StringUtils.substring_after_last(new_text, "¥").replace(",", "")) $MoneyLabel.set_shown_money($MoneyLabel.shown_money + amount) diff --git a/src/main/ui/chat/ChatChoices.tscn b/src/main/ui/chat/ChatChoices.tscn index 70679574d..0d20b5f50 100644 --- a/src/main/ui/chat/ChatChoices.tscn +++ b/src/main/ui/chat/ChatChoices.tscn @@ -5,7 +5,6 @@ [ext_resource path="res://assets/main/ui/chat/choice-choose.wav" type="AudioStream" id=5] [ext_resource path="res://src/main/ui/chat/ChatChoiceButton.tscn" type="PackedScene" id=6] - [node name="ChatChoices" type="GridContainer"] anchor_left = 1.0 anchor_top = 1.0 diff --git a/src/main/world/restaurant/CreatureView.tscn b/src/main/world/restaurant/CreatureView.tscn index 8e72e38ae..bd9d1b4c1 100644 --- a/src/main/world/restaurant/CreatureView.tscn +++ b/src/main/world/restaurant/CreatureView.tscn @@ -42,7 +42,7 @@ range_item_cull_mask = 2 [node name="CreatureSwitcher" type="Node2D" parent="SceneClip"] [node name="Scene" parent="SceneClip/CreatureSwitcher" instance=ExtResource( 3 )] -position = Vector2( -89.8811, -77.6484 ) +position = Vector2( -89.8812, -104.904 ) [node name="CreatureSwitchTween" type="Tween" parent="SceneClip/CreatureSwitcher"] diff --git a/src/main/world/restaurant/RestaurantScene.tscn b/src/main/world/restaurant/RestaurantScene.tscn index e799dc62f..ac925f41d 100644 --- a/src/main/world/restaurant/RestaurantScene.tscn +++ b/src/main/world/restaurant/RestaurantScene.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=11 format=2] +[gd_scene load_steps=12 format=2] +[ext_resource path="res://src/main/world/restaurant/Creature.tscn" type="PackedScene" id=1] [ext_resource path="res://src/main/world/restaurant/Seat.tscn" type="PackedScene" id=2] [ext_resource path="res://assets/main/world/restaurant/wall-metal.png" type="Texture" id=5] [ext_resource path="res://assets/main/world/restaurant/wall-metal-shadow.png" type="Texture" id=7] @@ -145,19 +146,28 @@ z_index = 10 texture = ExtResource( 12 ) offset = Vector2( 0, -550 ) +[node name="Creature1" parent="." instance=ExtResource( 1 )] +visible = false +position = Vector2( 381.228, 435.763 ) +z_index = 20 + [node name="Seat1" parent="." instance=ExtResource( 2 )] -z_index = 10 + +[node name="Creature2" parent="." instance=ExtResource( 1 )] +visible = false +position = Vector2( 1381.23, 435.763 ) +z_index = 20 [node name="Seat2" parent="." instance=ExtResource( 2 )] position = Vector2( 1380, 585 ) -z_index = 10 + +[node name="Creature3" parent="." instance=ExtResource( 1 )] +visible = false +position = Vector2( 2381.23, 435.763 ) +z_index = 20 [node name="Seat3" parent="." instance=ExtResource( 2 )] position = Vector2( 2380, 585 ) -z_index = 10 - -[editable path="Seat1"] - -[editable path="Seat2"] - -[editable path="Seat3"] +[connection signal="food_eaten" from="Creature1" to="." method="_on_Creature_food_eaten"] +[connection signal="food_eaten" from="Creature2" to="." method="_on_Creature_food_eaten"] +[connection signal="food_eaten" from="Creature3" to="." method="_on_Creature_food_eaten"] diff --git a/src/main/world/restaurant/Seat.tscn b/src/main/world/restaurant/Seat.tscn index 4398461d0..5a1cded53 100644 --- a/src/main/world/restaurant/Seat.tscn +++ b/src/main/world/restaurant/Seat.tscn @@ -1,6 +1,5 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=9 format=2] -[ext_resource path="res://src/main/world/restaurant/Creature.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/main/world/shadow-oval-0.png" type="Texture" id=3] [ext_resource path="res://assets/main/world/restaurant/wood-table.png" type="Texture" id=8] [ext_resource path="res://src/main/world/outline.shader" type="Shader" id=9] @@ -18,8 +17,9 @@ shader = ExtResource( 9 ) shader_param/width = 2.5 shader_param/black = Color( 0.423529, 0.262745, 0.192157, 1 ) -[node name="Seat" type="Node2D"] +[node name="Seat1" type="Node2D"] position = Vector2( 380, 585 ) +z_index = 10 script = ExtResource( 30 ) [node name="Stool0L" type="Sprite" parent="."] @@ -36,9 +36,6 @@ scale = Vector2( 0.15, 0.15 ) z_index = -10 texture = ExtResource( 3 ) -[node name="Creature" parent="." instance=ExtResource( 1 )] -position = Vector2( 1.228, -149.237 ) - [node name="WoodTable0" type="Sprite" parent="."] light_mask = 2 material = SubResource( 1 ) @@ -69,5 +66,3 @@ light_mask = 2 scale = Vector2( 0.15, 0.15 ) z_index = -15 texture = ExtResource( 3 ) -[connection signal="creature_arrived" from="Creature" to="." method="_on_Creature_creature_arrived"] -[connection signal="creature_left" from="Creature" to="." method="_on_Creature_creature_left"] diff --git a/src/main/world/restaurant/creature-loader.gd b/src/main/world/restaurant/creature-loader.gd index a3669367f..ae804291f 100644 --- a/src/main/world/restaurant/creature-loader.gd +++ b/src/main/world/restaurant/creature-loader.gd @@ -31,6 +31,13 @@ const DEFINITIONS := [ {"line_rgb": "41281e", "body_rgb": "0b45a6", "eye_rgb": "fad541 ffffff", "horn_rgb": "282828"} # dark blue ] +""" +Returns a random creature definition. +""" +static func random_def() -> Dictionary: + return DEFINITIONS[randi() % DEFINITIONS.size()] + + """ Loads all the appropriate resources and property definitions for a creature. The resulting textures are stored back in the 'creature_def' parameter which is passed in. diff --git a/src/main/world/restaurant/creature-view.gd b/src/main/world/restaurant/creature-view.gd index 3ce0a7c87..e8ddb45db 100644 --- a/src/main/world/restaurant/creature-view.gd +++ b/src/main/world/restaurant/creature-view.gd @@ -13,16 +13,13 @@ func _ready() -> void: PuzzleScore.connect("combo_ended", self, "_on_PuzzleScore_combo_ended") -""" -Increases/decreases the camera and creature's fatness, playing an animation which gradually applies the change. +func _physics_process(delta: float) -> void: + if $FatPlayer.get_fatness() != get_creature().get_fatness(): + $FatPlayer.set_fatness(get_creature().get_fatness()) -Parameters: - 'fatness': How fat the creature should be; 5.0 = 5x normal size -""" -func set_fatness(fatness: float, creature_index: int = -1) -> void: - $SceneClip/CreatureSwitcher/Scene.set_fatness(fatness, creature_index) - if creature_index == -1 or creature_index == $SceneClip/CreatureSwitcher/Scene.current_creature_index: - $FatPlayer.set_fatness(fatness) + +func get_creature(creature_index: int = -1) -> Creature: + return $SceneClip/CreatureSwitcher/Scene.get_creature(creature_index) """ @@ -32,20 +29,12 @@ properties. func summon_creature(creature_index: int = -1) -> void: var creature_def: Dictionary if Global.creature_queue.empty(): - creature_def = CreatureLoader.DEFINITIONS[randi() % CreatureLoader.DEFINITIONS.size()] + creature_def = CreatureLoader.random_def() else: creature_def = Global.creature_queue.pop_front() $SceneClip/CreatureSwitcher/Scene.summon_creature(creature_def, creature_index) -""" -Returns the camera's 'fatness' -- when fatness is 1.0 the camera is zoomed in, and when the fatness is at 10.0 it's -zoomed out so that the creature is in frame. -""" -func get_fatness() -> float: - return $FatPlayer.get_fatness() - - """ Pans the camera to a new creature. This also changes which creature will be fed. """ @@ -55,17 +44,9 @@ func set_current_creature_index(current_creature_index: int) -> void: $SceneClip/CreatureSwitcher, "position:x", $SceneClip/CreatureSwitcher.position.x, -1000 * current_creature_index, PAN_DURATION_SECONDS, Tween.TRANS_SINE, Tween.EASE_IN_OUT) - $FatPlayer.set_fatness($SceneClip/CreatureSwitcher/Scene.get_fatness(current_creature_index)) $SceneClip/CreatureSwitcher/CreatureSwitchTween.start() -""" -Plays a 'check please!' voice sample, for when a creature is ready to leave -""" -func play_goodbye_voice() -> void: - $SceneClip/CreatureSwitcher/Scene.play_goodbye_voice() - - """ Scroll to a new creature and replace the old creature. """ @@ -74,7 +55,6 @@ func scroll_to_new_creature() -> void: var new_creature_index: int = (creature_index + randi() % 2 + 1) % 3 set_current_creature_index(new_creature_index) yield(get_tree().create_timer(0.5), "timeout") - set_fatness(1, creature_index) summon_creature(creature_index) @@ -82,11 +62,11 @@ func scroll_to_new_creature() -> void: If they ended the previous game while serving a creature, we scroll to a new one """ func _on_PuzzleScore_game_prepared() -> void: - if get_fatness() > 1: + if get_creature().get_fatness() > 1: scroll_to_new_creature() func _on_PuzzleScore_combo_ended() -> void: if PuzzleScore.game_active and not Scenario.settings.other.tutorial: - play_goodbye_voice() + get_creature().play_goodbye_voice() scroll_to_new_creature() diff --git a/src/main/world/restaurant/creature.gd b/src/main/world/restaurant/creature.gd index d4e868b4c..bedee76e8 100644 --- a/src/main/world/restaurant/creature.gd +++ b/src/main/world/restaurant/creature.gd @@ -182,6 +182,30 @@ func _process(delta: float) -> void: $Sprites/Neck0/Neck1.position.y = -100 +""" +Returns the creature's fatness, a float which determines how fat the creature +should be; 5.0 = 5x normal size + +Parameters: + 'creature_index': (Optional) The creature to ask about. Defaults to the current creature. +""" +func get_fatness() -> float: + return $FatPlayer.get_fatness() + + +""" +Increases/decreases the creature's fatness, a float which determines how fat +the creature should be; 5.0 = 5x normal size + +Parameters: + 'fatness_percent': Controls how fat the creature should be; 5.0 = 5x normal size + + 'creature_index': (Optional) The creature to be altered. Defaults to the current creature. +""" +func set_fatness(fatness: float) -> void: + $FatPlayer.set_fatness(fatness) + + func set_head_bob_mode(new_head_bob_mode: int) -> void: head_bob_mode = new_head_bob_mode # Some head bob animations like 'shudder' offset the x position; reset it back to the center diff --git a/src/main/world/restaurant/restaurant-scene.gd b/src/main/world/restaurant/restaurant-scene.gd index b298db170..9e8cc0805 100644 --- a/src/main/world/restaurant/restaurant-scene.gd +++ b/src/main/world/restaurant/restaurant-scene.gd @@ -16,12 +16,13 @@ var _shake_original_position: Vector2 # all of the seats in the scene. each 'seat' includes a table, chairs, a creature, etc... onready var _seats := [$Seat1, $Seat2, $Seat3] +onready var _creatures := [$Creature1, $Creature2, $Creature3] func _ready() -> void: - $Seat1.set_door_sound_position(Vector2(-500, 0)) - $Seat2.set_door_sound_position(Vector2(-1500, 0)) - $Seat3.set_door_sound_position(Vector2(-2500, 0)) - play_door_chime(0.0) + for i in range(3): + _get_seat(i).set_door_sound_position(Vector2(-500 + 1000 * i, 0)) + _get_seat(i).set_creature(_creatures[i]) + _get_seat(i).refresh() func _process(delta: float) -> void: @@ -35,13 +36,6 @@ func _process(delta: float) -> void: position = _shake_original_position + shake_vector -""" -Launches the 'feed' animation, hurling a piece of food at the creature and having them catch it. -""" -func feed() -> void: - _seats[current_creature_index].get_node("Creature").feed() - - """ Recolors the creature according to the specified creature definition. This involves updating shaders and sprite properties. @@ -50,71 +44,30 @@ Parameters: 'creature_def': The colors and textures used to draw the creature. """ func summon_creature(creature_def: Dictionary, creature_index: int = -1) -> void: - get_seat(creature_index).get_node("Creature").summon(creature_def) + get_creature(creature_index).summon(creature_def) + _get_seat(creature_index).refresh() -""" -Increases/decreases the creature's fatness, playing an animation which gradually applies the change. - -Parameters: - 'fatness_percent': Controls how fat the creature should be; 5.0 = 5x normal size - - 'creature_index': (Optional) The creature to be altered. Defaults to the current creature. -""" func set_fatness(fatness_percent: float, creature_index: int = -1) -> void: - get_seat(creature_index).get_node("Creature/FatPlayer").set_fatness(fatness_percent) - + get_creature(creature_index).set_fatness(fatness_percent) -""" -Returns the creature's fatness, a float which determines how fat the creature should be; 5.0 = 5x normal size -Parameters: - 'creature_index': (Optional) The creature to ask about. Defaults to the current creature. -""" func get_fatness(creature_index: int = -1) -> float: - return get_seat(creature_index).get_node("Creature/FatPlayer").get_fatness() - - -""" -Returns the seat corresponding to the specified optional index. If the index is omitted, returns the current seat of -the creature currently being fed. - -Parameters: - 'creature_index': (Optional) The creature to ask about. Defaults to the current creature. -""" -func get_seat(creature_index: int = -1) -> Control: - return _seats[current_creature_index] if creature_index == -1 else _seats[creature_index] - - -""" -Plays a door chime sound effect, for when a creature enters the restaurant. - -Parameter: 'delay' is the delay in seconds before the chime sound plays. The default value of '-1' results in a random - delay. -""" -func play_door_chime(delay: float = -1) -> void: - get_seat().play_door_chime(delay) - - -""" -Plays a 'mmm!' creature voice sample, for when a player builds a big combo. -""" -func play_combo_voice() -> void: - get_seat().play_combo_voice() + return get_creature(creature_index).get_fatness() """ -Plays a 'hello!' voice sample, for when a creature enters the restaurant +Returns the creature with the specified optional index. Defaults to the creature being fed. """ -func play_hello_voice() -> void: - get_seat().play_hello_voice() +func get_creature(creature_index: int = -1) -> Control: + return _creatures[current_creature_index] if creature_index == -1 else _creatures[creature_index] """ -Plays a 'check please!' voice sample, for when a creature is ready to leave +Returns the seat with the specified optional index. Defaults to the seat of the creature being fed. """ -func play_goodbye_voice() -> void: - get_seat().play_goodbye_voice() +func _get_seat(seat_index: int = -1) -> Control: + return _seats[current_creature_index] if seat_index == -1 else _seats[seat_index] func _on_Creature_food_eaten() -> void: diff --git a/src/main/world/restaurant/seat.gd b/src/main/world/restaurant/seat.gd index 2cc2b7d83..c983b719d 100644 --- a/src/main/world/restaurant/seat.gd +++ b/src/main/world/restaurant/seat.gd @@ -6,59 +6,36 @@ contain the shadows itself, since they need to appear behind other objects outsi This script contains logic for scaling an injected 'creature shadow' object as the creature grows in size. """ -""" -Plays a door chime sound effect, for when a creature enters the restaurant. - -Parameter: 'delay' is the delay in seconds before the chime sound plays. The default value of '-1' results in a random - delay. -""" -func play_door_chime(delay: float = -1) -> void: - $Creature.play_door_chime(delay) - - -""" -Sets the relative position of sound affects related to the restaurant door. Each seat has a different position -relative to the restaurant's entrance; some are close to the door, some are far away. - -Parameter: 'position' is the position of the door relative to this seat, in world coordinates. -""" -func set_door_sound_position(position: Vector2) -> void: - for chime_sound in $Creature.chime_sounds: - chime_sound.position = position - for hello_voice in $Creature.hello_voices: - hello_voice.position = position - +var _creature: Creature setget set_creature +var _door_sound_position: Vector2 -""" -Plays a 'mmm!' creature voice sample, for when a player builds a big combo. -""" -func play_combo_voice() -> void: - $Creature.play_combo_voice() - - -""" -Plays a 'hello!' voice sample, for when a creature enters the restaurant -""" -func play_hello_voice() -> void: - $Creature.play_hello_voice() +func set_creature(creature: Creature) -> void: + _creature = creature + refresh() """ -Plays a 'check please!' voice sample, for when a creature is ready to leave +Updates the properties of the seat and the creature sitting in it. """ -func play_goodbye_voice() -> void: - $Creature.play_goodbye_voice() +func refresh() -> void: + if _creature and _creature.is_visible_in_tree(): + # draw a shadow on the creature's stool + $Stool0L.texture = preload("res://assets/main/world/restaurant/stool-occupied.png") + for chime_sound in _creature.chime_sounds: + chime_sound.position = _door_sound_position + for hello_voice in _creature.hello_voices: + hello_voice.position = _door_sound_position + else: + # remove the shadow from the creature's stool + $Stool0L.texture = preload("res://assets/main/world/restaurant/stool.png") """ -When the creature arrives, we draw a shadowy version of the stool they sat upon. -""" -func _on_Creature_creature_arrived() -> void: - $Stool0L.texture = preload("res://assets/main/world/restaurant/stool-occupied.png") - +Sets the relative position of sound effects related to the restaurant door. Each seat has a different position +relative to the restaurant's entrance; some are close to the door, some are far away. +Parameter: 'position' is the position of the door relative to this seat, in world coordinates. """ -When the creature leaves, we draw an unshadowed version of the stool they stood up from. -""" -func _on_Creature_creature_left() -> void: - $Stool0L.texture = preload("res://assets/main/world/restaurant/stool.png") +func set_door_sound_position(door_sound_position: Vector2) -> void: + _door_sound_position = door_sound_position + refresh()