mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-07-11 20:42:55 +08:00
refactor(Feed.gd): 移除冗余的UIState.player有效性检查
简化代码逻辑,假设UIState.player始终有效,移除多处不必要的有效性检查
This commit is contained in:
@@ -67,10 +67,7 @@ func apply(entity: EntityBase):
|
|||||||
func countOf(index: int) -> int:
|
func countOf(index: int) -> int:
|
||||||
return ceil(costCounts[index] * multipiler())
|
return ceil(costCounts[index] * multipiler())
|
||||||
func multipiler() -> float:
|
func multipiler() -> float:
|
||||||
if is_instance_valid(UIState.player):
|
return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION)
|
||||||
return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION)
|
|
||||||
else:
|
|
||||||
return 1
|
|
||||||
func rebuildInfo():
|
func rebuildInfo():
|
||||||
avatarRect.texture = avatarTexture
|
avatarRect.texture = avatarTexture
|
||||||
nameLabel.displayName = displayName
|
nameLabel.displayName = displayName
|
||||||
@@ -86,8 +83,7 @@ func rebuildInfo():
|
|||||||
var fieldShow: FieldShow = ComponentManager.getUIComponent("FieldShow").instantiate()
|
var fieldShow: FieldShow = ComponentManager.getUIComponent("FieldShow").instantiate()
|
||||||
fieldShow.field = field
|
fieldShow.field = field
|
||||||
fieldShow.value = value
|
fieldShow.value = value
|
||||||
if is_instance_valid(UIState.player):
|
fieldShow.maxed = value + UIState.player.fields[field] > FieldStore.entityMaxValueMap.get(field, INF)
|
||||||
fieldShow.maxed = value + UIState.player.fields[field] > FieldStore.entityMaxValueMap.get(field, INF)
|
|
||||||
fieldsBox.add_child(fieldShow)
|
fieldsBox.add_child(fieldShow)
|
||||||
if noField:
|
if noField:
|
||||||
fieldsBox.add_child(QuickUI.smallText("无词条"))
|
fieldsBox.add_child(QuickUI.smallText("无词条"))
|
||||||
@@ -96,8 +92,7 @@ func rebuildInfo():
|
|||||||
for weapon in weapons:
|
for weapon in weapons:
|
||||||
var weaponShow: WeaponShow = ComponentManager.getUIComponent("WeaponShow").instantiate()
|
var weaponShow: WeaponShow = ComponentManager.getUIComponent("WeaponShow").instantiate()
|
||||||
weaponShow.weapon = weapon
|
weaponShow.weapon = weapon
|
||||||
if is_instance_valid(UIState.player):
|
weaponShow.operation = WeaponShow.Operation.EXTRACT if UIState.player.weaponBag.has(weapon.instantiate().displayName) else WeaponShow.Operation.GET
|
||||||
weaponShow.operation = WeaponShow.Operation.EXTRACT if UIState.player.weaponBag.has(weapon.instantiate().displayName) else WeaponShow.Operation.GET
|
|
||||||
weaponShow.visible = true
|
weaponShow.visible = true
|
||||||
weaponsBox.add_child(weaponShow)
|
weaponsBox.add_child(weaponShow)
|
||||||
for i in costsBox.get_children():
|
for i in costsBox.get_children():
|
||||||
@@ -106,7 +101,7 @@ func rebuildInfo():
|
|||||||
var cost = costs[i]
|
var cost = costs[i]
|
||||||
var count = countOf(i)
|
var count = countOf(i)
|
||||||
var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate()
|
var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate()
|
||||||
costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= count
|
costShow.enough = UIState.player.inventory[cost] >= count
|
||||||
costShow.type = cost
|
costShow.type = cost
|
||||||
costShow.count = count
|
costShow.count = count
|
||||||
costsBox.add_child(costShow)
|
costsBox.add_child(costShow)
|
||||||
|
|||||||
Reference in New Issue
Block a user