Some code optimization
This commit is contained in:
@@ -24,6 +24,7 @@ var target_x := 0.0
|
||||
@onready var state_machine : CultistStateMachine = $CultistStateMachine
|
||||
@onready var chase_left_state : CultistState = $CultistStateMachine/ChaseLeftState
|
||||
@onready var chase_right_state : CultistState = $CultistStateMachine/ChaseRightState
|
||||
@onready var look_around_state : CultistState = $CultistStateMachine/LookAroundState
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -36,23 +37,13 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
state_machine.physics_process(delta)
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func update_x_velocity(direction: int, max_speed: float, delta: float) -> void:
|
||||
velocity.x = move_toward(velocity.x, direction * max_speed, ACCELERATION * delta)
|
||||
|
||||
|
||||
#TODO Rework
|
||||
func _on_player_touch_area_entered(body: Node2D) -> void:
|
||||
if body is Player:
|
||||
target_x = body.position.x
|
||||
if body.position.x < position.x:
|
||||
state_machine._change_state(chase_left_state)
|
||||
else:
|
||||
state_machine._change_state(chase_right_state)
|
||||
|
||||
|
||||
func _set_ray_cast_enable(ray_cast: RayCast2D, enabled: bool) -> void:
|
||||
ray_cast.process_mode = Node.PROCESS_MODE_INHERIT if enabled else Node.PROCESS_MODE_DISABLED
|
||||
|
||||
Reference in New Issue
Block a user