diff --git a/prefab/projectile/curseOfTheUndead.tscn b/prefab/projectile/curseOfTheUndead.tscn
index 8f16dfa..3aefe50 100644
--- a/prefab/projectile/curseOfTheUndead.tscn
+++ b/prefab/projectile/curseOfTheUndead.tscn
@@ -15,7 +15,6 @@ _maxDamage = 10
_minDamage = 1
_damageType = 2
Speed = 500.0
-_enableTracking = true
_targetDiesDestroyProjectile = true
_repelStrength = 2.5
diff --git a/scripts/character/AiCharacter.cs b/scripts/character/AiCharacter.cs
index 32abb5c..41e910f 100644
--- a/scripts/character/AiCharacter.cs
+++ b/scripts/character/AiCharacter.cs
@@ -180,6 +180,7 @@ public sealed partial class AiCharacter : CharacterTemplate
//You must create an item container for the character before you can pick up the item.
//必须为角色创建物品容器后才能拾起物品。
var universalItemContainer = new UniversalItemContainer(1);
+ universalItemContainer.AllowAddingItemByType(Config.ItemType.ProjectileWeapon);
ProtectedItemContainer = universalItemContainer;
//Add initial weapon
//添加初始武器
diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs
index b64987b..fab0371 100644
--- a/scripts/character/CharacterTemplate.cs
+++ b/scripts/character/CharacterTemplate.cs
@@ -481,10 +481,10 @@ public partial class CharacterTemplate : CharacterBody2D
if (_currentItem is IItem item)
{
- item.Use(this, position);
+ return item.Use(this, position);
}
- return true;
+ return false;
}
public override void _Process(double delta)
diff --git a/scripts/inventory/IItem.cs b/scripts/inventory/IItem.cs
index 185c316..92e4745 100644
--- a/scripts/inventory/IItem.cs
+++ b/scripts/inventory/IItem.cs
@@ -126,7 +126,11 @@ public interface IItem
///
/// Owner of current item, if any
/// Target position, such as the position of the cursor when used by the player
- void Use(Node2D? owner, Vector2 targetGlobalPosition);
+ ///
+ ///Whether it was successfully executed
+ ///是否成功被执行了
+ ///
+ bool Use(Node2D? owner, Vector2 targetGlobalPosition);
///
/// When the item is thrown
diff --git a/scripts/inventory/Packsack.cs b/scripts/inventory/Packsack.cs
index 88e7a9c..906450c 100644
--- a/scripts/inventory/Packsack.cs
+++ b/scripts/inventory/Packsack.cs
@@ -18,9 +18,13 @@ public partial class Packsack : PickAbleTemplate
get => Config.ItemType.Packsack;
}
[Export] public int NumberSlots { get; set; }
- public override void Use(Node2D? owner, Vector2 targetGlobalPosition)
+ public override bool Use(Node2D? owner, Vector2 targetGlobalPosition)
{
- GameSceneDepend.DynamicUiGroup?.ShowControl(Path, control =>
+ if (GameSceneDepend.DynamicUiGroup == null)
+ {
+ return false;
+ }
+ return GameSceneDepend.DynamicUiGroup.ShowControl(Path, control =>
{
if (control is PacksackUi packsackUi)
{
diff --git a/scripts/inventory/PlaceholderItem.cs b/scripts/inventory/PlaceholderItem.cs
index 419599c..e0d1ec7 100644
--- a/scripts/inventory/PlaceholderItem.cs
+++ b/scripts/inventory/PlaceholderItem.cs
@@ -50,8 +50,9 @@ public class PlaceholderItem : IItem
return null;
}
- public void Use(Node2D? owner, Vector2 targetGlobalPosition)
+ public bool Use(Node2D? owner, Vector2 targetGlobalPosition)
{
+ return false;
}
public void OnThrow(Vector2 velocity)
diff --git a/scripts/pickable/PickAbleTemplate.cs b/scripts/pickable/PickAbleTemplate.cs
index 906c079..93a1ac3 100644
--- a/scripts/pickable/PickAbleTemplate.cs
+++ b/scripts/pickable/PickAbleTemplate.cs
@@ -182,8 +182,9 @@ public partial class PickAbleTemplate : RigidBody2D, IItem
return Math.Min(freeQuantity, unallocatedQuantity);
}
- public virtual void Use(Node2D? owner, Vector2 targetGlobalPosition)
+ public virtual bool Use(Node2D? owner, Vector2 targetGlobalPosition)
{
+ return false;
}
public virtual void OnThrow(Vector2 velocity)
diff --git a/scripts/weapon/WeaponTemplate.cs b/scripts/weapon/WeaponTemplate.cs
index 43dd365..a45a591 100644
--- a/scripts/weapon/WeaponTemplate.cs
+++ b/scripts/weapon/WeaponTemplate.cs
@@ -25,9 +25,9 @@ public abstract partial class WeaponTemplate : PickAbleTemplate
_audioStreamPlayer2D = GetNodeOrNull("Marker2D/AudioStreamPlayer2D");
}
- public override void Use(Node2D? owner, Vector2 targetGlobalPosition)
+ public override bool Use(Node2D? owner, Vector2 targetGlobalPosition)
{
- Fire(owner, targetGlobalPosition);
+ return Fire(owner, targetGlobalPosition);
}
@@ -77,15 +77,16 @@ public abstract partial class WeaponTemplate : PickAbleTemplate
///敌人所在位置
///
///
- public void Fire(Node2D? owner, Vector2 enemyGlobalPosition)
+ public bool Fire(Node2D? owner, Vector2 enemyGlobalPosition)
{
var nowTime = DateTime.Now;
//If the present time minus the time of the last fire is less than the interval between fires, it means that the fire cannot be fired yet.
//如果现在时间减去上次开火时间小于开火间隔,说明还不能开火。
if (_lastFiringTime != null && nowTime - _lastFiringTime < _firingInterval)
{
- return;
+ return false;
}
+ _lastFiringTime = nowTime;
var result = DoFire(owner, enemyGlobalPosition);
if (result)
{
@@ -96,10 +97,9 @@ public abstract partial class WeaponTemplate : PickAbleTemplate
characterTemplate.AddForce(enemyGlobalPosition.DirectionTo(characterTemplate.GlobalPosition) * _recoilStrength * Config.CellSize);
}
}
-
_audioStreamPlayer2D?.Play();
}
- _lastFiringTime = nowTime;
+ return result;
}
///