|
|
|
@ -136,38 +136,30 @@ func _state_process_physics_idle():
|
|
|
|
##Bugfix
|
|
|
|
##Bugfix
|
|
|
|
if _wants_jump:
|
|
|
|
if _wants_jump:
|
|
|
|
request_state_change.call_func('jump')
|
|
|
|
request_state_change.call_func('jump')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_crouch == true:
|
|
|
|
if _wants_crouch == true:
|
|
|
|
request_state_change.call_func('crouch')
|
|
|
|
request_state_change.call_func('crouch')
|
|
|
|
return
|
|
|
|
|
|
|
|
##TODO: May need that 'bump' logic to make velocity work.
|
|
|
|
##TODO: May need that 'bump' logic to make velocity work.
|
|
|
|
if desired_movement_vector.x != 0: # and velocity.x != 0:
|
|
|
|
if desired_movement_vector.x != 0: # and velocity.x != 0:
|
|
|
|
request_state_change.call_func('move')
|
|
|
|
request_state_change.call_func('move')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
#return fall_state
|
|
|
|
#return fall_state
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_roll == true:
|
|
|
|
if _wants_roll == true:
|
|
|
|
request_state_change.call_func('roll')
|
|
|
|
request_state_change.call_func('roll')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_attack_primary == true:
|
|
|
|
if _wants_attack_primary == true:
|
|
|
|
#request_state_change.call_func('attack_shoot')
|
|
|
|
#request_state_change.call_func('attack_shoot')
|
|
|
|
attack_primary()
|
|
|
|
attack_primary()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_attack_secondary == true:
|
|
|
|
if _wants_attack_secondary == true:
|
|
|
|
#parent_request_state_change.call_func('attack_sword')
|
|
|
|
#parent_request_state_change.call_func('attack_sword')
|
|
|
|
attack_secondary()
|
|
|
|
attack_secondary()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if $"%LadderDetector".is_colliding() and _wants_climb == true:
|
|
|
|
if $"%LadderDetector".is_colliding() and _wants_climb == true:
|
|
|
|
request_state_change.call_func('climb')
|
|
|
|
request_state_change.call_func('climb')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# var _v :Vector2 = new_move_actor_as_desired( physics_delta , current_state )
|
|
|
|
# var _v :Vector2 = new_move_actor_as_desired( physics_delta , current_state )
|
|
|
|
# apply_movement_to_parent(_v)
|
|
|
|
# apply_movement_to_parent(_v)
|
|
|
|
@ -188,7 +180,6 @@ func attack_primary():
|
|
|
|
var _item_state_name :String = parent_use_primary_item.call_func()
|
|
|
|
var _item_state_name :String = parent_use_primary_item.call_func()
|
|
|
|
if _item_state_name != '':
|
|
|
|
if _item_state_name != '':
|
|
|
|
request_state_change.call_func(_item_state_name)
|
|
|
|
request_state_change.call_func(_item_state_name)
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -197,7 +188,6 @@ func attack_secondary():
|
|
|
|
var _item_state_name :String = get_parent().use_secondary_item()
|
|
|
|
var _item_state_name :String = get_parent().use_secondary_item()
|
|
|
|
if _item_state_name != '':
|
|
|
|
if _item_state_name != '':
|
|
|
|
request_state_change.call_func(_item_state_name)
|
|
|
|
request_state_change.call_func(_item_state_name)
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _state_process_physics_attack_shoot():
|
|
|
|
func _state_process_physics_attack_shoot():
|
|
|
|
@ -209,37 +199,30 @@ func _state_process_physics_attack_shoot():
|
|
|
|
|
|
|
|
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
#return fall_state
|
|
|
|
#return fall_state
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _state_process_physics_attack_punch():
|
|
|
|
func _state_process_physics_attack_punch():
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
#return fall_state
|
|
|
|
#return fall_state
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _state_process_physics_attack_sword():
|
|
|
|
func _state_process_physics_attack_sword():
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
#return fall_state
|
|
|
|
#return fall_state
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _state_process_physics_roll():
|
|
|
|
func _state_process_physics_roll():
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Force role in facing direction
|
|
|
|
# Force role in facing direction
|
|
|
|
# instead of movement direction
|
|
|
|
# instead of movement direction
|
|
|
|
@ -276,7 +259,6 @@ func _state_process_physics_enter_right():
|
|
|
|
level_transition_latch = true
|
|
|
|
level_transition_latch = true
|
|
|
|
elif current_state.state_timeout.time_left == 0 and level_transition_latch == true:
|
|
|
|
elif current_state.state_timeout.time_left == 0 and level_transition_latch == true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Force role in facing direction
|
|
|
|
# Force role in facing direction
|
|
|
|
# instead of movement direction
|
|
|
|
# instead of movement direction
|
|
|
|
@ -292,12 +274,10 @@ func _state_process_physics_land():
|
|
|
|
$"%LedgeDetector".set_enabled(true)
|
|
|
|
$"%LedgeDetector".set_enabled(true)
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
if current_state.animation_finished == true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
#return fall_state
|
|
|
|
#return fall_state
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
#move_actor_as_desired()
|
|
|
|
#move_actor_as_desired()
|
|
|
|
apply_movement_to_parent(
|
|
|
|
apply_movement_to_parent(
|
|
|
|
velocity_controller.calculate_velocity(
|
|
|
|
velocity_controller.calculate_velocity(
|
|
|
|
@ -309,7 +289,6 @@ func _state_process_physics_land():
|
|
|
|
func _state_process_physics_hurt():
|
|
|
|
func _state_process_physics_hurt():
|
|
|
|
if current_state.state_timeout.time_left == 0:
|
|
|
|
if current_state.state_timeout.time_left == 0:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if !parent.is_on_floor():
|
|
|
|
# if !parent.is_on_floor():
|
|
|
|
# #return fall_state
|
|
|
|
# #return fall_state
|
|
|
|
@ -332,12 +311,11 @@ func _state_process_physics_fall():
|
|
|
|
if debug_component:
|
|
|
|
if debug_component:
|
|
|
|
UiManager.debug_text = (str($"%LedgeDetector".get_collision_point()))
|
|
|
|
UiManager.debug_text = (str($"%LedgeDetector".get_collision_point()))
|
|
|
|
request_state_change.call_func('ledge_grab')
|
|
|
|
request_state_change.call_func('ledge_grab')
|
|
|
|
return
|
|
|
|
|
|
|
|
if parent.is_on_floor():
|
|
|
|
if parent.is_on_floor():
|
|
|
|
#modifier.reference()
|
|
|
|
#modifier.reference()
|
|
|
|
#idle_state.modifier = landing_modifier
|
|
|
|
#idle_state.modifier = landing_modifier
|
|
|
|
request_state_change.call_func('land')
|
|
|
|
request_state_change.call_func('land')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#move_actor_as_desired()
|
|
|
|
#move_actor_as_desired()
|
|
|
|
apply_movement_to_parent(
|
|
|
|
apply_movement_to_parent(
|
|
|
|
@ -358,7 +336,6 @@ func _state_process_physics_jump():
|
|
|
|
# request_state_change.call_func('idle')
|
|
|
|
# request_state_change.call_func('idle')
|
|
|
|
if velocity_controller.velocity.y > 0:
|
|
|
|
if velocity_controller.velocity.y > 0:
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
desired_movement_vector.y = UP
|
|
|
|
desired_movement_vector.y = UP
|
|
|
|
#move_actor_as_desired()
|
|
|
|
#move_actor_as_desired()
|
|
|
|
apply_movement_to_parent(
|
|
|
|
apply_movement_to_parent(
|
|
|
|
@ -374,15 +351,12 @@ func _state_process_physics_move():
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_jump:
|
|
|
|
if _wants_jump:
|
|
|
|
request_state_change.call_func('jump')
|
|
|
|
request_state_change.call_func('jump')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if desired_movement_vector.x == 0:
|
|
|
|
if desired_movement_vector.x == 0:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## First version
|
|
|
|
## First version
|
|
|
|
#move_actor_as_desired()
|
|
|
|
#move_actor_as_desired()
|
|
|
|
@ -436,11 +410,9 @@ func _state_process_physics_climb():
|
|
|
|
# animations.stop()
|
|
|
|
# animations.stop()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return request_state_change.call_func('idle')
|
|
|
|
return request_state_change.call_func('idle')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_crouch:
|
|
|
|
if _wants_crouch:
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _state_process_physics_ledge_grab():
|
|
|
|
func _state_process_physics_ledge_grab():
|
|
|
|
if debug_component:
|
|
|
|
if debug_component:
|
|
|
|
@ -449,11 +421,9 @@ func _state_process_physics_ledge_grab():
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_jump:
|
|
|
|
if _wants_jump:
|
|
|
|
request_state_change.call_func('ledge_climb')
|
|
|
|
request_state_change.call_func('ledge_climb')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_crouch:
|
|
|
|
if _wants_crouch:
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _state_process_physics_ledge_climb():
|
|
|
|
func _state_process_physics_ledge_climb():
|
|
|
|
# $"../LedgeDetector".set_enabled(false)
|
|
|
|
# $"../LedgeDetector".set_enabled(false)
|
|
|
|
@ -487,18 +457,14 @@ func _state_process_physics_crouch():
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_crouch != true:
|
|
|
|
if _wants_crouch != true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_crouch == true and desired_movement_vector.x != 0:
|
|
|
|
if _wants_crouch == true and desired_movement_vector.x != 0:
|
|
|
|
request_state_change.call_func('crouch_move')
|
|
|
|
request_state_change.call_func('crouch_move')
|
|
|
|
return
|
|
|
|
|
|
|
|
elif desired_movement_vector.x != 0: # and velocity.x != 0:
|
|
|
|
elif desired_movement_vector.x != 0: # and velocity.x != 0:
|
|
|
|
request_state_change.call_func('move')
|
|
|
|
request_state_change.call_func('move')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apply_movement_to_parent(
|
|
|
|
apply_movement_to_parent(
|
|
|
|
velocity_controller.calculate_velocity(
|
|
|
|
velocity_controller.calculate_velocity(
|
|
|
|
@ -513,18 +479,14 @@ func _state_process_physics_crouch_move():
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_crouch != true:
|
|
|
|
if _wants_crouch != true:
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
request_state_change.call_func('idle')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
if !parent.is_on_floor():
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
request_state_change.call_func('fall')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _wants_crouch == true and desired_movement_vector.x == 0:
|
|
|
|
if _wants_crouch == true and desired_movement_vector.x == 0:
|
|
|
|
request_state_change.call_func('crouch')
|
|
|
|
request_state_change.call_func('crouch')
|
|
|
|
return
|
|
|
|
|
|
|
|
elif _wants_crouch != true and desired_movement_vector.x != 0:
|
|
|
|
elif _wants_crouch != true and desired_movement_vector.x != 0:
|
|
|
|
request_state_change.call_func('move')
|
|
|
|
request_state_change.call_func('move')
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#move_actor_as_desired()
|
|
|
|
#move_actor_as_desired()
|
|
|
|
apply_movement_to_parent(
|
|
|
|
apply_movement_to_parent(
|
|
|
|
|