From ba1be5fb5e1cd2aaa86e96d998417743871ddc3c 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: Sun, 14 Dec 2025 14:44:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=AD=A6=E5=99=A8=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AD=A6=E5=99=A8=E8=B5=84=E6=BA=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=B9=B6=E5=9C=A8=E9=9D=9E=E8=B0=83=E8=AF=95=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=B8=AD=E5=88=9D=E5=A7=8B=E5=8C=96=E7=B4=AB=E8=89=B2?= =?UTF-8?q?=E6=B0=B4=E6=99=B6=E6=AD=A6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在ComponentManager中添加武器资源管理功能,支持从指定目录加载武器资源 对于非调试版本的游戏,自动为玩家初始化紫色水晶武器 --- scripts/Statemachine/EntityBase.gd | 4 ++++ scripts/Tools/Managers/ComponentManager.gd | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 36f1c9c..12227f5 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -122,6 +122,10 @@ func _ready(): if isPlayer(): if displayName == MultiplayerState.playerName: UIState.player = self + if !OS.is_debug_build(): + for i in weaponStore.get_children(): + i.free() + weaponStore.add_child(ComponentManager.getWeapon("PurpleCrystal").instantiate()) for i in weaponStore.get_children(): i.hide() weapons.append(i) diff --git a/scripts/Tools/Managers/ComponentManager.gd b/scripts/Tools/Managers/ComponentManager.gd index 704e519..16a9c24 100644 --- a/scripts/Tools/Managers/ComponentManager.gd +++ b/scripts/Tools/Managers/ComponentManager.gd @@ -4,6 +4,7 @@ class_name ComponentManager static var bullets = {} static var characters = {} +static var weapons = {} static var summons = {} static var effects = {} static var feeds = [] @@ -17,6 +18,8 @@ static func init(): bullets[DirTool.getBasenameWithoutExtension(i)] = load(i) for i in DirTool.listdir("res://components/Characters"): characters[DirTool.getBasenameWithoutExtension(i)] = load(i) + for i in DirTool.listdir("res://components/Weapons"): + weapons[DirTool.getBasenameWithoutExtension(i)] = load(i) for i in DirTool.listdir("res://components/Summons"): summons[DirTool.getBasenameWithoutExtension(i)] = load(i) for i in DirTool.listdir("res://components/Effects"): @@ -35,6 +38,8 @@ static func getBullet(t: String) -> PackedScene: return MathTool.priority(bullets.get(t, false), load("res://components/Bullets/%s.tscn" % t)) static func getCharacter(t: String) -> PackedScene: return MathTool.priority(characters.get(t, false), load("res://components/Characters/%s.tscn" % t)) +static func getWeapon(t: String) -> PackedScene: + return MathTool.priority(weapons.get(t, false), load("res://components/Weapons/%s.tscn" % t)) static func getSummon(t: String) -> PackedScene: return MathTool.priority(summons.get(t, false), load("res://components/Summons/%s.tscn" % t)) static func getEffect(t: String) -> PackedScene: