Fable test
This commit is contained in:
@@ -0,0 +1 @@
|
||||
uid://boknaojgo0qni
|
||||
@@ -0,0 +1 @@
|
||||
uid://borckhkljxkbb
|
||||
@@ -172,8 +172,14 @@ func on_cost_group_pick_request(req: Dictionary) -> void:
|
||||
var option_idx: int = 0
|
||||
for entry: Variant in entries:
|
||||
var entry_d: Dictionary = entry as Dictionary
|
||||
var label: String = str(entry_d.get("typestr", entry_d.get("typeStr", "Option %d" % (option_idx + 1))))
|
||||
var btn: Button = Button.new()
|
||||
# Keys are normalised to lowercase; the server serializes CostEntry.Type/Amount.
|
||||
var label: String = str(entry_d.get("type", ""))
|
||||
var amt: int = int(entry_d.get("amount", 0))
|
||||
if label.is_empty():
|
||||
label = "Option %d" % (option_idx + 1)
|
||||
elif amt > 0:
|
||||
label = "%s ×%d" % [label, amt]
|
||||
var btn: Button = Button.new()
|
||||
btn.text = label
|
||||
btn.add_theme_font_size_override("font_size", 12)
|
||||
var cap_idx: int = option_idx
|
||||
@@ -232,10 +238,11 @@ func on_action_group_pick_request(req: Dictionary) -> void:
|
||||
var option_idx: int = 0
|
||||
for act: Variant in actions:
|
||||
var act_d: Dictionary = act as Dictionary
|
||||
var label: String = str(act_d.get("label", "Action %d" % (option_idx + 1)))
|
||||
var label: String = str(act_d.get("label", ""))
|
||||
if label.is_empty():
|
||||
# Keys are normalised to lowercase; the target's type key is "type".
|
||||
var tgt: Dictionary = act_d.get("target", {}) as Dictionary
|
||||
label = "%s %s" % [tgt.get("ownership", ""), tgt.get("targetType", "")]
|
||||
label = "%s %s" % [tgt.get("ownership", ""), tgt.get("type", "")]
|
||||
label = label.strip_edges()
|
||||
if label.is_empty():
|
||||
label = "Action %d" % (option_idx + 1)
|
||||
|
||||
@@ -103,6 +103,25 @@ func _acquire_from_pool(card_type: String) -> StaticBody3D:
|
||||
return body
|
||||
|
||||
|
||||
func _set_body_click_collision_enabled(body: StaticBody3D, enabled: bool) -> void:
|
||||
if not is_instance_valid(body):
|
||||
return
|
||||
body.collision_layer = 1 if enabled else 0
|
||||
body.collision_mask = 1 if enabled else 0
|
||||
_set_descendant_click_collision_enabled(body, enabled)
|
||||
|
||||
|
||||
func _set_descendant_click_collision_enabled(node: Node, enabled: bool) -> void:
|
||||
if node is CollisionShape3D:
|
||||
(node as CollisionShape3D).disabled = not enabled
|
||||
if node is CollisionObject3D:
|
||||
var collision_object: CollisionObject3D = node as CollisionObject3D
|
||||
collision_object.collision_layer = 1 if enabled else 0
|
||||
collision_object.collision_mask = 1 if enabled else 0
|
||||
for child: Node in node.get_children():
|
||||
_set_descendant_click_collision_enabled(child, enabled)
|
||||
|
||||
|
||||
# ── Incremental rebuild ───────────────────────────────────────────────────────
|
||||
|
||||
## Incremental diff: add/remove units without recreating unchanged ones.
|
||||
@@ -317,6 +336,7 @@ func add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false,
|
||||
|
||||
if not _pool_hit:
|
||||
body.add_child(shape)
|
||||
_set_body_click_collision_enabled(body, card_type != "Ruin")
|
||||
body.add_child(mi)
|
||||
body.set_meta("above_tile", above_tile)
|
||||
body.position = wp + Vector3(0, tile_base + tile_h + above_tile, 0)
|
||||
@@ -422,6 +442,8 @@ func add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false,
|
||||
if raw_aabb.size != Vector3.ZERO:
|
||||
model_node.position.y = -above_tile - target_scale.y * raw_aabb.position.y
|
||||
unit_meshes[iid] = model_node
|
||||
if card_type == "Ruin":
|
||||
_set_body_click_collision_enabled(b, false)
|
||||
if Time.get_ticks_msec() <= int(materialize_until.get(iid, 0)):
|
||||
if ascend_arrival:
|
||||
_play_ascend_arrival_shader(model_node, team_color)
|
||||
@@ -1161,6 +1183,8 @@ func do_model_retry(iid: String, model_url: String, attempt: int, etag: String =
|
||||
if raw_aabb.size != Vector3.ZERO:
|
||||
model_node.position.y = -above_tile - target_scale.y * raw_aabb.position.y
|
||||
unit_meshes[iid] = model_node
|
||||
if card_type == "Ruin":
|
||||
_set_body_click_collision_enabled(body, false)
|
||||
var ap: AnimationPlayer = find_animation_player(model_node)
|
||||
anim_players[iid] = ap
|
||||
if ap != null:
|
||||
|
||||
@@ -555,8 +555,7 @@ func _on_board_clicked(screen_pos: Vector2) -> void:
|
||||
var unit_id: String = _mouse_to_unit_id(screen_pos)
|
||||
if unit_id.is_empty() and coord.x >= 0:
|
||||
var tile: Dictionary = Game.get_tile(coord.x, coord.y)
|
||||
var raw_occ: Variant = tile.get("occupantId")
|
||||
unit_id = str(raw_occ) if raw_occ != null else ""
|
||||
unit_id = _non_ruin_occupant_id(tile)
|
||||
_sel_ctrl.handle_board_click(screen_pos, coord, unit_id)
|
||||
_update_hover(screen_pos)
|
||||
if unit_id.is_empty():
|
||||
@@ -871,8 +870,7 @@ func _update_hover(mouse_pos: Vector2) -> void:
|
||||
if coord.x >= 0:
|
||||
tile = Game.get_tile(coord.x, coord.y)
|
||||
if occ_id.is_empty():
|
||||
var raw_occ: Variant = tile.get("occupantId")
|
||||
occ_id = str(raw_occ) if raw_occ != null else ""
|
||||
occ_id = _non_ruin_occupant_id(tile)
|
||||
if coord == _hovered_coord:
|
||||
return
|
||||
_reset_unit_hover_glow()
|
||||
@@ -1280,7 +1278,20 @@ func _mouse_to_unit_id(mouse_pos: Vector2) -> String:
|
||||
var body: PhysicsBody3D = _pathfinder.raycast_body(mouse_pos)
|
||||
if body == null:
|
||||
return ""
|
||||
return str(body.get_meta("unit_id", ""))
|
||||
var unit_id: String = str(body.get_meta("unit_id", ""))
|
||||
if _unit_reg != null and _unit_reg.is_ruin_instance(unit_id):
|
||||
return ""
|
||||
return unit_id
|
||||
|
||||
|
||||
func _non_ruin_occupant_id(tile: Dictionary) -> String:
|
||||
var raw_occ: Variant = tile.get("occupantId")
|
||||
var occupant_id: String = "" if raw_occ == null else str(raw_occ)
|
||||
if occupant_id.is_empty() or occupant_id == "null":
|
||||
return ""
|
||||
if _unit_reg != null and _unit_reg.is_ruin_instance(occupant_id):
|
||||
return ""
|
||||
return occupant_id
|
||||
|
||||
|
||||
func _terra_count_for_card(card: Dictionary) -> int:
|
||||
|
||||
Reference in New Issue
Block a user