mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 05:15:55 +00:00
Basic laser integration
This commit is contained in:
parent
d16f9b3b9d
commit
4011a7c6f6
15 changed files with 1028 additions and 284 deletions
|
|
@ -3,6 +3,7 @@
|
|||
namespace Cirno.Scripts.Actors._3D;
|
||||
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class LaserConfig : Resource
|
||||
{
|
||||
[Export] public float MaxLength = 50f;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,15 @@ namespace Cirno.Scripts.Actors;
|
|||
|
||||
public partial class BulletSpawner3D : Node3D
|
||||
{
|
||||
|
||||
public void SpawnBullet(BulletInfo bulletInfo, Vector3 position)
|
||||
{
|
||||
// Check if this is a laser
|
||||
if (bulletInfo.IsLaser && bulletInfo.LaserConfig != null)
|
||||
{
|
||||
SpawnLaser(bulletInfo, position);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = bulletInfo.BulletCount;
|
||||
|
||||
// Choose base direction (defaults to +X)
|
||||
|
|
@ -66,5 +72,28 @@ public partial class BulletSpawner3D : Node3D
|
|||
}
|
||||
}
|
||||
|
||||
private void SpawnLaser(BulletInfo bulletInfo, Vector3 position)
|
||||
{
|
||||
// Lasers don't use bullet count/spread the same way
|
||||
// Each laser is typically a single beam
|
||||
LaserBullet3D laser = PoolingManager.Instance.SpawnBullet<LaserBullet3D>(bulletInfo.OriginalBulletResource);
|
||||
laser.GlobalPosition = position;
|
||||
|
||||
// Apply modifiers if present
|
||||
if (bulletInfo.Modifier is not null)
|
||||
{
|
||||
bulletInfo = bulletInfo.Modifier.ModifyBullet(bulletInfo, 0, 1);
|
||||
}
|
||||
|
||||
laser.Initialize(bulletInfo);
|
||||
|
||||
// Set the laser direction
|
||||
Vector2 baseDirection = bulletInfo.Direction == Vector2.Zero
|
||||
? Vector2.Right
|
||||
: bulletInfo.Direction.Normalized();
|
||||
|
||||
laser.SetDirection(baseDirection);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue