Updated WeaponTemplate's FiringInterval calculation so that it can be changed by FiringIntervalAsMillisecond even after instantiation.
更新了WeaponTemplate的FiringInterval计算方式以使该值即便在实例化之后也可通过FiringIntervalAsMillisecond更改
This commit is contained in:
parent
197930f446
commit
edaa490b5b
|
@ -16,6 +16,7 @@ collision_mask = 34
|
|||
script = ExtResource("1_w8hhv")
|
||||
ProjectileScenes = [ExtResource("2_34250")]
|
||||
Id = "staff_of_the_undead"
|
||||
FiringIntervalAsMillisecond = 300
|
||||
metadata/Projectiles = PackedStringArray("res://prefab/projectile/curseOfTheUndead.tscn")
|
||||
|
||||
[node name="DamageArea2D" type="Area2D" parent="."]
|
||||
|
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using ColdMint.scripts.camp;
|
||||
using ColdMint.scripts.character;
|
||||
using ColdMint.scripts.damage;
|
||||
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.item.weapon;
|
||||
|
@ -70,7 +71,16 @@ public abstract partial class WeaponTemplate : RigidBody2D, IItem
|
|||
/// <para>开火间隔</para>
|
||||
/// </summary>
|
||||
private TimeSpan _firingInterval;
|
||||
[Export] private long _firingIntervalAsMillisecond = 100;
|
||||
private long _firingIntervalAsMillisecond = 100;
|
||||
[Export] protected long FiringIntervalAsMillisecond
|
||||
{
|
||||
get => _firingIntervalAsMillisecond;
|
||||
set
|
||||
{
|
||||
_firingIntervalAsMillisecond = value;
|
||||
_firingInterval = TimeSpan.FromMilliseconds(_firingIntervalAsMillisecond);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -101,8 +111,6 @@ public abstract partial class WeaponTemplate : RigidBody2D, IItem
|
|||
_damageArea2D = GetNode<Area2D>("DamageArea2D");
|
||||
_damageArea2D.BodyEntered += OnBodyEnter;
|
||||
_damageArea2D.BodyExited += OnBodyExited;
|
||||
|
||||
_firingInterval = TimeSpan.FromMilliseconds(_firingIntervalAsMillisecond);
|
||||
}
|
||||
|
||||
private void OnBodyExited(Node node)
|
||||
|
|
Loading…
Reference in New Issue
Block a user