Fixed item ID and its container being lost when throwing items. Pick up the weapon again can not fire the bullet issue.
修复扔出物品时,物品的ID与自身的物品容器丢失。再次捡起武器无法发射子弹的问题。
This commit is contained in:
parent
b7805c5804
commit
e718d78137
|
@ -4,11 +4,9 @@
|
|||
[ext_resource type="AudioStream" uid="uid://cak6chjjsu7wo" path="res://sounds/fire.wav" id="4_ffr2k"]
|
||||
[ext_resource type="Texture2D" uid="uid://bbcjkyrsx88av" path="res://sprites/projectile/curseOfTheUndead.png" id="4_y6nkf"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_obcq2"]
|
||||
size = Vector2(20, 21)
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_qgdry"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_14m1g"]
|
||||
size = Vector2(20, 20.75)
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_akp3k"]
|
||||
|
||||
[node name="curseOfTheUndead" type="RigidBody2D"]
|
||||
collision_layer = 8
|
||||
|
@ -23,11 +21,11 @@ collision_mask = 102
|
|||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageArea2D"]
|
||||
position = Vector2(0, -0.5)
|
||||
shape = SubResource("RectangleShape2D_obcq2")
|
||||
shape = SubResource("CircleShape2D_qgdry")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -0.625)
|
||||
shape = SubResource("RectangleShape2D_14m1g")
|
||||
shape = SubResource("CircleShape2D_akp3k")
|
||||
|
||||
[node name="Marker2D" type="Marker2D" parent="."]
|
||||
position = Vector2(65, 0)
|
||||
|
|
|
@ -9,6 +9,7 @@ using ColdMint.scripts.inventory;
|
|||
using ColdMint.scripts.utils;
|
||||
using ColdMint.scripts.loot;
|
||||
using ColdMint.scripts.pickable;
|
||||
using ColdMint.scripts.weapon;
|
||||
using Godot;
|
||||
using WeaponTemplate = ColdMint.scripts.weapon.WeaponTemplate;
|
||||
|
||||
|
@ -445,6 +446,10 @@ public partial class CharacterTemplate : CharacterBody2D
|
|||
pickAbleTemplate.Sleeping = true;
|
||||
}
|
||||
|
||||
if (pickAbleItemNode2D is ProjectileWeapon projectileWeapon)
|
||||
{
|
||||
projectileWeapon.UpdateSpellCache();
|
||||
}
|
||||
|
||||
if (_currentItem == null && ItemContainer.GetSelectItem() == item)
|
||||
{
|
||||
|
|
|
@ -44,15 +44,6 @@ public partial class Packsack : PickAbleTemplate
|
|||
GameSceneDepend.DynamicUiGroup?.HideControl(Path);
|
||||
}
|
||||
|
||||
public override void CopyAttributes(Node node)
|
||||
{
|
||||
base.CopyAttributes(node);
|
||||
if (node is Packsack packsack)
|
||||
{
|
||||
SelfItemContainer = packsack.SelfItemContainer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
|
@ -342,14 +342,14 @@ public partial class PickAbleTemplate : RigidBody2D, IItem
|
|||
/// <para>Please copy node properties within this function</para>
|
||||
/// <para>请在此函数内复制节点属性</para>
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
public virtual void CopyAttributes(Node node)
|
||||
/// <param name="originalNode"></param>
|
||||
public void CopyAttributes(Node originalNode)
|
||||
{
|
||||
if (node is not PickAbleTemplate pickAbleTemplate)
|
||||
if (originalNode is not PickAbleTemplate originalPickAbleTemplate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pickAbleTemplate.Id = Id;
|
||||
Id = originalPickAbleTemplate.Id;
|
||||
SelfItemContainer = originalPickAbleTemplate.SelfItemContainer;
|
||||
}
|
||||
}
|
|
@ -113,11 +113,22 @@ public partial class ProjectileWeapon : WeaponTemplate
|
|||
{
|
||||
base._Ready();
|
||||
_marker2D = GetNode<Marker2D>("Marker2D");
|
||||
if (SelfItemContainer == null)
|
||||
{
|
||||
SelfItemContainer = new UniversalItemContainer(_numberSlots);
|
||||
SelfItemContainer.AllowAddingItemByType(Config.ItemType.Spell);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemDataChangeEvent(ItemDataChangeEvent itemDataChangeEvent)
|
||||
/// <summary>
|
||||
/// <para>Update spell cache</para>
|
||||
/// <para>更新法术缓存</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>This will parse available spells from inside the item container.</para>
|
||||
///<para>这将从物品容器内解析可用的法术。</para>
|
||||
/// </remarks>
|
||||
public void UpdateSpellCache()
|
||||
{
|
||||
if (SelfItemContainer == null)
|
||||
{
|
||||
|
@ -148,6 +159,11 @@ public partial class ProjectileWeapon : WeaponTemplate
|
|||
}
|
||||
}
|
||||
|
||||
private void OnItemDataChangeEvent(ItemDataChangeEvent itemDataChangeEvent)
|
||||
{
|
||||
UpdateSpellCache();
|
||||
}
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
base._EnterTree();
|
||||
|
|
Loading…
Reference in New Issue
Block a user