diff --git a/Resources/BossPhases/Reimu/Reimu_NS1.tres b/Resources/BossPhases/Reimu/Reimu_NS1.tres index 6c10e95f..c6b9d6f8 100644 --- a/Resources/BossPhases/Reimu/Reimu_NS1.tres +++ b/Resources/BossPhases/Reimu/Reimu_NS1.tres @@ -1,11 +1,11 @@ [gd_resource type="Resource" script_class="BossPhase" load_steps=15 format=3 uid="uid://bu3a6hv5i1qam"] [ext_resource type="Script" uid="uid://cdd6q2h0t1hhq" path="res://Scripts/Resources/BossPhase.cs" id="1_4trvi"] -[ext_resource type="Resource" uid="uid://djjp4nyufqxlp" path="res://Resources/Bullets/Reimu_Card_Bullet_Red.tres" id="1_x3pjh"] +[ext_resource type="Resource" uid="uid://djjp4nyufqxlp" path="res://Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Red.tres" id="1_x3pjh"] [ext_resource type="Script" uid="uid://da0qevb67wh1i" path="res://Scripts/Resources/AttackPattern.cs" id="1_xjypu"] [ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="2_sai2e"] [ext_resource type="Script" uid="uid://c0ndqalsc4jve" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="3_xjypu"] -[ext_resource type="Resource" uid="uid://t2tbu5bfge4b" path="res://Resources/Bullets/Reimu_Card_Bullet_Blue.tres" id="5_8tj6w"] +[ext_resource type="Resource" uid="uid://t2tbu5bfge4b" path="res://Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Blue.tres" id="5_8tj6w"] [ext_resource type="Script" uid="uid://rqtkxuqmo7gi" path="res://Scripts/Resources/ScriptableBullets/ParallelPatternGroup.cs" id="5_vtvh5"] [ext_resource type="Script" uid="uid://cq7pfooyqayc4" path="res://Scripts/Resources/Modifiers/DelayedSpeedModifier.cs" id="6_8tj6w"] diff --git a/Resources/Bullets/Reimu_Card_Bullet_Blue.tres b/Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Blue.tres similarity index 80% rename from Resources/Bullets/Reimu_Card_Bullet_Blue.tres rename to Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Blue.tres index 934ce19f..cd524cf5 100644 --- a/Resources/Bullets/Reimu_Card_Bullet_Blue.tres +++ b/Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Blue.tres @@ -1,11 +1,11 @@ [gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://t2tbu5bfge4b"] -[ext_resource type="PackedScene" uid="uid://bdb2kledtug42" path="res://Scenes/Weapons/Bullets/enemyBullet_reimu_blue_small.tscn" id="1_371nf"] -[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_olcd3"] +[ext_resource type="PackedScene" uid="uid://bdb2kledtug42" path="res://Scenes/Weapons/Bullets/enemyBullet_reimu_blue_small.tscn" id="1_hv3jl"] +[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_mvqvb"] [resource] -script = ExtResource("2_olcd3") -BulletScene = ExtResource("1_371nf") +script = ExtResource("2_mvqvb") +BulletScene = ExtResource("1_hv3jl") BulletSpeed = 100.0 Direction = Vector2(1, 0) BulletDamage = 30.0 @@ -20,6 +20,6 @@ Controllable = false Freezable = true Grazeable = true GrazeValue = 1.0 -Attributes = 96 +Attributes = 98 TimeModifiers = [] metadata/_custom_type_script = "uid://dslyrfcej3g2n" diff --git a/Resources/Bullets/Reimu_Card_Bullet_Red.tres b/Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Red.tres similarity index 80% rename from Resources/Bullets/Reimu_Card_Bullet_Red.tres rename to Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Red.tres index 3969af19..d256bfc1 100644 --- a/Resources/Bullets/Reimu_Card_Bullet_Red.tres +++ b/Resources/Bullets/Boss/Reimu/Reimu_Card_Bullet_Red.tres @@ -1,11 +1,11 @@ [gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://djjp4nyufqxlp"] -[ext_resource type="PackedScene" uid="uid://db10ajastitm" path="res://Scenes/Weapons/Bullets/enemyBullet_reimu_red_small.tscn" id="1_ie3bo"] -[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_gj3rh"] +[ext_resource type="PackedScene" uid="uid://db10ajastitm" path="res://Scenes/Weapons/Bullets/enemyBullet_reimu_red_small.tscn" id="1_vfoj8"] +[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_72228"] [resource] -script = ExtResource("2_gj3rh") -BulletScene = ExtResource("1_ie3bo") +script = ExtResource("2_72228") +BulletScene = ExtResource("1_vfoj8") BulletSpeed = 100.0 Direction = Vector2(1, 0) BulletDamage = 30.0 @@ -20,6 +20,6 @@ Controllable = false Freezable = true Grazeable = true GrazeValue = 1.0 -Attributes = 96 +Attributes = 98 TimeModifiers = [] metadata/_custom_type_script = "uid://dslyrfcej3g2n" diff --git a/Resources/Bullets/Spider_Bomb_Bullet.tres b/Resources/Bullets/Spider_Bomb_Bullet.tres index 7123abc8..77ad32bf 100644 --- a/Resources/Bullets/Spider_Bomb_Bullet.tres +++ b/Resources/Bullets/Spider_Bomb_Bullet.tres @@ -22,6 +22,6 @@ Controllable = true Freezable = true Grazeable = false GrazeValue = 0.2 -Attributes = 4 +Attributes = 260 TimeModifiers = [] metadata/_custom_type_script = "uid://dslyrfcej3g2n" diff --git a/Resources/Bullets/ice_shotgun_sawed_bullets.tres b/Resources/Bullets/ice_shotgun_sawed_bullets.tres index 6921ad57..0c5bc408 100644 --- a/Resources/Bullets/ice_shotgun_sawed_bullets.tres +++ b/Resources/Bullets/ice_shotgun_sawed_bullets.tres @@ -11,6 +11,7 @@ DestructionParticlesScene = ExtResource("2_ibcyh") BulletSpeed = 300.0 Direction = Vector2(1, 0) BulletDamage = 1.0 +MaxDamage = 1.0 Knockback = 200.0 LifeTime = 4.0 DestroyOnCollision = true @@ -21,4 +22,5 @@ Controllable = false Freezable = true Grazeable = false GrazeValue = 0.2 +Attributes = 256 TimeModifiers = [] diff --git a/Resources/Bullets/icicle_gun_bullets.tres b/Resources/Bullets/icicle_gun_bullets.tres index b99535f1..1ea569fa 100644 --- a/Resources/Bullets/icicle_gun_bullets.tres +++ b/Resources/Bullets/icicle_gun_bullets.tres @@ -22,5 +22,5 @@ Controllable = false Freezable = true Grazeable = false GrazeValue = 0.2 -Attributes = 0 +Attributes = 256 TimeModifiers = [] diff --git a/Resources/Bullets/player_laser.tres b/Resources/Bullets/player_laser.tres index b1a7ed59..5f0b69ee 100644 --- a/Resources/Bullets/player_laser.tres +++ b/Resources/Bullets/player_laser.tres @@ -22,5 +22,5 @@ Controllable = false Freezable = false Grazeable = false GrazeValue = 1.0 -Attributes = 64 +Attributes = 320 TimeModifiers = [] diff --git a/Resources/Bullets/simple_enemy_bullet.tres b/Resources/Bullets/simple_enemy_bullet.tres index c99bc806..f52ed5d7 100644 --- a/Resources/Bullets/simple_enemy_bullet.tres +++ b/Resources/Bullets/simple_enemy_bullet.tres @@ -20,5 +20,5 @@ Controllable = false Freezable = true Grazeable = true GrazeValue = 1.0 -Attributes = 34 +Attributes = 290 TimeModifiers = [] diff --git a/Resources/Bullets/simple_enemy_bullet_big.tres b/Resources/Bullets/simple_enemy_bullet_big.tres index 115c4f64..7eb7c867 100644 --- a/Resources/Bullets/simple_enemy_bullet_big.tres +++ b/Resources/Bullets/simple_enemy_bullet_big.tres @@ -20,5 +20,5 @@ Controllable = false Freezable = true Grazeable = true GrazeValue = 1.0 -Attributes = 34 +Attributes = 290 TimeModifiers = [] diff --git a/Resources/Bullets/simple_ice_bullet.tres b/Resources/Bullets/simple_ice_bullet.tres index caf1ef7e..79b13ed0 100644 --- a/Resources/Bullets/simple_ice_bullet.tres +++ b/Resources/Bullets/simple_ice_bullet.tres @@ -11,6 +11,7 @@ DestructionParticlesScene = ExtResource("2_fkpjr") BulletSpeed = 300.0 Direction = Vector2(1, 0) BulletDamage = 0.6 +MaxDamage = 1.0 Knockback = 200.0 LifeTime = 10.0 DestroyOnCollision = true @@ -21,4 +22,5 @@ Controllable = false Freezable = true Grazeable = false GrazeValue = 0.2 +Attributes = 256 TimeModifiers = [] diff --git a/Resources/Bullets/yin_yang_bullet.tres b/Resources/Bullets/yin_yang_bullet.tres index baf1ed0a..afb156af 100644 --- a/Resources/Bullets/yin_yang_bullet.tres +++ b/Resources/Bullets/yin_yang_bullet.tres @@ -34,5 +34,5 @@ Controllable = false Freezable = true Grazeable = false GrazeValue = 1.0 -Attributes = 8 +Attributes = 264 TimeModifiers = Array[Object]([SubResource("Resource_lcgqc")]) diff --git a/Scenes/Utils/pooling_manager.tscn b/Scenes/Utils/pooling_manager.tscn index b3f2e081..39f3f1ed 100644 --- a/Scenes/Utils/pooling_manager.tscn +++ b/Scenes/Utils/pooling_manager.tscn @@ -6,4 +6,3 @@ z_index = 1 script = ExtResource("1_ji88p") PoolOnStart = Array[Resource]([]) -DebugView = true diff --git a/Scripts/Bullet.cs b/Scripts/Bullet.cs index 6861bc42..6d87076e 100644 --- a/Scripts/Bullet.cs +++ b/Scripts/Bullet.cs @@ -34,13 +34,14 @@ public partial class Bullet : Area2D public bool IsFrozen { get; private set; } = false; public bool Enabled { get; private set; } = false; - [Signal] public delegate void OnDestroyEventHandler(); + [Signal] + public delegate void OnDestroyEventHandler(); private AudioStreamPlayer2D _grazeSound; private GpuParticles2D _grazeParticles; - + private CollisionShape2D _collisionShape2D; - + public override void _Ready() { _grazeSound = GetNodeOrNull("AudioStreamPlayer2D"); @@ -48,7 +49,7 @@ public partial class Bullet : Area2D _collisionShape2D = GetNode("CollisionShape2D"); } - + public void Initialize(BulletInfo bulletInfo, GameManager gameManager) { _bulletInfo = bulletInfo; @@ -58,7 +59,7 @@ public partial class Bullet : Area2D _elapsedTime = 0f; this.Speed = bulletInfo.Speed; - + // Need to clone them here // _modifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone()).ToList(); @@ -81,9 +82,8 @@ public partial class Bullet : Area2D { _collisionShape2D = GetNode("CollisionShape2D"); } - + _collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, false); - } /// @@ -92,18 +92,19 @@ public partial class Bullet : Area2D public void Disable(bool hideSprite = true) { Enabled = false; - if (hideSprite) + if (hideSprite && !BulletInfo.Attributes.HasFlag(BulletFlags.PersistSprite)) { Hide(); } + if (this._collisionShape2D is null) { _collisionShape2D = GetNode("CollisionShape2D"); } - + _collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, true); } - + public void Graze() { if (!Enabled) return; @@ -112,6 +113,7 @@ public partial class Bullet : Area2D { _grazeParticles.Emitting = true; } + IsGrazed = true; } @@ -162,19 +164,20 @@ public partial class Bullet : Area2D //SetRotationDegrees(RotationDegrees + degrees); float radians = Mathf.DegToRad(degrees); _direction = _direction.Rotated(radians).Normalized(); // Rotate direction - if (!BulletInfo.RotateSprite) return; + + if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return; SetRotation(Rotation + radians); } public virtual void RotateSpriteDegrees(float degrees) { - if (!BulletInfo.RotateSprite) return; + if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return; SetRotationDegrees(RotationDegrees + degrees); } public virtual void RotateSprite(float radians) { - if (!BulletInfo.RotateSprite) return; + if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return; SetRotation(Rotation + radians); } @@ -204,7 +207,7 @@ public partial class Bullet : Area2D _direction = normalized; - if (!BulletInfo.RotateSprite) return; + if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return; SetRotation(Mathf.Atan2(normalized.Y, normalized.X) + Mathf.Pi / 2); //Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}"); @@ -229,8 +232,8 @@ public partial class Bullet : Area2D { ApplyTimeModifiers(delta); } - - if (BulletInfo.Controllabe) + + if (BulletInfo.Attributes.HasFlag(BulletFlags.Controllable)) { ControlBullet(delta); } @@ -253,6 +256,7 @@ public partial class Bullet : Area2D private void _on_visible_on_screen_notifier_2d_screen_exited() { if (!Enabled) return; + if (!BulletInfo.Attributes.HasFlag(BulletFlags.DieOutOfScreen)) return; //Debug.WriteLine("Destroy bullet out of screen"); Destroy(); } @@ -319,6 +323,7 @@ public partial class Bullet : Area2D //particle.Init(); } + EmitSignal(SignalName.OnDestroy); //QueueFree(); PoolingManager.Instance.DisableBullet(this); diff --git a/Scripts/Components/BulletFlags.cs b/Scripts/Components/BulletFlags.cs index 2f55b179..dabeb199 100644 --- a/Scripts/Components/BulletFlags.cs +++ b/Scripts/Components/BulletFlags.cs @@ -8,7 +8,10 @@ public enum BulletFlags Freezable = 1 << 1, Controllable = 1 << 2, Bouncy = 1 << 3, - Piercing = 1 << 4, - Grazeable = 1 << 5, - Rotateable = 1 << 6, + Piercing = 1 << 4, + Grazeable = 1 << 5, + Rotateable = 1 << 6, + PersistSprite = 1 << 7, + DieOutOfScreen = 1 << 8, + // Max 31 } \ No newline at end of file