From 9c953125445760dbf5c0562854caaa0d1866fda9 Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 4 Sep 2024 21:04:07 +0200 Subject: Add new progress protocol; Add knife model; Add knife to cutting board; Add cutting animation; Bump protocol version --- client/map/items/bread.gd | 4 ++-- client/map/items/food_processor.gd | 9 +++++---- client/map/items/item.gd | 11 ++++++----- client/map/items/pot.gd | 4 ++-- client/map/items/pot_items.gd | 4 ++-- client/map/items/strawberry.gd | 4 ++-- client/map/items/tomato.gd | 4 ++-- 7 files changed, 21 insertions(+), 19 deletions(-) (limited to 'client/map/items') diff --git a/client/map/items/bread.gd b/client/map/items/bread.gd index b5143c53..d869aeb1 100644 --- a/client/map/items/bread.gd +++ b/client/map/items/bread.gd @@ -25,8 +25,8 @@ func _init(owned_by_: Node3D): steam.color = Color(.6, .6, .6, .4) base.add_child(steam) -func progress(p: float, warn: bool): - super(p, warn) +func progress(position_: float, speed: float, warn: bool): + super(position_, speed, warn) steam.emitting = warn func finish(warn: bool): diff --git a/client/map/items/food_processor.gd b/client/map/items/food_processor.gd index 66d78168..ad4a6349 100644 --- a/client/map/items/food_processor.gd +++ b/client/map/items/food_processor.gd @@ -23,11 +23,12 @@ func _init(owned_by_: Node3D): add_child(load("res://map/items/food_processor.tscn").instantiate()) add_child(processing) -func progress(p: float, warn: bool): - super(p, warn) +func progress(position_: float, speed: float, warn: bool): + super(position_, speed, warn) processing.emitting = true - processing.rotation.y += p * TAU - base.rotation.y += p * TAU + # TODO: Fix animation + # processing.rotation.y += p * TAU + # base.rotation.y += p * TAU if sound_id == null: sound_id = Sound.item_progress( self, diff --git a/client/map/items/item.gd b/client/map/items/item.gd index 2d046700..e67edcca 100644 --- a/client/map/items/item.gd +++ b/client/map/items/item.gd @@ -50,12 +50,13 @@ func _process(delta): if p: rotation.y = G.interpolate_angle(rotation.y, owned_by.global_rotation.y, delta * ispeed) else: rotation.y = G.interpolate_angle_closest_quarter(rotation.y, owned_by.global_rotation.y, delta * ispeed) -func progress(p: float, warn: bool): +func progress(position_: float, speed: float, warn: bool): progress_instance.visible = true - progress_instance.set_progress(p, warn) - # this shoukd be removed when the server is fixed - if p >= 1.: - finish(warn) + progress_instance.update(position_, speed, warn) + + # TODO: Fix finish + # if p >= 1.: + # finish(warn) func finish(_warn: bool): progress_instance.visible = false diff --git a/client/map/items/pot.gd b/client/map/items/pot.gd index dd5a6c6f..7a4fe40b 100644 --- a/client/map/items/pot.gd +++ b/client/map/items/pot.gd @@ -23,8 +23,8 @@ func _init(owned_by_: Node3D): add_child(load("res://map/items/pot.tscn").instantiate()) base.add_child(steam) -func progress(p: float, warn: bool): - super(p, warn) +func progress(position_: float, speed: float, warn: bool): + super(position_, speed, warn) steam.emitting = true if warn: steam.color = Color(.2, .2, .2) diff --git a/client/map/items/pot_items.gd b/client/map/items/pot_items.gd index fae2ccaa..25fd74d3 100644 --- a/client/map/items/pot_items.gd +++ b/client/map/items/pot_items.gd @@ -51,8 +51,8 @@ class RawSteakP extends Pot: super(owned_by_) base.add_child(preload("res://map/items/raw_steak.tscn").instantiate()) - func progress(p: float, warn: bool): - super(p, warn) + func progress(position_: float, speed: float, warn: bool): + super(position_, speed, warn) if sound_id == null: sound_id = Sound.item_progress(self, preload("res://map/items/sounds/frying.ogg"), null) diff --git a/client/map/items/strawberry.gd b/client/map/items/strawberry.gd index ef9abb64..e663464f 100644 --- a/client/map/items/strawberry.gd +++ b/client/map/items/strawberry.gd @@ -24,8 +24,8 @@ func _init(owned_by_: Node3D): base.add_child(cut) cut.color = Color(1., 0., 0.) -func progress(p: float, warn: bool): - super(p, warn) +func progress(position_: float, speed: float, warn: bool): + super(position_, speed, warn) cut.emitting = true func finish(warn: bool): diff --git a/client/map/items/tomato.gd b/client/map/items/tomato.gd index 97cd668c..7ecff374 100644 --- a/client/map/items/tomato.gd +++ b/client/map/items/tomato.gd @@ -24,8 +24,8 @@ func _init(owned_by_: Node3D): base.add_child(cut) cut.color = Color(1., 0., 0.) -func progress(p: float, warn: bool): - super(p, warn) +func progress(position_: float, speed: float, warn: bool): + super(position_, speed, warn) cut.emitting = true func finish(warn: bool): -- cgit v1.2.3-70-g09d2 From fc63ac8ce0b6757e4b61a633f93f4f4c27fd7e03 Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 4 Sep 2024 21:14:33 +0200 Subject: Fix crash on item finished; Clean up code; Update knife model --- client/game.gd | 8 ++++---- client/map/items/item.gd | 2 +- client/map/tiles/knife.res | Bin 5530 -> 5546 bytes client/map/tiles/tile.gd | 4 ++-- client/multiplayer.gd | 5 ++--- client/player/player.gd | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) (limited to 'client/map/items') diff --git a/client/game.gd b/client/game.gd index a3bef461..d764e6af 100644 --- a/client/game.gd +++ b/client/game.gd @@ -201,9 +201,9 @@ func _ready(): t.progress(position_, speed, warn) ) - mp.set_tile_finished.connect(func(tile: Vector2i, warn: bool): + mp.set_tile_finished.connect(func(tile: Vector2i): var t: Tile = map.get_tile_instance(tile) - t.finish(warn) + t.finish() ) mp.set_player_progress.connect(func(player: int, position_: float, speed: float, warn: bool): @@ -211,9 +211,9 @@ func _ready(): p.progress(position_, speed, warn) ) - mp.set_player_finished.connect(func(player: int, warn: bool): + mp.set_player_finished.connect(func(player: int): var p: Player = players[player] - p.finish(warn) + p.finish() ) mp.text_message.connect(func(player: int, text: String, timeout_initial: float, timeout_remaining: float): diff --git a/client/map/items/item.gd b/client/map/items/item.gd index e67edcca..11914eef 100644 --- a/client/map/items/item.gd +++ b/client/map/items/item.gd @@ -58,7 +58,7 @@ func progress(position_: float, speed: float, warn: bool): # if p >= 1.: # finish(warn) -func finish(_warn: bool): +func finish(): progress_instance.visible = false func setup_sounds(): diff --git a/client/map/tiles/knife.res b/client/map/tiles/knife.res index 77e95cc7..622d9eb3 100644 Binary files a/client/map/tiles/knife.res and b/client/map/tiles/knife.res differ diff --git a/client/map/tiles/tile.gd b/client/map/tiles/tile.gd index 4075593d..be78883e 100644 --- a/client/map/tiles/tile.gd +++ b/client/map/tiles/tile.gd @@ -61,9 +61,9 @@ func progress(position_: float, speed: float, warn: bool): if item != null: item.progress(position_, speed, warn) -func finish(warn: bool): +func finish(): if item != null: - item.finish(warn) + item.finish() func put_item(i: Item): if item != null: diff --git a/client/multiplayer.gd b/client/multiplayer.gd index e4af88f2..d42e500b 100644 --- a/client/multiplayer.gd +++ b/client/multiplayer.gd @@ -174,14 +174,13 @@ func handle_packet(bytes: PackedByteArray): set_player_progress.emit(player, position, speed, warn) "clear_progress": var item: Dictionary = decoded["item"] - var warn: bool = decoded["warn"] var tile = item.get("tile") var player = item.get("player") if tile != null: - set_tile_finished.emit(pos_to_vec2i(tile), warn) + set_tile_finished.emit(pos_to_vec2i(tile)) else: - set_player_finished.emit(player, warn) + set_player_finished.emit(player) "set_tile_item": push_warning("set_tile_item is deprecated") var tile = pos_to_vec2i(decoded["tile"]) diff --git a/client/player/player.gd b/client/player/player.gd index 17db85a9..d5837d47 100644 --- a/client/player/player.gd +++ b/client/player/player.gd @@ -111,9 +111,9 @@ func progress(position__: float, speed: float, warn: bool): if hand != null: hand.progress(position__, speed, warn) -func finish(warn: bool): +func finish(): if hand != null: - hand.finish(warn) + hand.finish() func take_item(tile: Tile): if hand != null: -- cgit v1.2.3-70-g09d2 From f1389c16aee688fd7dd67abb56b5e5c83aaf2c1c Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 4 Sep 2024 21:15:47 +0200 Subject: Fix crash because of incomplete refactor --- client/map/items/bread.gd | 4 ++-- client/map/items/food_processor.gd | 4 ++-- client/map/items/pot.gd | 4 ++-- client/map/items/strawberry.gd | 4 ++-- client/map/items/tomato.gd | 4 ++-- client/map/tiles/oven.gd | 4 ++-- client/map/tiles/sink.gd | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'client/map/items') diff --git a/client/map/items/bread.gd b/client/map/items/bread.gd index d869aeb1..a3c109e1 100644 --- a/client/map/items/bread.gd +++ b/client/map/items/bread.gd @@ -29,6 +29,6 @@ func progress(position_: float, speed: float, warn: bool): super(position_, speed, warn) steam.emitting = warn -func finish(warn: bool): - super(warn) +func finish(): + super() steam.emitting = false diff --git a/client/map/items/food_processor.gd b/client/map/items/food_processor.gd index ad4a6349..4a73cac5 100644 --- a/client/map/items/food_processor.gd +++ b/client/map/items/food_processor.gd @@ -37,8 +37,8 @@ func progress(position_: float, speed: float, warn: bool): -10. ) -func finish(warn: bool): - super(warn) +func finish(): + super() if sound_id != null: processing.emitting = false Sound.item_finished(sound_id) diff --git a/client/map/items/pot.gd b/client/map/items/pot.gd index 7a4fe40b..2bed6a5c 100644 --- a/client/map/items/pot.gd +++ b/client/map/items/pot.gd @@ -31,8 +31,8 @@ func progress(position_: float, speed: float, warn: bool): else: steam.color = Color(1.,1.,1.) -func finish(warn: bool): - super(warn) +func finish(): + super() steam.emitting = false func setup_sounds(): diff --git a/client/map/items/strawberry.gd b/client/map/items/strawberry.gd index e663464f..f2a1165a 100644 --- a/client/map/items/strawberry.gd +++ b/client/map/items/strawberry.gd @@ -28,6 +28,6 @@ func progress(position_: float, speed: float, warn: bool): super(position_, speed, warn) cut.emitting = true -func finish(warn: bool): - super(warn) +func finish(): + super() cut.emitting = false diff --git a/client/map/items/tomato.gd b/client/map/items/tomato.gd index 7ecff374..082b2b19 100644 --- a/client/map/items/tomato.gd +++ b/client/map/items/tomato.gd @@ -28,6 +28,6 @@ func progress(position_: float, speed: float, warn: bool): super(position_, speed, warn) cut.emitting = true -func finish(warn: bool): - super(warn) +func finish(): + super() cut.emitting = false diff --git a/client/map/tiles/oven.gd b/client/map/tiles/oven.gd index 598e0c7e..9ab7fd75 100644 --- a/client/map/tiles/oven.gd +++ b/client/map/tiles/oven.gd @@ -30,6 +30,6 @@ func take_item() -> Item: oven.open() return super() -func finish(warn: bool): - super(warn) +func finish(): + super() oven.ding() diff --git a/client/map/tiles/sink.gd b/client/map/tiles/sink.gd index 32c5290f..e2524041 100644 --- a/client/map/tiles/sink.gd +++ b/client/map/tiles/sink.gd @@ -44,8 +44,8 @@ func progress(position_: float, speed: float, warn: bool): if not running.playing: running.play() -func finish(warn: bool): - super(warn) +func finish(): + super() particles.stop() running.stop() stopping.play() -- cgit v1.2.3-70-g09d2 From 9ed1d51ad4abaa114da36e3284c8e29dd07855ad Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 4 Sep 2024 21:31:13 +0200 Subject: Fix food processor rotation animation --- client/map/items/food_processor.gd | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'client/map/items') diff --git a/client/map/items/food_processor.gd b/client/map/items/food_processor.gd index 4a73cac5..81886ae7 100644 --- a/client/map/items/food_processor.gd +++ b/client/map/items/food_processor.gd @@ -16,6 +16,7 @@ class_name FoodProcessor extends Item +var time := 0. var processing: CPUParticles3D = load("res://map/items/processing.tscn").instantiate() func _init(owned_by_: Node3D): @@ -23,12 +24,15 @@ func _init(owned_by_: Node3D): add_child(load("res://map/items/food_processor.tscn").instantiate()) add_child(processing) +func _process(delta: float): + super(delta) + time += delta + processing.rotation.y += time * TAU + base.rotation.y += time * TAU + func progress(position_: float, speed: float, warn: bool): super(position_, speed, warn) processing.emitting = true - # TODO: Fix animation - # processing.rotation.y += p * TAU - # base.rotation.y += p * TAU if sound_id == null: sound_id = Sound.item_progress( self, -- cgit v1.2.3-70-g09d2