TurnBlock.gd 524 B

12345678910111213141516171819202122
  1. extends Block
  2. const SPINNING_TURN_BLOCK = preload("uid://b8dalotrk2oci")
  3. func on_block_hit(player: Player) -> void:
  4. if item != null:
  5. if mushroom_if_small:
  6. item = player_mushroom_check(player)
  7. dispense_item()
  8. else:
  9. spin()
  10. func on_shell_block_hit(_shell: Shell) -> void:
  11. if item != null:
  12. dispense_item()
  13. else:
  14. spin()
  15. func spin() -> void:
  16. await get_tree().create_timer(0.15, false).timeout
  17. var spinning = SPINNING_TURN_BLOCK.instantiate()
  18. spinning.position = position
  19. add_sibling(spinning)
  20. queue_free()