From ad5d2bce2de2cf92aa1264d6be521667bf6588a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Tue, 30 Sep 2025 17:39:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(Feed):=20=E6=B7=BB=E5=8A=A0=E5=AF=B9UIState?= =?UTF-8?q?.player=E6=97=A0=E6=95=88=E5=AE=9E=E4=BE=8B=E7=9A=84=E6=A3=80?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在multiplier()和rebuildInfo()方法中添加对UIState.player实例有效性的检查,防止当player无效时出现运行时错误 --- scripts/Structs/Feed.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/Structs/Feed.gd b/scripts/Structs/Feed.gd index 42863c0..f8493af 100644 --- a/scripts/Structs/Feed.gd +++ b/scripts/Structs/Feed.gd @@ -67,7 +67,10 @@ func apply(entity: EntityBase): func countOf(index: int) -> int: return ceil(costCounts[index] * multipiler()) func multipiler() -> float: - return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION) + if is_instance_valid(UIState.player): + return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION) + else: + return 1 func rebuildInfo(): avatarRect.texture = avatarTexture nameLabel.displayName = displayName @@ -83,7 +86,8 @@ func rebuildInfo(): var fieldShow: FieldShow = ComponentManager.getUIComponent("FieldShow").instantiate() fieldShow.field = field fieldShow.value = value - fieldShow.maxed = value + UIState.player.fields[field] > FieldStore.entityMaxValueMap.get(field, INF) + if is_instance_valid(UIState.player): + fieldShow.maxed = value + UIState.player.fields[field] > FieldStore.entityMaxValueMap.get(field, INF) fieldsBox.add_child(fieldShow) if noField: fieldsBox.add_child(QuickUI.smallText("无词条"))