Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -49,8 +49,10 @@ func _activate(_world, activator, position):
|
||||
else:
|
||||
assert(false, "who are you, activator?")
|
||||
|
||||
func discard(world, activator, do_ability):
|
||||
func discard(_world, activator, do_ability):
|
||||
ammo = max_ammo
|
||||
if do_ability:
|
||||
activator.dash(_activate);
|
||||
|
||||
func get_ammo():
|
||||
return ammo
|
||||
|
||||
@@ -29,9 +29,7 @@ var charge_level = 0;
|
||||
var charge_rate = 1;
|
||||
var charged = false;
|
||||
|
||||
var dash_cooldown_timer = 0;
|
||||
var dash_on_cooldown = false;
|
||||
|
||||
var dash_cooldown_timer: Timer = Timer.new()
|
||||
var knockback_timer: Timer = Timer.new()
|
||||
|
||||
func get_target_pos():
|
||||
@@ -70,36 +68,30 @@ func charge():
|
||||
# Gradual charge dropoff
|
||||
charge_level = max(charge_level - charge_rate * 2, 0);
|
||||
|
||||
func dash():
|
||||
if dash_on_cooldown:
|
||||
return;
|
||||
|
||||
hand.discard(); # Must set move_state at start and end of dash
|
||||
dash_on_cooldown = true;
|
||||
|
||||
func dash(on_end: Callable):
|
||||
dash_cooldown_timer.start(dash_cooldown);
|
||||
var target_dir = position.direction_to(target)
|
||||
dash_cooldown_timer.timeout.connect(func(): on_end.call(null, self, target_dir), CONNECT_ONE_SHOT);
|
||||
velocity = move_direction * speed * 5;
|
||||
|
||||
func _ready():
|
||||
screen_size = get_viewport_rect().size
|
||||
knockback_timer.one_shot = true
|
||||
dash_cooldown_timer.one_shot = true
|
||||
add_child(knockback_timer);
|
||||
add_child(dash_cooldown_timer);
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta):
|
||||
update_target_coords();
|
||||
update_camera_position();
|
||||
if (move_state != MoveState.Dashing):
|
||||
update_move_direction();
|
||||
|
||||
if (dash_on_cooldown):
|
||||
dash_cooldown_timer += delta;
|
||||
if (dash_cooldown_timer >= dash_cooldown):
|
||||
dash_on_cooldown = false;
|
||||
dash_cooldown_timer = 0;
|
||||
|
||||
# handle move_state
|
||||
if knockback_timer.time_left > 0:
|
||||
if knockback_timer.time_left > 0 or dash_cooldown_timer.time_left > 0:
|
||||
pass
|
||||
elif Input.is_action_just_pressed("dash"):
|
||||
dash();
|
||||
hand.discard(); # Must set move_state at start and end of dash
|
||||
elif (move_state != MoveState.Dashing):
|
||||
velocity = move_direction * speed;
|
||||
if velocity.x || velocity.y:
|
||||
|
||||
Reference in New Issue
Block a user