mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-13 04:45:54 +00:00
Explosions for bullets
This commit is contained in:
parent
8e784be1aa
commit
8ab4546579
9 changed files with 58 additions and 11 deletions
|
|
@ -24,7 +24,7 @@ public partial class BulletEmitter : Node2D, IActivable
|
|||
|
||||
private BulletSpawner _bulletSpawner;
|
||||
|
||||
private bool _isEmitting = false;
|
||||
protected bool IsEmitting = false;
|
||||
|
||||
private double _emitTimer = 0f;
|
||||
|
||||
|
|
@ -33,13 +33,14 @@ public partial class BulletEmitter : Node2D, IActivable
|
|||
_bulletSpawner = GetNode<BulletSpawner>("BulletSpawner");
|
||||
if (EmitOnStart)
|
||||
{
|
||||
_isEmitting = true;
|
||||
IsEmitting = true;
|
||||
CallDeferred(MethodName.Shoot);
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (!_isEmitting) return;
|
||||
if (!IsEmitting) return;
|
||||
_emitTimer += delta;
|
||||
|
||||
if (_emitTimer >= EmitCoolDown)
|
||||
|
|
@ -60,17 +61,17 @@ public partial class BulletEmitter : Node2D, IActivable
|
|||
{
|
||||
case ActivationType.Open:
|
||||
case ActivationType.Enable:
|
||||
_isEmitting = true;
|
||||
IsEmitting = true;
|
||||
_emitTimer = 0;
|
||||
break;
|
||||
case ActivationType.Close:
|
||||
case ActivationType.Disable:
|
||||
_isEmitting = false;
|
||||
IsEmitting = false;
|
||||
_emitTimer = 0;
|
||||
break;
|
||||
case ActivationType.Use:
|
||||
case ActivationType.Toggle:
|
||||
_isEmitting = !_isEmitting;
|
||||
IsEmitting = !IsEmitting;
|
||||
_emitTimer = 0;
|
||||
break;
|
||||
case ActivationType.Destroy:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ public partial class WeaponAmmoCounter : Container
|
|||
public void Init(LootItem item)
|
||||
{
|
||||
Item = item;
|
||||
|
||||
Icon.Texture = item.InventorySprite;
|
||||
|
||||
InventoryManager.Instance.LoadedAmmoChanged += (weaponKey, count) =>
|
||||
{
|
||||
|
|
|
|||
24
Scripts/Weapons/AutoclearingBulletEmitter.cs
Normal file
24
Scripts/Weapons/AutoclearingBulletEmitter.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using Cirno.Scripts.Activables;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Weapons;
|
||||
|
||||
public partial class AutoclearingBulletEmitter : BulletEmitter
|
||||
{
|
||||
[Export]
|
||||
public float Timeout { get; private set; } = 5f;
|
||||
|
||||
private double _timeoutTimer = 0f;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
if (!IsEmitting) return;
|
||||
_timeoutTimer += delta;
|
||||
|
||||
if (_timeoutTimer >= Timeout)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Scripts/Weapons/AutoclearingBulletEmitter.cs.uid
Normal file
1
Scripts/Weapons/AutoclearingBulletEmitter.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://df81kn4u8yigu
|
||||
Loading…
Add table
Add a link
Reference in a new issue