2023-11-09 16:22:52 -08:00
|
|
|
using Godot;
|
2024-09-16 12:33:29 -07:00
|
|
|
using SupaLidlGame.Extensions;
|
2023-11-09 16:22:52 -08:00
|
|
|
|
|
|
|
namespace SupaLidlGame.Items.Weapons;
|
|
|
|
|
|
|
|
public partial class Bow : ProjectileSpawner
|
|
|
|
{
|
|
|
|
protected bool _isOnFire = false;
|
|
|
|
|
|
|
|
protected Area2D _ignitionArea;
|
|
|
|
|
2024-07-06 22:51:09 -07:00
|
|
|
protected override Entities.Projectile SpawnProjectile(Scenes.Map map,
|
2023-11-09 16:22:52 -08:00
|
|
|
Vector2 direction, float velocityModifier = 1)
|
|
|
|
{
|
2024-07-06 22:51:09 -07:00
|
|
|
var projectile = base.SpawnProjectile(map, direction, velocityModifier);
|
|
|
|
|
|
|
|
if (_isOnFire)
|
|
|
|
{
|
2024-09-16 12:33:29 -07:00
|
|
|
var flame = GetNode<AnimatedSprite2D>("%Flame");
|
|
|
|
|
|
|
|
var newFlame = flame.Duplicate() as Node2D;
|
|
|
|
projectile.AddChild(newFlame);
|
|
|
|
|
|
|
|
newFlame.Position = Vector2.Zero;
|
|
|
|
|
|
|
|
flame.Visible = false;
|
2024-07-06 22:51:09 -07:00
|
|
|
// TODO: instead of doing 1.5x damage, create an "On Fire" debuff
|
|
|
|
projectile.Hitbox.Damage *= 1.5f;
|
|
|
|
_isOnFire = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return projectile;
|
2023-11-09 16:22:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
base._Ready();
|
|
|
|
_ignitionArea = GetNode<Area2D>("IgnitionArea");
|
2024-07-06 22:51:09 -07:00
|
|
|
var onAreaEntered = (Area2D area) =>
|
2023-11-09 16:22:52 -08:00
|
|
|
{
|
2024-09-16 12:33:29 -07:00
|
|
|
if (!_isOnFire)
|
|
|
|
{
|
|
|
|
var flame = GetNode<AnimatedSprite2D>("%Flame");
|
|
|
|
flame.Visible = true;
|
|
|
|
flame.GetNode<AudioStreamPlayer2D>("Ignite")
|
|
|
|
.OnWorld()
|
|
|
|
.PlayOneShot();
|
|
|
|
_isOnFire = true;
|
|
|
|
}
|
2023-11-09 16:22:52 -08:00
|
|
|
};
|
2024-07-06 22:51:09 -07:00
|
|
|
_ignitionArea.Connect(
|
|
|
|
Area2D.SignalName.AreaEntered,
|
|
|
|
Callable.From(onAreaEntered));
|
2023-11-09 16:22:52 -08:00
|
|
|
}
|
|
|
|
}
|