Bullet resource

This commit is contained in:
Marco 2025-02-12 16:20:55 +01:00
commit 07f6e58ebd
19 changed files with 236 additions and 50 deletions

View file

@ -1,6 +1,7 @@
using Godot;
using System;
using System.Diagnostics;
using Cirno.Scripts;
using Cirno.Scripts.Components;
using Cirno.Scripts.Resources;
@ -111,7 +112,7 @@ public partial class Bullet : Area2D
private void _on_visible_on_screen_notifier_2d_screen_exited()
{
//Debug.WriteLine("Destroy bullet out of screen");
QueueFree();
Destroy();
}
private void _on_body_entered(Node2D body)
@ -119,7 +120,7 @@ public partial class Bullet : Area2D
if (body.IsInGroup("Solid"))
{
//Debug.WriteLine("Collision");
QueueFree();
Destroy();
}
//// Do not Collide with body for purpose of destroying bullets
// else if (body.IsInGroup("Destroyable"))
@ -134,7 +135,7 @@ public partial class Bullet : Area2D
{
if (area.IsInGroup("Solid"))
{
QueueFree();
Destroy();
return;
}
@ -144,9 +145,21 @@ public partial class Bullet : Area2D
destructible.Hit(Damage, DamageType);
QueueFree();
Destroy();
}
}
public void Destroy()
{
if (_bulletInfo?.DestructionParticlesScene != null)
{
var particle = this.CreateSibling<AutodeleteParticle>(_bulletInfo.DestructionParticlesScene);
particle.Init();
}
QueueFree();
}
}
public enum BulletOwner