Files
mtgodot-poc/project/part_hiding.gd
T

60 lines
2.9 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.
# part_hiding.gd —— §4.1 修改 4:变身 / 时装的部位遮挡规则(InstanceBase.cpp 1:1)。
#
# 纯函数,无状态。EquipModel.refresh() 在解出身体 shape 后调用,决定武器 / 盾 / 头发
# 是否该隐藏、身体 shape 是否被变身强制归零。远端角色换装走同一条路(EquipModel 是
# 「渲染别的玩家用的同一条路」)。
#
# 参考 REF/UserInterface/InstanceBase*.cpp
# IsPoly() -> SetShape(0)SetWeapon / SetParts 提前 return
# -> 身体 shape 归 0、无武器、无头发 / 挂件
# __IsShapeAnimalWear() -> GetShape() ∈ {100,101,102,103}SetWeapon(:2747) 与
# SetParts 返回 false -> 穿动物 / 怪物时装时武器 + 头发被抑制
# IsWearingDress() -> m_eShape == 201(婚纱);__IsChangableWeapon(iWeaponID)
# (:901) 除 c_iBouquets 外一律 false -> 非捧花时武器隐藏
# (头发不受婚纱影响)
# __ArmorVnumToShape() -> shape = item_proto values[3]vnum ∉ {0,1} 且
# USE_ARMOR_SPECULAR),否则 shape = vnum
extends RefCounted
const POLY_SHAPE := 0
const ANIMAL_WEAR_SHAPES := [100, 101, 102, 103] # __IsShapeAnimalWear
const WEDDING_DRESS_SHAPE := 201 # IsWearingDress
const BOUQUET_VNUMS := [50201, 50202, 50203, 50204] # c_iBouquets(原表 0 结尾)
static func is_animal_wear(shape: int) -> bool:
return shape in ANIMAL_WEAR_SHAPES
static func is_wearing_dress(shape: int) -> bool:
return shape == WEDDING_DRESS_SHAPE
static func is_bouquet(weapon_vnum: int) -> bool:
return weapon_vnum in BOUQUET_VNUMS
# __IsChangableWeapon:婚纱状态只有捧花可换,其它 shape 一律可换。
static func is_changable_weapon(weapon_vnum: int, shape: int) -> bool:
if is_wearing_dress(shape):
return is_bouquet(weapon_vnum)
return true
# 武器(含盾,走同一挂点规则)是否该隐藏:变身 / 动物时装 / 婚纱且非捧花。
static func weapon_hidden(shape: int, is_poly: bool, weapon_vnum: int = 0) -> bool:
if is_poly:
return true
if is_animal_wear(shape):
return true
if is_wearing_dress(shape) and not is_bouquet(weapon_vnum):
return true
return false
# 头发 / 挂件是否该隐藏:变身 / 动物时装(婚纱不影响头发)。
static func hair_hidden(shape: int, is_poly: bool) -> bool:
return is_poly or is_animal_wear(shape)
# 身体 shape:变身强制 0SetShape(0)),否则原样(动物时装 100-103 保留,用来出时装体)。
static func body_shape(shape: int, is_poly: bool) -> int:
return POLY_SHAPE if is_poly else shape
# 有效武器 vnum:被隐藏则 0SetWeapon 提前 return 的等效结果)。
static func effective_weapon(weapon_vnum: int, shape: int, is_poly: bool) -> int:
return 0 if weapon_hidden(shape, is_poly, weapon_vnum) else weapon_vnum