Added new animation states for the snail entity, including 'Move' and 'Sleep'. The snail now hides certain elements when eating and plays appropriate animations when transitioning between states. Also introduced a new texture for sleep indication.
31 lines
722 B
GDScript
31 lines
722 B
GDScript
extends State
|
|
class_name SnailSleeping
|
|
|
|
@onready var snail : Snail = get_parent().get_parent() as Snail # I think this is bad but I dont care it works
|
|
|
|
var wakes_up_in : float = 0
|
|
var sleep_timer : float = 0
|
|
|
|
func enter(_msg : Dictionary = {}) -> void:
|
|
Log.pr("I am a snail asleep...")
|
|
snail.rotation = 0
|
|
if snail.animation:
|
|
snail.animation.play("GoingToSleep")
|
|
CursorMgr.reset_cursor()
|
|
|
|
# Decide how many seconds until the snail wakes up again
|
|
wakes_up_in = randf_range(15.0, 25.0)
|
|
sleep_timer = 0
|
|
|
|
func exit() -> void:
|
|
pass
|
|
|
|
func update(delta : float) -> void:
|
|
sleep_timer += delta
|
|
|
|
if sleep_timer > wakes_up_in:
|
|
state_transition.emit(self, "Eating")
|
|
|
|
func physics_update(_delta : float) -> void:
|
|
pass
|
|
|