mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-15 07:43:47 +00:00
Interactions
This commit is contained in:
parent
e1d6afa512
commit
abff2ea59e
19 changed files with 282 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Cirno.Scripts;
|
||||
|
||||
public partial class Barrel : Area2D, IDestructible
|
||||
{
|
||||
|
|
@ -11,8 +12,10 @@ public partial class Barrel : Area2D, IDestructible
|
|||
[Export] public float ExplosionDamage = 1;
|
||||
|
||||
[Export] public PackedScene DebrisScene { get; set; }
|
||||
|
||||
[Export] public PackedScene ExplosionParticles { get; set; }
|
||||
|
||||
private float _currentHealth;
|
||||
private float _currentHealth = 0f;
|
||||
|
||||
private bool _isDestroyed = false;
|
||||
|
||||
|
|
@ -30,19 +33,50 @@ public partial class Barrel : Area2D, IDestructible
|
|||
private void Explode()
|
||||
{
|
||||
Debug.WriteLine("Boom");
|
||||
CreateParticles();
|
||||
CreateDebris();
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
private void CreateDebris()
|
||||
{
|
||||
if (DebrisScene == null) return;
|
||||
var debris = DebrisScene.Instantiate<Barrel>();
|
||||
Owner.AddChild(debris);
|
||||
debris.Transform = this.GlobalTransform;
|
||||
debris.Position = this.Position;
|
||||
this.CreateChild<Barrel>(DebrisScene);
|
||||
|
||||
// if (DebrisScene == null) return;
|
||||
// var debris = DebrisScene.Instantiate<Barrel>();
|
||||
// Owner.CallDeferred("add_child", debris); //.AddChild(debris);
|
||||
// debris.Transform = this.GlobalTransform;
|
||||
// debris.Position = this.Position;
|
||||
}
|
||||
|
||||
private void CreateParticles()
|
||||
{
|
||||
|
||||
var particle = this.CreateChild<GpuParticles2D>(ExplosionParticles);
|
||||
if (particle == null) return;
|
||||
|
||||
particle.Emitting = true;
|
||||
|
||||
// if (ExplosionParticles == null) return;
|
||||
// var emitter = ExplosionParticles.Instantiate<GpuParticles2D>();
|
||||
// Owner.CallDeferred("add_child", emitter);
|
||||
// emitter.Transform = this.GlobalTransform;
|
||||
// emitter.Position = this.Position;
|
||||
//
|
||||
// emitter.Emitting = true;
|
||||
}
|
||||
|
||||
// private T CreateChild<T>(PackedScene prefab) where T : Node2D
|
||||
// {
|
||||
// if (prefab == null) return null;
|
||||
// var newInstance = prefab.Instantiate<T>();
|
||||
// Owner.CallDeferred("add_child", newInstance);
|
||||
// newInstance.Transform = this.GlobalTransform;
|
||||
// newInstance.Position = this.Position;
|
||||
//
|
||||
// return newInstance;
|
||||
// }
|
||||
|
||||
public void Hit(float damage)
|
||||
{
|
||||
if (_isDestroyed) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue