Destroyable props

This commit is contained in:
Marco 2025-06-19 17:55:23 +02:00
commit 44ebc70448
52 changed files with 1387 additions and 18428 deletions

View file

@ -26,8 +26,6 @@ public partial class Bullet3D : Area3D, IBullet
private List<ModifierWrapper> _modifiers = new();
private GameManager _gameManager;
public bool IsGrazed { get; set; } = false;
public bool IsFrozen { get; private set; } = false;
@ -49,11 +47,10 @@ public partial class Bullet3D : Area3D, IBullet
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
}
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
public void Initialize(BulletInfo bulletInfo)
{
_bulletInfo = bulletInfo;
_gameManager = gameManager;
_elapsedTime = 0f;
@ -163,12 +160,12 @@ public partial class Bullet3D : Area3D, IBullet
public void FacePlayer()
{
if (_gameManager.Player != null)
{
//_direction = (_gameManager.PlayerPosition.Value - this.GlobalPosition).Normalized();
RotateBullet(0); // quick hack to rotate lasers
//LookAt(player.GlobalPosition);
}
// if (_gameManager.Player != null)
// {
// //_direction = (_gameManager.PlayerPosition.Value - this.GlobalPosition).Normalized();
// RotateBullet(0); // quick hack to rotate lasers
// //LookAt(player.GlobalPosition);
// }
}
@ -236,6 +233,16 @@ public partial class Bullet3D : Area3D, IBullet
private void _on_body_entered(Node3D body)
{
if (body.IsInGroup("Destroyable") && body is IDestructible destructible &&
CanHit(BulletOwner, destructible.BulletGroup))
{
// hit
destructible.Hit(Damage, DamageType);
RequestCollisionDestruction();
return;
}
if (body.IsInGroup("Solid"))
{
//Debug.WriteLine("Collision");

View file

@ -18,7 +18,7 @@ public interface IBullet
public delegate void OnDestroyEventHandler();
public void Initialize(BulletInfo bulletInfo, GameManager gameManager);
public void Initialize(BulletInfo bulletInfo);
public void Enable();
public void Disable(bool hideSprite = true);

View file

@ -182,7 +182,7 @@ public partial class Weapon3D : Node3D
GetBulletStrengthMultiplier(bulletData.Damage, bulletData.OriginalBulletResource.MaxDamage, 20);
}
bullet.Initialize(bulletData, _gameManager);
bullet.Initialize(bulletData);
//bullet.SetDirection(ShootDirection);
bullet.SetDirection(spreadDirection);