diff options
Diffstat (limited to 'client/player')
-rw-r--r-- | client/player/character/character.tscn | 2 | ||||
-rw-r--r-- | client/player/effect.gd | 28 | ||||
-rw-r--r-- | client/player/effect.tscn | 10 | ||||
-rw-r--r-- | client/player/item_bubble.gd | 3 | ||||
-rw-r--r-- | client/player/player.gd | 40 | ||||
-rw-r--r-- | client/player/stars.tscn | 2 |
6 files changed, 81 insertions, 4 deletions
diff --git a/client/player/character/character.tscn b/client/player/character/character.tscn index cb5aa988..d55296a5 100644 --- a/client/player/character/character.tscn +++ b/client/player/character/character.tscn @@ -575,7 +575,7 @@ height = 0.2 _data = [Vector2(0, 0.054945), 0.0, 0.0, 0, 0, Vector2(0.174157, 1), 0.0, 0.0, 0, 0, Vector2(0.573034, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] point_count = 4 -[node name="guy" type="Node3D"] +[node name="Character" type="Node3D"] script = ExtResource("1_12lbh") [node name="Main" type="MeshInstance3D" parent="."] diff --git a/client/player/effect.gd b/client/player/effect.gd new file mode 100644 index 00000000..eba2e66f --- /dev/null +++ b/client/player/effect.gd @@ -0,0 +1,28 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +class_name Effect +extends Node3D + +func set_effect(e: String): + clear_effect() + match e: + "satisfied": + $Stars.emitting = true + _: + push_warning("effect %s unknown" % e) + +func clear_effect(): + $Stars.emitting = false diff --git a/client/player/effect.tscn b/client/player/effect.tscn new file mode 100644 index 00000000..787997e9 --- /dev/null +++ b/client/player/effect.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://dn2ne30t81ame"] + +[ext_resource type="Script" path="res://player/effect.gd" id="1_aqsk6"] +[ext_resource type="PackedScene" uid="uid://yaed1vnhd0aa" path="res://player/stars.tscn" id="2_shb5l"] + +[node name="Effect" type="Node3D"] +script = ExtResource("1_aqsk6") + +[node name="Stars" parent="." instance=ExtResource("2_shb5l")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) diff --git a/client/player/item_bubble.gd b/client/player/item_bubble.gd index e57fbace..6bfe60b1 100644 --- a/client/player/item_bubble.gd +++ b/client/player/item_bubble.gd @@ -29,7 +29,8 @@ func set_item(t: String): func remove_item(): visible = false - item.queue_free() + if item != null: + item.queue_free() func _process(delta): if item != null: diff --git a/client/player/player.gd b/client/player/player.gd index b20eba14..75e3861e 100644 --- a/client/player/player.gd +++ b/client/player/player.gd @@ -30,6 +30,9 @@ var position_anim = Vector2(0, 0) var character: Character = preload("res://player/character/character.tscn").instantiate() var chat_bubble: ChatBubble = preload("res://player/chat_bubble.tscn").instantiate() var item_bubble: ItemBubble = preload("res://player/item_bubble.tscn").instantiate() +var effect: Effect = preload("res://player/effect.tscn").instantiate() + +var clear_timer: Timer = Timer.new() var hand: Item = null var hand_base: Node3D = Node3D.new() @@ -50,12 +53,18 @@ func _init(_id: int, new_name: String, pos: Vector2, new_character_idx: int, new add_child(chat_bubble) add_child(item_bubble) - + add_child(effect) + + clear_timer.one_shot = true + clear_timer.wait_time = 5. + add_child(clear_timer) + character_idx = new_character_idx - + func _ready(): character.select_hairstyle(character_idx) + clear_timer.timeout.connect(clear_message) func update_position(new_position: Vector2, new_rotation: float): position_ = new_position @@ -97,3 +106,30 @@ func _process(delta): position.z = position_anim.y rotation.y = rotation_anim character.walking = position_.distance_squared_to(position_anim) > 0.001 + + +func clear_message(): + item_bubble.remove_item() + chat_bubble.remove_text() + effect.clear_effect() + +func item_message(item_name: String, persist: bool): + item_bubble.set_item(item_name) + if persist: + clear_timer.stop() + else: + clear_timer.start() + +func text_message(m: String, persist: bool): + chat_bubble.set_text(m) + if persist: + clear_timer.stop() + else: + clear_timer.start() + +func effect_message(effect_name: String, persist: bool): + effect.set_effect(effect_name) + if persist: + clear_timer.stop() + else: + clear_timer.start() diff --git a/client/player/stars.tscn b/client/player/stars.tscn index e3fcc587..5c96c291 100644 --- a/client/player/stars.tscn +++ b/client/player/stars.tscn @@ -22,8 +22,10 @@ offsets = PackedFloat32Array(0, 0.711828, 1) colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) [node name="Stars" type="CPUParticles3D"] +emitting = false amount = 5 lifetime = 2.0 +one_shot = true explosiveness = 1.0 mesh = SubResource("QuadMesh_d0lru") direction = Vector3(0, 1, 0) |