# Hurry Curry! - a game about cooking # Copyright 2024 tpart # 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 . # extends Node3D class_name Character const DEFAULT_MAIN_MESH = preload("res://player/character/default/main.res") const CUSTOMER_MAIN_MESH = preload("res://player/character/customer_body.res") const ROBOT_MAIN_MESH = preload("res://player/character/robot/body.res") const WALK_ANIM_STRENGTH := 0.05 const WALK_ANIM_SPEED:= 15.0 var walking := false var holding := false var boosting := false var was_boosting := boosting var current_animation := "idle" @onready var hand_animations = $HandAnimations @onready var main = $Main @onready var default_height = main.position.y @onready var main_height_target = default_height @onready var walking_particles = $Walking @onready var boosting_particles = $Boosting @onready var username_tag = $Username @onready var tie = $Main/Tie @onready var hairstyles := { "Brown": $Main/HeadDefault/Hair, "Blond": $Main/HeadDefault/Hair2, "E. Parsley": $Main/HeadDefault/Hair3 } @onready var head_default: MeshInstance3D = $Main/HeadDefault @onready var head_robot: MeshInstance3D = $Main/HeadRobot @onready var step_sounds: PlayRandom = $Steps @onready var boost_sounds: PlayRandom = $Boosts func _ready(): play_animation("idle") var t := 0.0 func _process(delta): if walking: t += delta main_height_target = default_height + sin(t * WALK_ANIM_SPEED) * WALK_ANIM_STRENGTH else: t = 0 main.position.y = main_height_target # Update animation: var next_animation: String if holding: next_animation = "hold" elif walking: next_animation = "walk" else: next_animation = "idle" walking_particles.emitting = walking if boosting and walking and not was_boosting: boosting_particles.emitting = true boost_sounds.play_random() else: boosting_particles.emitting = false was_boosting = boosting and walking if current_animation != next_animation: play_animation(next_animation) func select_hairstyle(id: int): if id == 51: toggle_robot(true) return if id < 0: to_customer() id *= -1 var hairstyle_count = hairstyles.keys().size() id = id % hairstyle_count var target = hairstyles.keys()[id] for k in hairstyles.keys(): if k == target: hairstyles[k].show() else: hairstyles[k].hide() func to_customer(): main.mesh = CUSTOMER_MAIN_MESH tie.queue_free() func toggle_robot(b: bool): if b: head_robot.show() head_default.hide() main.mesh = ROBOT_MAIN_MESH else: head_robot.hide() head_default.show() main.mesh = DEFAULT_MAIN_MESH func play_animation(name_: String): current_animation = name_ hand_animations.play(name_) if name_ == "walk": step_sounds.start_autoplay() else: step_sounds.stop_autoplay() func _on_hand_animations_animation_finished(_name): hand_animations.play(current_animation)