mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 23:11:54 +08:00
refactor(资源加载): 将preload替换为load以优化内存使用
统一使用load方法动态加载资源,减少启动时的内存占用 移动Manager类到Tools/Managers目录下 修复DirTool处理remap文件的问题
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 = preload("res://components/UI/DamageLabel.tscn").instantiate()
|
||||
var instance = load("res://components/UI/DamageLabel.tscn").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 = preload("res://components/Abstracts/SkillIconBase.tscn").instantiate()
|
||||
var icon: SkillIcon = load("res://components/Abstracts/SkillIconBase.tscn").instantiate()
|
||||
icon.weapon = i
|
||||
UIState.skillIconContainer.add_child(icon)
|
||||
else:
|
||||
@@ -266,7 +266,7 @@ func tryAttack(type: int, needChargeUp: bool = false):
|
||||
if state:
|
||||
if needChargeUp:
|
||||
charginup = true
|
||||
await EffectController.create(preload("res://components/Effects/AttackStar.tscn"), damageAnchor.global_position).shot()
|
||||
await EffectController.create(load("res://components/Effects/AttackStar.tscn"), damageAnchor.global_position).shot()
|
||||
charginup = false
|
||||
if isPlayer():
|
||||
if await weapon.tryAttack(self):
|
||||
@@ -317,7 +317,7 @@ func tryDie(by: BulletBase = null):
|
||||
if isPlayer():
|
||||
if UIState.player == self:
|
||||
UIState.setPanel("GameOver", [displayName, by.launcher.displayName, by.displayName])
|
||||
EffectController.create(preload("res://components/Effects/DeadBlood.tscn"), texture.global_position).shot()
|
||||
EffectController.create(load("res://components/Effects/DeadBlood.tscn"), texture.global_position).shot()
|
||||
await die()
|
||||
died.emit()
|
||||
queue_free()
|
||||
|
||||
@@ -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 = preload("res://components/UI/FieldShow.tscn").instantiate()
|
||||
var fieldShow = load("res://components/UI/FieldShow.tscn").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 = preload("res://components/UI/ItemDropped.tscn").instantiate()
|
||||
var instance: ItemDropped = load("res://components/UI/ItemDropped.tscn").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 = preload("res://components/UI/ItemShow.tscn").instantiate()
|
||||
var item = load("res://components/UI/ItemShow.tscn").instantiate()
|
||||
item.type = itemType
|
||||
item.count = itemCount
|
||||
item.autoFree = isAutoFree
|
||||
|
||||
Reference in New Issue
Block a user