Removed duplicate code
This commit is contained in:
@@ -1,17 +1,5 @@
|
|||||||
extends CultistFallState
|
extends CultistFallSidewaysState
|
||||||
|
|
||||||
|
|
||||||
@export var fall_state: CultistState
|
|
||||||
|
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
cultist.sprite.play(CultistSprite.ANIMATION_FALL_LEFT)
|
cultist.sprite.play(CultistSprite.ANIMATION_FALL_LEFT)
|
||||||
|
|
||||||
|
|
||||||
func physics_process(delta: float) -> void:
|
|
||||||
cultist.velocity += cultist.get_gravity() * delta
|
|
||||||
cultist.move_and_slide()
|
|
||||||
if cultist.is_on_floor():
|
|
||||||
switch_state.emit(look_around_state)
|
|
||||||
elif is_zero_approx(cultist.velocity.x):
|
|
||||||
switch_state.emit(fall_state)
|
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
extends CultistFallState
|
extends CultistFallSidewaysState
|
||||||
|
|
||||||
|
|
||||||
@export var fall_state: CultistState
|
|
||||||
|
|
||||||
|
|
||||||
func enter() -> void:
|
func enter() -> void:
|
||||||
cultist.sprite.play(CultistSprite.ANIMATION_FALL_RIGHT)
|
cultist.sprite.play(CultistSprite.ANIMATION_FALL_RIGHT)
|
||||||
|
|
||||||
|
|
||||||
func physics_process(delta: float) -> void:
|
|
||||||
cultist.velocity += cultist.get_gravity() * delta
|
|
||||||
cultist.move_and_slide()
|
|
||||||
if cultist.is_on_floor():
|
|
||||||
switch_state.emit(look_around_state)
|
|
||||||
elif is_zero_approx(cultist.velocity.x):
|
|
||||||
switch_state.emit(fall_state)
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class_name CultistFallSidewaysState
|
||||||
|
extends CultistFallState
|
||||||
|
|
||||||
|
|
||||||
|
@export var fall_state: CultistState
|
||||||
|
|
||||||
|
|
||||||
|
func physics_process(delta: float) -> void:
|
||||||
|
var is_on_floor := _move_down_and_check_floor(delta)
|
||||||
|
if not is_on_floor and is_zero_approx(cultist.velocity.x):
|
||||||
|
switch_state.emit(fall_state)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dknrtf0f5wgnr
|
||||||
@@ -10,7 +10,13 @@ func enter() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func physics_process(delta: float) -> void:
|
func physics_process(delta: float) -> void:
|
||||||
|
_move_down_and_check_floor(delta)
|
||||||
|
|
||||||
|
|
||||||
|
func _move_down_and_check_floor(delta: float) -> bool:
|
||||||
cultist.velocity += cultist.get_gravity() * delta
|
cultist.velocity += cultist.get_gravity() * delta
|
||||||
cultist.move_and_slide()
|
cultist.move_and_slide()
|
||||||
if cultist.is_on_floor():
|
if cultist.is_on_floor():
|
||||||
switch_state.emit(look_around_state)
|
switch_state.emit(look_around_state)
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user