using System; using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/WaveBullets.cs")] public partial class WaveBullets : Node2D { [Export(PropertyHint.None, "")] private Node2D[] bullets; [Export(PropertyHint.None, "")] private NodePath holder; [Export(PropertyHint.None, "")] public float delay = 30f; [Export(PropertyHint.None, "")] public float variance = 5f; [Export(PropertyHint.None, "")] public float maxAngle = 35f; [Export(PropertyHint.None, "")] public float angleVariance; [Export(PropertyHint.None, "")] public float speed = 1f; [Export(PropertyHint.None, "")] public int skip = 2; [Export(PropertyHint.None, "")] public int skipVariance = 1; [Export(PropertyHint.None, "")] private int bulletsPerWave = 10; [Export(PropertyHint.None, "")] private Vector2 direction; [Export(PropertyHint.None, "")] private bool usePlayerDirection = true; [Export(PropertyHint.None, "")] private bool initialDelay; [Export(PropertyHint.None, "")] private AudioStream sound; [Export(PropertyHint.None, "")] private float soundVolume = 1f; private List bulletObjs = new List(); private Node2D actualHolder; private float cd; private float angle; public override void _EnterTree() { if (initialDelay) { cd = delay; } angle = (float)Math.PI * 2f / maxAngle; if (holder == null || holder.IsEmpty || holder.ToString().Length < 1) { actualHolder = this; } else { actualHolder = GetNode(holder); } } public override void _Process(double delta) { if (cd > 0f) { cd -= Main.deltaTime; return; } cd = delay + Main.RandomRange(0f - variance, variance); if (usePlayerDirection) { direction = base.GlobalPosition.DirectionTo(DWMenu.instance.soulBody.GlobalPosition); } int num = Main.RandomRange(0, skipVariance); int num2 = Main.RandomRange(0, bulletsPerWave); float num3 = Main.RandomRange(0f - angleVariance, angleVariance); if (sound != null) { Audio.PlaySound(sound, soundVolume); } int i = 0; int num4 = skip + num; for (; i < bulletsPerWave + skip; i++) { if (num4 > 0 && i >= num2) { num4--; continue; } int num5 = Main.RandomRange(0, bullets.Length - 1); float weight = (float)i / (float)bulletsPerWave; Vector2 vector = direction.Rotated(Mathf.DegToRad(Mathf.Lerp(0f, maxAngle, weight) - maxAngle / 2f + num3)); bulletObjs.Add((Node2D)bullets[num5].Duplicate()); Node2D node2D = actualHolder; List list = bulletObjs; node2D.AddChild(list[list.Count - 1], forceReadableName: false, InternalMode.Disabled); List list2 = bulletObjs; list2[list2.Count - 1].GlobalPosition = base.GlobalPosition; List list3 = bulletObjs; Main.SetActive(list3[list3.Count - 1], state: true); List list4 = bulletObjs; if (list4[list4.Count - 1] is MoveAhead moveAhead) { moveAhead.speed = vector * speed; } } } }