diff --git a/ColdMint.Traveler.csproj b/ColdMint.Traveler.csproj
index dafdfc5..ec53ff3 100644
--- a/ColdMint.Traveler.csproj
+++ b/ColdMint.Traveler.csproj
@@ -6,5 +6,9 @@
true
ColdMint
enable
+ 12
+
+
+
\ No newline at end of file
diff --git a/locals/Item.csv b/locals/Item.csv
index 3741a2b..7085a40 100644
--- a/locals/Item.csv
+++ b/locals/Item.csv
@@ -1,5 +1,5 @@
id,zh,en,ja
-staff_of_the_undead,死灵法杖,StaffOfTheUndead,ネクロポリスの杖です
-staff_of_the_undead_desc,发射诅咒,可将敌人转化为邪恶的怪物。,Cast a curse that transforms enemies into evil monsters.,呪いを発射して、敵を邪悪な怪物に変えることができます。
-packsack,背包,Packsack,背嚢
-packsack_desc,可以装载更多物品的背包。,A backpack that can hold more items.,より多くのアイテムを保持できるバックパックです。
\ No newline at end of file
+item_staff_of_the_undead,死灵法杖,StaffOfTheUndead,ネクロポリスの杖です
+item_staff_of_the_undead_desc,发射诅咒,可将敌人转化为邪恶的怪物。,Cast a curse that transforms enemies into evil monsters.,呪いを発射して、敵を邪悪な怪物に変えることができます。
+item_packsack,背包,Packsack,背嚢
+item_packsack_desc,可以装载更多物品的背包。,A backpack that can hold more items.,より多くのアイテムを保持できるバックパックです。
\ No newline at end of file
diff --git a/locals/Item.en.translation b/locals/Item.en.translation
index 1c8ae52..f16d6d9 100644
Binary files a/locals/Item.en.translation and b/locals/Item.en.translation differ
diff --git a/locals/Item.ja.translation b/locals/Item.ja.translation
index 27c8bbc..29758ae 100644
Binary files a/locals/Item.ja.translation and b/locals/Item.ja.translation differ
diff --git a/locals/Item.zh.translation b/locals/Item.zh.translation
index b775a9f..013e7ca 100644
Binary files a/locals/Item.zh.translation and b/locals/Item.zh.translation differ
diff --git a/locals/Log.en.translation b/locals/Log.en.translation
index 3b2867b..26a2d18 100644
Binary files a/locals/Log.en.translation and b/locals/Log.en.translation differ
diff --git a/locals/Log.ja.translation b/locals/Log.ja.translation
index ae0f924..bcce44b 100644
Binary files a/locals/Log.ja.translation and b/locals/Log.ja.translation differ
diff --git a/locals/Log.zh.translation b/locals/Log.zh.translation
index a879ff0..b618fc9 100644
Binary files a/locals/Log.zh.translation and b/locals/Log.zh.translation differ
diff --git a/locals/Slogan.ja.translation b/locals/Slogan.ja.translation
index e44c84c..db766f6 100644
Binary files a/locals/Slogan.ja.translation and b/locals/Slogan.ja.translation differ
diff --git a/locals/slogan.en.translation b/locals/slogan.en.translation
index afca762..77ebe61 100644
Binary files a/locals/slogan.en.translation and b/locals/slogan.en.translation differ
diff --git a/locals/slogan.zh.translation b/locals/slogan.zh.translation
index 357757f..04ff434 100644
Binary files a/locals/slogan.zh.translation and b/locals/slogan.zh.translation differ
diff --git a/prefab/packsacks/packsack.tscn b/prefab/packsacks/packsack.tscn
index 3599009..a6ec43c 100644
--- a/prefab/packsacks/packsack.tscn
+++ b/prefab/packsacks/packsack.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://cn10fimoem04m"]
-[ext_resource type="Script" path="res://scripts/inventory/Packsack.cs" id="1_8ehup"]
+[ext_resource type="Script" path="res://scripts/item/Packsack.cs" id="1_slakl"]
[ext_resource type="Texture2D" uid="uid://b1twcink38sh0" path="res://sprites/Player.png" id="2_e1ale"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xqyue"]
@@ -9,12 +9,7 @@ size = Vector2(41, 57)
[node name="RigidBody2D" type="RigidBody2D"]
collision_layer = 8
collision_mask = 38
-script = ExtResource("1_8ehup")
-metadata/Id = "Packsack"
-metadata/MaxStackQuantity = 1
-metadata/Icon = ExtResource("2_e1ale")
-metadata/Name = "packsack"
-metadata/Description = "packsack_desc"
+script = ExtResource("1_slakl")
[node name="Player" type="Sprite2D" parent="."]
texture = ExtResource("2_e1ale")
diff --git a/prefab/weapons/staffOfTheUndead.tscn b/prefab/weapons/staffOfTheUndead.tscn
index 91488d1..d4732bf 100644
--- a/prefab/weapons/staffOfTheUndead.tscn
+++ b/prefab/weapons/staffOfTheUndead.tscn
@@ -1,8 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://dnnn2xyayiehk"]
[ext_resource type="Texture2D" uid="uid://e6670ykyq145" path="res://sprites/weapon/staffOfTheUndead.png" id="1_ms3us"]
-[ext_resource type="Script" path="res://scripts/weapon/ProjectileWeapon.cs" id="1_w8hhv"]
-[ext_resource type="Texture2D" uid="uid://b2blj0yf4ohx3" path="res://icon.svg" id="2_l5lni"]
+[ext_resource type="Script" path="res://scripts/item/weapon/ProjectileWeapon.cs" id="1_w8hhv"]
+[ext_resource type="PackedScene" uid="uid://c01av43yk1q71" path="res://prefab/projectile/curseOfTheUndead.tscn" id="2_34250"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_obcq2"]
size = Vector2(49, 5)
@@ -14,13 +14,9 @@ size = Vector2(49, 5.25)
collision_layer = 8
collision_mask = 34
script = ExtResource("1_w8hhv")
+ProjectileScenes = [ExtResource("2_34250")]
+Id = "staff_of_the_undead"
metadata/Projectiles = PackedStringArray("res://prefab/projectile/curseOfTheUndead.tscn")
-metadata/Name = "staff_of_the_undead"
-metadata/FiringIntervalArray = PackedInt64Array(5000, 500, 250)
-metadata/Icon = ExtResource("2_l5lni")
-metadata/ID = "StaffOfTheUndead"
-metadata/MaxStackQuantity = 1
-metadata/Description = "staff_of_the_undead_desc"
[node name="DamageArea2D" type="Area2D" parent="."]
collision_layer = 8
diff --git a/scripts/behaviorTree/ai/AiPickNode.cs b/scripts/behaviorTree/ai/AiPickNode.cs
index 12ffdfd..727fbdd 100644
--- a/scripts/behaviorTree/ai/AiPickNode.cs
+++ b/scripts/behaviorTree/ai/AiPickNode.cs
@@ -1,5 +1,6 @@
using ColdMint.scripts.character;
-using ColdMint.scripts.weapon;
+
+using ColdMint.scripts.item.weapon;
namespace ColdMint.scripts.behaviorTree.ai;
diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs
index f8b6891..dac5540 100644
--- a/scripts/character/CharacterTemplate.cs
+++ b/scripts/character/CharacterTemplate.cs
@@ -1,13 +1,16 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+
using ColdMint.scripts.camp;
using ColdMint.scripts.damage;
using ColdMint.scripts.debug;
using ColdMint.scripts.health;
using ColdMint.scripts.inventory;
+using ColdMint.scripts.item;
using ColdMint.scripts.utils;
-using ColdMint.scripts.weapon;
+using ColdMint.scripts.item.weapon;
+
using Godot;
namespace ColdMint.scripts.character;
@@ -38,14 +41,7 @@ public partial class CharacterTemplate : CharacterBody2D
//Item containers are used to store items.
//物品容器用于存储物品。
- private IItemContainer? _itemContainer;
-
-
- public IItemContainer? ItemContainer
- {
- get => _itemContainer;
- set => _itemContainer = value;
- }
+ public IItemContainer? ItemContainer { get; set; }
//Items currently held
//当前持有的物品
@@ -69,11 +65,9 @@ public partial class CharacterTemplate : CharacterBody2D
///Update finished items
///更新完成后的物品
///
- protected virtual void WhenUpdateCurrentItem(Node2D? currentItem)
- {
- }
+ protected virtual void WhenUpdateCurrentItem(Node2D? currentItem) { }
- //Define a pick up range
+ //Define a pickup range
//定义一个拾起范围
private Area2D? _pickingArea;
@@ -128,7 +122,7 @@ public partial class CharacterTemplate : CharacterBody2D
///
protected List? PickingRangeBodiesList;
- public Node[] PickingRangeBodies => PickingRangeBodiesList?.ToArray() ?? Array.Empty();
+ public Node[] PickingRangeBodies => PickingRangeBodiesList?.ToArray() ?? [];
///
/// Resurrected character
@@ -161,7 +155,7 @@ public partial class CharacterTemplate : CharacterBody2D
}
///
- /// Find the nearest item within the pick up area(Does not include items currently held)
+ /// Find the nearest item within the pickup area(Does not include items currently held)
/// 在拾捡范围内查找距离最近的物品(不包括当前持有的物品)
///
///
@@ -185,7 +179,7 @@ public partial class CharacterTemplate : CharacterBody2D
///
- /// Get all weapons within range of the pick up
+ /// Get all weapons within range of the pickup
/// 获取所有在拾捡范围内的武器
///
///
@@ -211,8 +205,8 @@ public partial class CharacterTemplate : CharacterBody2D
base._Ready();
PickingRangeBodiesList = new List();
CharacterName = GetMeta("Name", Name).AsString();
- CampId = GetMeta("CampId", Config.CampId.Default).AsString();
- MaxHp = GetMeta("MaxHp", Config.DefaultMaxHp).AsInt32();
+ CampId = GetMeta("CampId", Config.CampId.Default).AsString();
+ MaxHp = GetMeta("MaxHp", Config.DefaultMaxHp).AsInt32();
var lootListId = GetMeta("LootListId", string.Empty).AsString();
if (!string.IsNullOrEmpty(lootListId))
{
@@ -282,14 +276,14 @@ public partial class CharacterTemplate : CharacterBody2D
return false;
}
- if (_itemContainer == null)
+ if (ItemContainer == null)
{
return false;
}
//Get the currently selected node
//拿到当前选择的节点
- var itemSlotNode = _itemContainer.GetSelectItemSlotNode();
+ var itemSlotNode = ItemContainer.GetSelectItemSlotNode();
if (itemSlotNode == null)
{
return false;
@@ -297,7 +291,7 @@ public partial class CharacterTemplate : CharacterBody2D
//First check if we can pick up the item.
//先检查我们能否拾起此物品。
- var canPick = _itemContainer.CanAddItem(item);
+ var canPick = ItemContainer.CanAddItem(item);
if (!canPick)
{
return false;
@@ -305,7 +299,7 @@ public partial class CharacterTemplate : CharacterBody2D
//Is it successfully added to the container?
//再检查是否成功的添加到容器内了?
- var addSuccess = _itemContainer.AddItem(item);
+ var addSuccess = ItemContainer.AddItem(item);
if (!addSuccess)
{
return false;
@@ -320,7 +314,7 @@ public partial class CharacterTemplate : CharacterBody2D
weaponTemplate.Owner = this;
weaponTemplate.Picked = true;
weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Platform, false);
- weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, false);
+ weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, false);
weaponTemplate.EnableContactInjury = false;
weaponTemplate.Sleeping = true;
}
@@ -354,9 +348,9 @@ public partial class CharacterTemplate : CharacterBody2D
return false;
}
- if (_currentItem is WeaponTemplate weaponTemplate)
+ if (_currentItem is IItem item)
{
- weaponTemplate.Fire(this, position);
+ item.Use(this, position);
}
return true;
@@ -407,7 +401,7 @@ public partial class CharacterTemplate : CharacterBody2D
{
if (targetCamp.Id == playerCamp.Id)
{
- //If an attack is allowed and you are on the same side, it is displayed as a friendly color (friend damage).
+ //If an attack is allowed, and you are on the same side, it is displayed as a friendly color (friend damage).
//如果允许攻击,且属于同一阵营,则显示为友好颜色(友伤)
_healthBar.SetFriendlyTones();
}
@@ -491,8 +485,8 @@ public partial class CharacterTemplate : CharacterBody2D
///
///
public void GenerateLootObjects(Node parentNode,
- LootData[] lootDataArray,
- Vector2 position)
+ LootData[] lootDataArray,
+ Vector2 position)
{
LootListManager.GenerateLootObjects(parentNode, lootDataArray, position);
}
@@ -507,9 +501,7 @@ public partial class CharacterTemplate : CharacterBody2D
_additionalForce = force;
}
- protected virtual void OnHit(DamageTemplate damageTemplate)
- {
- }
+ protected virtual void OnHit(DamageTemplate damageTemplate) { }
///
/// Handle the event of character death
@@ -590,12 +582,12 @@ public partial class CharacterTemplate : CharacterBody2D
{
//If the item container is null, then return
//如果物品容器为null,那么返回
- if (_itemContainer == null)
+ if (ItemContainer == null)
{
return;
}
- var len = _itemContainer.GetItemSlotCount();
+ var len = ItemContainer.GetItemSlotCount();
if (len == 0)
{
return;
@@ -625,8 +617,8 @@ public partial class CharacterTemplate : CharacterBody2D
/// 抛出物品
///
///
- ///Item slot subscript in item container
- ///物品容器内的物品槽下标
+ ///Item slot index in item container
+ ///物品容器内的物品槽位置
///
///
/// How many to throw
@@ -640,22 +632,39 @@ public partial class CharacterTemplate : CharacterBody2D
///
protected void ThrowItem(int index, int number, Vector2 velocity)
{
- if (_itemContainer == null)
- {
- return;
- }
+ var itemSlotNode = ItemContainer?.GetItemSlotNode(index);
+ if (itemSlotNode is null) return;
- var itemSlotNode = _itemContainer.GetItemSlotNode(index);
- if (itemSlotNode == null)
+ if (number < 0)
{
- return;
+ while (!itemSlotNode.IsEmpty())
+ {
+ ThrowOneItem(itemSlotNode, velocity);
+ }
}
+ else
+ {
+ for (int i = 0; i < number && !itemSlotNode.IsEmpty(); i++)
+ {
+ ThrowOneItem(itemSlotNode, velocity);
+ }
+ }
+ }
- var item = itemSlotNode.GetItem();
- if (item == null)
- {
- return;
- }
+ ///
+ /// Throw item
+ /// 抛出物品
+ ///
+ ///
+ ///
+ /// The speed to be applied to the item
+ /// 要施加到物品上的速度
+ ///
+ private void ThrowOneItem(ItemSlotNode itemSlotNode, Vector2 velocity)
+ {
+ //Pick an item from the item container
+ //从物品容器内取出一个物品
+ var item = itemSlotNode.PickItem();
if (item is not Node2D node2D)
{
@@ -681,7 +690,7 @@ public partial class CharacterTemplate : CharacterBody2D
//We cannot immediately resume the physical collision when the weapon is discharged, which will cause the weapon to collide with the ground and platform earlier, preventing the weapon from flying.
//仍出武器时,我们不能立即恢复物理碰撞,立即恢复会导致武器更早的与地面和平台碰撞,阻止武器的飞行。
weaponTemplate.EnableContactInjury = true;
- weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, true);
+ weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Ground, true);
weaponTemplate.SetCollisionMaskValue(Config.LayerNumber.Platform, true);
timer.QueueFree();
};
@@ -706,17 +715,6 @@ public partial class CharacterTemplate : CharacterBody2D
rigidBody2D.LinearVelocity = velocity;
break;
}
-
- //Remove items from the item container
- //在物品容器内移除物品
- if (number < 0)
- {
- itemSlotNode.RemoveItem(item.Quantity);
- }
- else
- {
- itemSlotNode.RemoveItem(number);
- }
}
///
diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs
index ff084d4..cc8b4b9 100644
--- a/scripts/character/Player.cs
+++ b/scripts/character/Player.cs
@@ -1,13 +1,16 @@
using System;
using System.Text;
using System.Threading.Tasks;
+
using ColdMint.scripts.damage;
using ColdMint.scripts.deathInfo;
using ColdMint.scripts.debug;
using ColdMint.scripts.inventory;
+using ColdMint.scripts.item;
using ColdMint.scripts.map.events;
using ColdMint.scripts.utils;
-using ColdMint.scripts.weapon;
+using ColdMint.scripts.item.weapon;
+
using Godot;
namespace ColdMint.scripts.character;
@@ -103,7 +106,7 @@ public partial class Player : CharacterTemplate
operationTipBuilder.Append(Config.OperationTipActionColor);
operationTipBuilder.Append(']');
operationTipBuilder.Append(
- TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_down")[0].AsText()));
+ TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_down")[0].AsText()));
operationTipBuilder.Append("[/color]");
operationTipBuilder.Append(TranslationServerUtils.Translate("jump_down"));
}
@@ -117,7 +120,7 @@ public partial class Player : CharacterTemplate
operationTipBuilder.Append(Config.OperationTipActionColor);
operationTipBuilder.Append(']');
operationTipBuilder.Append(
- TranslationServerUtils.Translate(InputMap.ActionGetEvents("pick_up")[0].AsText()));
+ TranslationServerUtils.Translate(InputMap.ActionGetEvents("pick_up")[0].AsText()));
operationTipBuilder.Append("[/color]");
operationTipBuilder.Append(TranslationServerUtils.Translate("pick_up"));
operationTipLabel.Text = operationTipBuilder.ToString();
@@ -140,7 +143,7 @@ public partial class Player : CharacterTemplate
operationTipBuilder.Append(Config.OperationTipActionColor);
operationTipBuilder.Append(']');
operationTipBuilder.Append(
- TranslationServerUtils.Translate(InputMap.ActionGetEvents("use_item")[0].AsText()));
+ TranslationServerUtils.Translate(InputMap.ActionGetEvents("use_item")[0].AsText()));
operationTipBuilder.Append("[/color]");
operationTipBuilder.Append(TranslationServerUtils.Translate("use_item"));
operationTipBuilder.Append(TranslationServerUtils.Translate(item.Name));
@@ -244,8 +247,8 @@ public partial class Player : CharacterTemplate
}
_parabola.Points = CurrentItem == null
- ? _emptyVector2Array
- : ParabolicUtils.ComputeParabolic(ItemMarker2D.Position, GetThrowVelocity(), Gravity, 0.1f);
+ ? _emptyVector2Array
+ : ParabolicUtils.ComputeParabolic(ItemMarker2D.Position, GetThrowVelocity(), Gravity, 0.1f);
}
@@ -402,9 +405,9 @@ public partial class Player : CharacterTemplate
{
var rotationDegreesNode2D = node2D.RotationDegrees;
var rotationDegreesNode2DAbs = Math.Abs(rotationDegreesNode2D);
- _floatLabel.Position = rotationDegreesNode2DAbs > 90
- ? new Vector2(0, PromptTextDistance)
- : new Vector2(0, -PromptTextDistance);
+ _floatLabel.Position = rotationDegreesNode2DAbs > 90
+ ? new Vector2(0, PromptTextDistance)
+ : new Vector2(0, -PromptTextDistance);
_floatLabel.RotationDegrees = 0 - rotationDegreesNode2D;
var label = _floatLabel.GetNode