diff --git a/locals/Log.csv b/locals/Log.csv
index 3b809ad..c4bf743 100644
--- a/locals/Log.csv
+++ b/locals/Log.csv
@@ -33,7 +33,7 @@ log_start_item_register_from_file,开始从文件注册物品信息,Start regist
log_found_files,找到{0}个文件,Found {0} files,{0}ファイルが見つかりました
log_found_item_types,从文件中找到{0}个物品类型,Found {0} item types in files,ファイルから{0}個のアイテム・タイプが見つかった
log_register_item,注册物品类型{0}结果为{1},Registered item type {0}; results in {1},登録されたアイテム・タイプ {0} の結果は {1} です。
-log_error_when_open_item_regs_dir,尝试打开物品信息目录时发生错误,错误代码:{1},"An error occurred when trying to open the item information directory, error code: {1}",アイテム情報ディレクトリを開こうとしてエラーが発生しました、エラーコード:{1}
+log_error_when_open_item_regs_dir,尝试打开物品信息目录{0}时发生错误,错误代码:{1},"An error occurred when trying to open the item information directory {0}, error code: {1}",アイテム情報ディレクトリ{0}を開こうとしてエラーが発生しました、エラーコード:{1}
log_wrong_custom_arg,不匹配的参数:类型为{0}而值为{1},Mismatched parameter: type {0} and value {1},パラメータの不一致:型{0}と値{1}。
log_item_container_is_null,物品容器为空,Item container is null,アイテム・コンテナが空です
log_item_has_no_owner,物品没有所有者,Item has no owner,アイテムに所有者がいません
@@ -101,4 +101,7 @@ log_mod_folder_does_not_exist,位于{0}的模组文件夹不存在。,The module
log_mod_not_contain_dll,模组{0}不包含DLL文件。,The module {0} does not contain a DLL file.,モジュール{0}にDLLファイルが含まれていません。
log_mod_not_contain_pck,模组{0}不包含PCK文件。,The module {0} does not contain a PCK file.,モジュール{0}にPCKファイルが含まれていません。
log_load_pck_success,成功加载位于{0}的PCK文件。,Successfully loaded the PCK file located at {0}.,{0}にあるPCKファイルを正常にロードしました。
-log_load_pck_failed,加载PCK文件{0}失败。,Failed to load the PCK file {0}.,PCKファイル{0}のロードに失敗しました。
\ No newline at end of file
+log_load_pck_failed,加载PCK文件{0}失败。,Failed to load the PCK file {0}.,PCKファイル{0}のロードに失敗しました。
+log_projectile_container_is_null,抛射体容器为空。,Projectile container is null.,射出体コンテナが空です。
+log_marker2d_is_null,Marker2D为空。,Marker2D is null.,Marker2Dが空です。
+log_owner_is_null,所有者为空。,Owner is null.,所有者が空です。
\ No newline at end of file
diff --git a/scripts/GameSceneNodeHolder.cs b/scripts/GameSceneNodeHolder.cs
index 6dc2f79..bdcd319 100644
--- a/scripts/GameSceneNodeHolder.cs
+++ b/scripts/GameSceneNodeHolder.cs
@@ -35,6 +35,12 @@ public static class GameSceneNodeHolder
}
}
+ ///
+ /// ProjectileContainer
+ /// 抛射体容器
+ ///
+ public static Node2D? ProjectileContainer { get; set; }
+
///
/// WeaponContainer
/// 武器容器
diff --git a/scripts/inventory/ItemTypeRegister.cs b/scripts/inventory/ItemTypeRegister.cs
index 1a2b071..200c893 100644
--- a/scripts/inventory/ItemTypeRegister.cs
+++ b/scripts/inventory/ItemTypeRegister.cs
@@ -31,12 +31,14 @@ public static class ItemTypeRegister
LogCat.Log("start_item_register_from_file");
//初始化文件目录
//initialize file dir
- var itemRegsDirPath = "res://data/itemRegs/";
+ var itemRegsDirPath = "res://data/itemRegs";
var itemRegsDir = DirAccess.Open(itemRegsDirPath);
var error = DirAccess.GetOpenError();
if (error is not Error.Ok)
{
- LogCat.LogError("error_when_open_item_regs_dir", error.ToString());
+ LogCat.LogErrorWithFormat("error_when_open_item_regs_dir", LogCat.LogLabel.Default, true, itemRegsDirPath,
+ error.ToString());
+ return;
}
//找到文件
diff --git a/scripts/loader/sceneLoader/GameSceneLoader.cs b/scripts/loader/sceneLoader/GameSceneLoader.cs
index f433c7d..50a3d16 100644
--- a/scripts/loader/sceneLoader/GameSceneLoader.cs
+++ b/scripts/loader/sceneLoader/GameSceneLoader.cs
@@ -39,6 +39,10 @@ public partial class GameSceneLoader : SceneLoaderTemplate
//加载武器容器
var weaponContainer = GetNode("WeaponContainer");
GameSceneNodeHolder.WeaponContainer = weaponContainer;
+ //Load projectile container
+ //加载抛射体容器
+ var projectileContainer = GetNode("ProjectileContainer");
+ GameSceneNodeHolder.ProjectileContainer = projectileContainer;
//Load Packsack container
//加载背包容器
var packsackContainer = GetNode("PacksackContainer");
diff --git a/scripts/utils/NodeUtils.cs b/scripts/utils/NodeUtils.cs
index 7d7224e..3a24ddb 100644
--- a/scripts/utils/NodeUtils.cs
+++ b/scripts/utils/NodeUtils.cs
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using ColdMint.scripts.debug;
+using ColdMint.scripts.projectile;
using Godot;
using Packsack = ColdMint.scripts.inventory.Packsack;
using PacksackUi = ColdMint.scripts.loader.uiLoader.PacksackUi;
@@ -235,6 +236,11 @@ public static class NodeUtils
///
public static Node FindContainerNode(Node childNode, Node defaultParentNode)
{
+ if (GameSceneNodeHolder.ProjectileContainer != null && childNode is Projectile)
+ {
+ return GameSceneNodeHolder.ProjectileContainer;
+ }
+
if (GameSceneNodeHolder.WeaponContainer != null && childNode is WeaponTemplate)
{
return GameSceneNodeHolder.WeaponContainer;
diff --git a/scripts/weapon/ProjectileWeapon.cs b/scripts/weapon/ProjectileWeapon.cs
index bb73e98..d3b0c8b 100644
--- a/scripts/weapon/ProjectileWeapon.cs
+++ b/scripts/weapon/ProjectileWeapon.cs
@@ -23,21 +23,33 @@ public partial class ProjectileWeapon : WeaponTemplate
[Export] protected PackedScene[] ProjectileScenes { get; set; } = [];
- private Node2D? _projectileContainer;
-
public override void _Ready()
{
base._Ready();
_marker2D = GetNode("Marker2D");
-
- _projectileContainer = GetNode("/root/Game/ProjectileContainer") as Node2D;
}
protected override void DoFire(Node2D? owner, Vector2 enemyGlobalPosition)
{
- if (owner == null || _projectileContainer == null || _marker2D == null) return;
+ if (owner == null)
+ {
+ LogCat.LogError("owner_is_null");
+ return;
+ }
+ if (_marker2D == null)
+ {
+ LogCat.LogError("marker2d_is_null");
+ return;
+ }
+
+ if (GameSceneNodeHolder.ProjectileContainer == null)
+ {
+ LogCat.LogError("projectile_container_is_null");
+ return;
+ }
+ //Empty list check
//空列表检查
if (ProjectileScenes is [])
{
@@ -51,7 +63,7 @@ public partial class ProjectileWeapon : WeaponTemplate
// var projectileScene = _projectileCache[_projectiles[0]];
var projectile = NodeUtils.InstantiatePackedScene(projectileScene);
if (projectile == null) return;
- NodeUtils.CallDeferredAddChild(_projectileContainer, projectile);
+ NodeUtils.CallDeferredAddChild(GameSceneNodeHolder.ProjectileContainer, projectile);
projectile.Owner = owner;
projectile.Velocity = (enemyGlobalPosition - _marker2D.GlobalPosition).Normalized() * projectile.Speed;
projectile.Position = _marker2D.GlobalPosition;