pollen-not-included/entities/snail/states/snail_sleeping.gd
Dan 7f5d9dc6fc Updated snail entity behavior
The snail entity's default state has been changed from 'Move' to 'Sleep'. Visibility and color modulation of certain sprites have been adjusted. The initial state of the StateMachine node is now set to 'Sleeping' instead of 'Eating'. In the snail sleeping script, the sleep timer update and state transition are now conditional on whether the level has started.
2024-05-16 12:08:02 +01:00

34 lines
808 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:
if GameState.level_started:
sleep_timer += delta
# Snail will only wake up if the level has started
if sleep_timer > wakes_up_in:
state_transition.emit(self, "Eating")
func physics_update(_delta : float) -> void:
pass