I have no idea if I'm even going about this the right way, but I fear for refactoring my entire project.
I'm making a bullet hell game, and each boss battle is run through phases in the enemy class. The phase scripts reference the enemy node, and both handle & reference bullet spawning. If I want a bullet to turn mid-trajectory, I have to create a bullet as a variable, then give it its own function below. something like:
func attack():
while(can_enemy_attack):
var bullet: = spawn_bullet(args)
move_pattern(bullet)
await(timer1)
func move_pattern(bullet):
await (timer2)
bullet.angle += 90
There are walls surrounding the battles which the bullets can collide and dissipate on, player bombs which can erase bullets, and bullets will naturally despawn after existing long enough.
My question is, how should I handle and reference a bullet so that the game can ignore a deleted reference without having to type "if bullet != null" in front of every reference? is there an elegant solution to this?