Fable test
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user