diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 205e04f..1bcdf59 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -633,11 +633,9 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) if not def_id.is_empty(): _unit_def_ids[iid] = def_id if def_id.is_empty(): - print("[Anim] iid=%s no cardDefinitionId — skipping model" % iid) return var def := ContentCache.get_definition(def_id) var model_url := _find_model3d_url(def) - print("[Anim] iid=%s def_id=%s model_url=%s" % [iid, def_id.substr(0,8), model_url.substr(0, 60) if not model_url.is_empty() else "(none)"]) if model_url.is_empty(): return @@ -676,10 +674,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) var ap := _find_animation_player(model_node) _anim_players[iid] = ap if ap != null: - print("[Anim] iid=%s AnimationPlayer found. tracks=%s" % [iid, str(ap.get_animation_list())]) _play_unit_anim(iid, "idle", true) - else: - print("[Anim] iid=%s NO AnimationPlayer found in model tree" % iid) ) @@ -741,7 +736,6 @@ func _resolve_anim_track(ap: AnimationPlayer, action_lower: String) -> String: func _play_unit_anim(iid: String, action: String, loop: bool = false) -> void: var ap : AnimationPlayer = _anim_players.get(iid, null) if ap == null or not is_instance_valid(ap): - print("[Anim] _play_unit_anim('%s','%s') — no valid AnimationPlayer" % [iid, action]) return # Resolve via CardAnimationBinding override first. var def_id : String = _unit_def_ids.get(iid, "") @@ -751,22 +745,28 @@ func _play_unit_anim(iid: String, action: String, loop: bool = false) -> void: if not override.is_empty(): desired = override var track := _resolve_anim_track(ap, desired.to_lower()) - print("[Anim] _play_unit_anim('%s','%s') desired='%s' → track='%s'" % [iid, action, desired, track]) if track.is_empty(): return var anim := ap.get_animation(track) if anim == null: - print("[Anim] get_animation('%s') returned null!" % track) return anim.loop_mode = Animation.LOOP_LINEAR if loop else Animation.LOOP_NONE - if not loop and ap.current_animation == track and ap.is_playing(): - return # Don't restart the same one-shot animation mid-play. + # Don't restart the same animation while it's already playing correctly. + if ap.current_animation == track and ap.is_playing(): + return ap.play(track) - # Return to Idle after one-shot animations finish. + # For one-shot animations (not dying), queue idle immediately so the + # AnimationPlayer transitions with no bind-pose gap between them. if not loop: - ap.animation_finished.connect( - func(_n: String) -> void: _play_unit_anim(iid, "idle", true), - CONNECT_ONE_SHOT) + var action_l := action.to_lower() + var is_death := action_l == "dying" or action_l == "death" or action_l == "die" + if not is_death: + var idle_track := _resolve_anim_track(ap, "idle") + if not idle_track.is_empty(): + var idle_anim := ap.get_animation(idle_track) + if idle_anim != null: + idle_anim.loop_mode = Animation.LOOP_LINEAR + ap.queue(idle_track) ## Detect HP decreases and unit deaths vs previous state, and fire animations. @@ -886,8 +886,6 @@ func _animate_unit_move(iid: String, from_coord: Vector2i, to_coord: Vector2i, ## Detect position changes vs _prev_unit_pos and start move animations. ## Returns the maximum movement duration across all movers (seconds). func _play_move_animations(state: Dictionary) -> float: - print("[Move] _play_move_animations called. _prev_unit_pos.size=%d _unit_bodies.size=%d" \ - % [_prev_unit_pos.size(), _unit_bodies.size()]) if _prev_unit_pos.is_empty(): return 0.0 # Build the set of blocked tiles from old unit positions. @@ -905,19 +903,13 @@ func _play_move_animations(state: Dictionary) -> float: var new_coord := Vector2i((pd as Dictionary).get("x", 0), (pd as Dictionary).get("y", 0)) if not _prev_unit_pos.has(iid): - print("[Move] iid=%s not in _prev_unit_pos — skipping" % iid) continue var old_coord : Vector2i = _prev_unit_pos[iid] if old_coord == new_coord: continue - print("[Move] iid=%s moved %s→%s body_valid=%s" % [ - iid, str(old_coord), str(new_coord), - str(is_instance_valid(_unit_bodies.get(iid) as StaticBody3D))]) # Mover has left its old tile — unblock it for BFS. blocked.erase(old_coord) var dur := _animate_unit_move(iid, old_coord, new_coord, blocked) - print("[Move] _animate_unit_move returned dur=%.2f" % dur) max_dur = maxf(max_dur, dur) - print("[Move] max_dur=%.2f" % max_dur) return max_dur @@ -926,8 +918,6 @@ func _play_move_animations(state: Dictionary) -> float: ## but DO NOT cancel the running tween — this prevents rapid echo state-updates ## (phase changes, turn ticks) from killing an in-progress movement animation. func _schedule_rebuild(state: Dictionary, delay: float) -> void: - print("[Rebuild] _schedule_rebuild delay=%.2f tween_pending=%s" \ - % [delay, str(_rebuild_tween != null)]) _pending_rebuild = state # always target the latest state if delay <= 0.0: if _rebuild_tween != null: