Files
mtgodot-poc/project/pick_show.gd
T

70 lines
4.5 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# pick_show —— §8.8 / §5.4 game.py OnRender 的「Picking」块分派 1:1
# 每帧渲染时,textTail 的强显(ShowCharacterTextTail/ 全显(ShowAllTextTail/
# 拾取命中(chr.Pick / item.Pick / textTail.Pick)该走哪条,取决于
# wndMgr.IsPickedWindow(hWnd)(鼠标是否在 3D game 窗口上)与 __IsShowName()。
# 本模块把这棵判定树抽成纯静态谓词,供 net_world 的「悬停强显名字」用
# (仿增量 113 的 _target_vid forced 路数,给 _hover_vid 加第 5 路 forced)。
# (与 name_color.gd / text_tail.gd / chat_tail.gd / name_show.gd / damage_effect.gd /
# target_board.gd 同一套纯静态镜像套路,本模块是第 27 个 canonical。)
#
# REF40250 ClientVS22 source/ 为唯一基线;运行时 python 见 assets/root/game.py):
# root/game.py:1519 GameWindow.OnRender()
# root/game.py:1531 textTail.UpdateAllTextTail() —— 每帧先刷全部尾标
# root/game.py:1533 if True == wndMgr.IsPickedWindow(self.hWnd) —— 鼠标在 3D 窗口上才拾取
# root/game.py:1535 self.PickingCharacterIndex = chr.Pick() —— 射线拾取角色(-1 = 无)
# root/game.py:1537 if -1 != PickingCharacterIndex: textTail.ShowCharacterTextTail(idx)
# root/game.py:1539 if 0 != targetBoard.GetTargetVID(): textTail.ShowCharacterTextTail(targetVID)
# root/game.py:1543 if not self.__IsShowName(): PickingItemIndex = item.Pick() —— 只在「非总显名字」时拾取地面物品
# root/game.py:1546 if -1 != PickingItemIndex: textTail.ShowItemTextTail(idx)
# root/game.py:1552 if self.__IsShowName(): textTail.ShowAllTextTail() —— 总显名字:全显 + 从尾标里拾取
# root/game.py:1554 self.PickingItemIndex = textTail.Pick(x, y)
# root/game.py:1557 textTail.UpdateShowingTextTail()
# root/game.py:1558 textTail.ArrangeTextTail() —— 屏幕空间去重叠排布
# root/game.py:1560 if -1 != PickingItemIndex: textTail.SelectItemName(idx)
#
# seam ⑨:名字尾标 y = 聊天气泡 y 17pxPythonTextTail.cpp:112-114)尚未接入;
# 本 poc 名字牌是每实体一个 Label3D,暂无「随 chat 气泡下移」的整合。
# seam ⑩:ArrangeTextTail 的屏幕空间尾标去重叠排布(PythonTextTail.cpp ArrangeTextTail
# 仍缺——poc 名字牌是 3D billboard,靠深度天然分层,未做 2D 投影后的挤开。
# 本增量只收口其中一小块:把「悬停角色强显名字」按 :1535/:1537 补上(forced 第 5 路)。
# seam(近似):参考里 chr.Pick() 强显与 targetBoard 强显都在 :1533 的 IsPickedWindow 门内;
# poc 把 _target_vid(增量 113)与 _hover_vid(本增量)都当作「无条件 forced」路径——
# _hover_vid 在鼠标压 UI 时由 player_controller 主动置 0,算是部分等效于 IsPickedWindow 门。
extends RefCounted
# chr.Pick() / item.Pick() 的「无命中」哨兵。
const NO_PICK := -1
# :1533 —— 鼠标在 3D game 窗口上时,chr.Pick() 这一支才跑。
static func char_pick_active(is_picked_window: bool) -> bool:
return is_picked_window
# :1533..:1540 —— 本帧要 ShowCharacterTextTail(强显、绕过 __IsShowName)的 vid 集合:
# 悬停拾取到的角色(pick_char_vid,≈ poc 的 _hover_vid+ 目标框 VIDtarget_vid)。
# 两者都只在 is_picked_window 时收集;去重;0 / NO_PICK 视为无。
static func forced_name_vids(is_picked_window: bool, pick_char_vid: int, target_vid: int) -> Array:
var out: Array = []
if not is_picked_window:
return out
if pick_char_vid != NO_PICK and pick_char_vid != 0:
out.append(pick_char_vid) # :1537
if target_vid != 0 and not out.has(target_vid):
out.append(target_vid) # :1539
return out
# :1543 —— 只有「鼠标在窗口上」且「非总显名字」时才 item.Pick() 拾取地面物品。
static func should_pick_item(is_picked_window: bool, is_show_name: bool) -> bool:
return is_picked_window and not is_show_name
# :1552 —— 总显名字(__IsShowName())时才 ShowAllTextTail() 全量显名。
static func should_show_all_names(is_show_name: bool) -> bool:
return is_show_name
# :1554 —— 总显名字时,物品拾取改从已显的尾标里 textTail.Pick(x, y)。
static func should_pick_text_tail(is_show_name: bool) -> bool:
return is_show_name
# :1560 —— 拾取到物品尾标(PickingItemIndex != -1)才 SelectItemName 高亮其名。
static func should_select_item_name(pick_item_index: int) -> bool:
return pick_item_index != NO_PICK