Weapon evolution

This commit is contained in:
MaddoScientisto 2026-02-28 18:44:23 +01:00
commit f58b9646df
10 changed files with 209 additions and 68 deletions

View file

@ -2,6 +2,7 @@
using Cirno.Scripts.Resources;
using Cirno.Scripts.Utils;
using Cirno.Scripts.Weapons;
using Cirno.Scripts.Components.FSM.Enemy._3D;
using Godot;
using Godot.Collections;
@ -55,14 +56,24 @@ public partial class DamageReceiver3D : Area3D, IHittable
return;
}
;
if (BulletGroup is BulletOwner.None)
{
this.Hit(bullet.Damage, bullet.DamageType);
EmitSignalBulletHit(bullet, area.GlobalPosition, (this.GlobalPosition - area.GlobalPosition).Normalized());
// Attribute XP if this hit was lethal
if (HealthProvider.CurrentResource <= 0 && bullet.BulletInfo?.SourceWeapon != null)
{
int xp = 0;
if (GetParent() is EnemyProxy3D enemyProxy && enemyProxy.EnemyResource is not null)
{
xp = (int)System.Math.Round(enemyProxy.EnemyResource.MotivationReward);
}
bullet.BulletInfo.SourceWeapon.GainExperience(xp);
}
bullet.RequestCollisionDestruction();
return;
}
@ -73,6 +84,18 @@ public partial class DamageReceiver3D : Area3D, IHittable
EmitSignalBulletHit(bullet, area.GlobalPosition, (this.GlobalPosition - area.GlobalPosition).Normalized());
// Attribute XP on lethal hit
if (HealthProvider.CurrentResource <= 0 && bullet.BulletInfo?.SourceWeapon != null)
{
int xp = 0;
if (GetParent() is EnemyProxy3D enemyProxy && enemyProxy.EnemyResource is not null)
{
xp = (int)System.Math.Round(enemyProxy.EnemyResource.MotivationReward);
}
bullet.BulletInfo.SourceWeapon.GainExperience(xp);
}
bullet.RequestCollisionDestruction();
}