mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-10 13:47:12 +08:00
refactor(资源管理): 集中资源加载逻辑到ComponentManager
将分散在各处的资源加载逻辑统一到ComponentManager中管理 添加对UI组件、主题、物品纹理和饲料的集中管理 移除SkillIconBase.tscn并迁移到UI目录
This commit is contained in:
@@ -33,7 +33,7 @@ func _ready():
|
||||
queue_free()
|
||||
|
||||
static func create(spawnDamage: float, spawnCrit: bool, spawnPosition: Vector2, addToWorld: bool = true) -> DamageLabel:
|
||||
var instance = load("res://components/UI/DamageLabel.tscn").instantiate()
|
||||
var instance = ComponentManager.getUIComponent("DamageLabel").instantiate()
|
||||
instance.damage = spawnDamage
|
||||
instance.crit = spawnCrit
|
||||
instance.position = spawnPosition
|
||||
|
||||
@@ -126,7 +126,7 @@ func _ready():
|
||||
UIState.energyPercent.setCurrent(newEnergy)
|
||||
)
|
||||
for i in weapons:
|
||||
var icon: SkillIcon = load("res://components/Abstracts/SkillIconBase.tscn").instantiate()
|
||||
var icon: SkillIcon = ComponentManager.getUIComponent("SkillIcon").instantiate()
|
||||
icon.weapon = i
|
||||
UIState.skillIconContainer.add_child(icon)
|
||||
else:
|
||||
|
||||
@@ -37,7 +37,7 @@ func _ready():
|
||||
valueLabel.label_settings.font_color = Color(1, 1, 1)
|
||||
|
||||
static func create(newField: FieldStore.Entity, newValue: float, newShowSign: bool, newEntity: EntityBase, newUseViewCast: bool) -> FieldShow:
|
||||
var fieldShow = load("res://components/UI/FieldShow.tscn").instantiate()
|
||||
var fieldShow = ComponentManager.getUIComponent("FieldShow").instantiate()
|
||||
fieldShow.field = newField
|
||||
fieldShow.value = newValue
|
||||
fieldShow.showSign = newShowSign
|
||||
|
||||
@@ -50,7 +50,7 @@ static func generate(
|
||||
spawnPosition: Vector2,
|
||||
addToWorld: bool = true
|
||||
):
|
||||
var instance: ItemDropped = load("res://components/UI/ItemDropped.tscn").instantiate()
|
||||
var instance: ItemDropped = ComponentManager.getUIComponent("ItemDropped").instantiate()
|
||||
instance.item = itemType
|
||||
instance.stackCount = count
|
||||
instance.position = spawnPosition
|
||||
|
||||
@@ -23,7 +23,7 @@ func _physics_process(_delta):
|
||||
countLabel.text = str(count)
|
||||
|
||||
static func generate(itemType: ItemStore.ItemType, itemCount: int = 1, isAutoFree: bool = false):
|
||||
var item = load("res://components/UI/ItemShow.tscn").instantiate()
|
||||
var item = ComponentManager.getUIComponent("ItemShow").instantiate()
|
||||
item.type = itemType
|
||||
item.count = itemCount
|
||||
item.autoFree = isAutoFree
|
||||
|
||||
Reference in New Issue
Block a user