diff --git a/prefab/magics/curseOfTheUndead.tscn b/prefab/magics/curseOfTheUndead.tscn index f25cbde..6bd1640 100644 --- a/prefab/magics/curseOfTheUndead.tscn +++ b/prefab/magics/curseOfTheUndead.tscn @@ -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) diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 5258480..b64987b 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -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) { diff --git a/scripts/inventory/Packsack.cs b/scripts/inventory/Packsack.cs index bfaf81d..88e7a9c 100644 --- a/scripts/inventory/Packsack.cs +++ b/scripts/inventory/Packsack.cs @@ -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() { diff --git a/scripts/pickable/PickAbleTemplate.cs b/scripts/pickable/PickAbleTemplate.cs index 59e0dca..906c079 100644 --- a/scripts/pickable/PickAbleTemplate.cs +++ b/scripts/pickable/PickAbleTemplate.cs @@ -342,14 +342,14 @@ public partial class PickAbleTemplate : RigidBody2D, IItem /// Please copy node properties within this function /// 请在此函数内复制节点属性 /// - /// - public virtual void CopyAttributes(Node node) + /// + 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; } } \ No newline at end of file diff --git a/scripts/weapon/ProjectileWeapon.cs b/scripts/weapon/ProjectileWeapon.cs index aa45472..fe73fd0 100644 --- a/scripts/weapon/ProjectileWeapon.cs +++ b/scripts/weapon/ProjectileWeapon.cs @@ -113,11 +113,22 @@ public partial class ProjectileWeapon : WeaponTemplate { base._Ready(); _marker2D = GetNode("Marker2D"); - SelfItemContainer = new UniversalItemContainer(_numberSlots); - SelfItemContainer.AllowAddingItemByType(Config.ItemType.Spell); + if (SelfItemContainer == null) + { + SelfItemContainer = new UniversalItemContainer(_numberSlots); + SelfItemContainer.AllowAddingItemByType(Config.ItemType.Spell); + } } - private void OnItemDataChangeEvent(ItemDataChangeEvent itemDataChangeEvent) + /// + /// Update spell cache + /// 更新法术缓存 + /// + /// + ///This will parse available spells from inside the item container. + ///这将从物品容器内解析可用的法术。 + /// + 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();