From 07f6e58ebdce5dfe43e1058080f19557f41899fa Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 12 Feb 2025 16:20:55 +0100 Subject: [PATCH] Bullet resource --- Resources/BossPhases/Rumia_SP1.tres | 4 ++ Resources/Bullets/simple_enemy_bullet.tres | 15 ++++++ Resources/Bullets/simple_ice_bullet.tres | 17 +++++++ Resources/Patterns/rumia_ns_2.tres | 6 +++ Resources/Weapons/EnemyWeapon.tres | 10 ++-- Resources/Weapons/Ice_Shotgun_Weapon.tres | 6 ++- Resources/Weapons/IcicleGun.tres | 8 ++- Resources/Weapons/IcicleRepeater.tres | 10 ++-- Scenes/Barrel.cs | 9 ++-- Scenes/Particles/IceBulletParticle.tscn | 23 +++++++++ Scenes/Props/Barrel.tscn | 15 +++++- Scenes/Weapons/Bullets/explosion.tscn | 3 +- Scenes/test.tscn | 2 - Scripts/Bullet.cs | 21 ++++++-- Scripts/Components/AutodeleteParticle.cs | 27 ++++++++++ Scripts/Components/BulletSpawner.cs | 1 + Scripts/Resources/BulletResource.cs | 46 +++++++++++++++++ Scripts/Resources/WeaponResource.cs | 59 ++++++++++++---------- Scripts/Weapon.cs | 4 +- 19 files changed, 236 insertions(+), 50 deletions(-) create mode 100644 Resources/Bullets/simple_enemy_bullet.tres create mode 100644 Resources/Bullets/simple_ice_bullet.tres create mode 100644 Scenes/Particles/IceBulletParticle.tscn create mode 100644 Scripts/Components/AutodeleteParticle.cs create mode 100644 Scripts/Resources/BulletResource.cs diff --git a/Resources/BossPhases/Rumia_SP1.tres b/Resources/BossPhases/Rumia_SP1.tres index 41bfded7..a4a65d53 100644 --- a/Resources/BossPhases/Rumia_SP1.tres +++ b/Resources/BossPhases/Rumia_SP1.tres @@ -26,6 +26,8 @@ duration = 1.0 burstInterval = 1.0 spread = 180.0 owner = 2 +_damageType = 0 +_bulletDamage = 1.0 _timeModifiers = Array[Resource]([]) WaitForCompletion = true @@ -40,6 +42,8 @@ duration = 1.0 burstInterval = 1.0 spread = 180.0 owner = 2 +_damageType = 0 +_bulletDamage = 1.0 _timeModifiers = null WaitForCompletion = true diff --git a/Resources/Bullets/simple_enemy_bullet.tres b/Resources/Bullets/simple_enemy_bullet.tres new file mode 100644 index 00000000..5a345ba1 --- /dev/null +++ b/Resources/Bullets/simple_enemy_bullet.tres @@ -0,0 +1,15 @@ +[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://dqnvesdj0dk3v"] + +[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="1_o3tyw"] +[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="1_vsj6i"] + +[resource] +script = ExtResource("1_o3tyw") +BulletScene = ExtResource("1_vsj6i") +AmmoKey = "" +BulletSpeed = 50.0 +BulletDamage = 1.0 +LifeTime = 10.0 +Owner = 2 +DamageType = 0 +TimeModifiers = null diff --git a/Resources/Bullets/simple_ice_bullet.tres b/Resources/Bullets/simple_ice_bullet.tres new file mode 100644 index 00000000..fb54684e --- /dev/null +++ b/Resources/Bullets/simple_ice_bullet.tres @@ -0,0 +1,17 @@ +[gd_resource type="Resource" script_class="BulletResource" load_steps=4 format=3 uid="uid://eu6n6c5175y8"] + +[ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_qjgqc"] +[ext_resource type="PackedScene" uid="uid://dfbmny3s4rili" path="res://Scenes/Particles/IceBulletParticle.tscn" id="2_fkpjr"] +[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="3_m6t6f"] + +[resource] +script = ExtResource("3_m6t6f") +BulletScene = ExtResource("1_qjgqc") +DestructionParticlesScene = ExtResource("2_fkpjr") +AmmoKey = "" +BulletSpeed = 300.0 +BulletDamage = 1.0 +LifeTime = 10.0 +Owner = 1 +DamageType = 3 +TimeModifiers = null diff --git a/Resources/Patterns/rumia_ns_2.tres b/Resources/Patterns/rumia_ns_2.tres index 74a5938d..d0cdc953 100644 --- a/Resources/Patterns/rumia_ns_2.tres +++ b/Resources/Patterns/rumia_ns_2.tres @@ -16,6 +16,8 @@ duration = 1.0 burstInterval = 2.0 spread = 360.0 owner = 2 +_damageType = 0 +_bulletDamage = 1.0 _timeModifiers = null WaitForCompletion = true @@ -30,6 +32,8 @@ duration = 1.0 burstInterval = 2.0 spread = 360.0 owner = 2 +_damageType = 0 +_bulletDamage = 1.0 _timeModifiers = null WaitForCompletion = true @@ -44,6 +48,8 @@ duration = 4.0 burstInterval = 2.0 spread = 360.0 owner = 2 +_damageType = 0 +_bulletDamage = 1.0 _timeModifiers = null WaitForCompletion = true diff --git a/Resources/Weapons/EnemyWeapon.tres b/Resources/Weapons/EnemyWeapon.tres index b80a8fa1..e2b5a426 100644 --- a/Resources/Weapons/EnemyWeapon.tres +++ b/Resources/Weapons/EnemyWeapon.tres @@ -1,11 +1,13 @@ -[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://cdfmedtgp2rcn"] +[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://cdfmedtgp2rcn"] [ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="1_c5ala"] +[ext_resource type="Resource" uid="uid://dqnvesdj0dk3v" path="res://Resources/Bullets/simple_enemy_bullet.tres" id="1_eps1c"] [ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_8ycgt"] [resource] script = ExtResource("2_8ycgt") Name = "Enemy Weapon" +BulletData = ExtResource("1_eps1c") BulletScene = ExtResource("1_c5ala") RateOfFire = 0.4 BulletCapacity = 4 @@ -15,9 +17,11 @@ InfiniteAmmo = true BulletsPerShot = 1 SpreadAngle = 0.0 RandomSpread = 0.0 +AmmoKey = "" BulletSpeed = 50.0 -bulletPerShotCount = 1 +BulletDamage = 1.0 +LifeTime = 10.0 _rotationOffset = 0.0 -spread = 0.0 owner = 2 +_damageType = 0 _timeModifiers = null diff --git a/Resources/Weapons/Ice_Shotgun_Weapon.tres b/Resources/Weapons/Ice_Shotgun_Weapon.tres index 9396732b..6bdb83da 100644 --- a/Resources/Weapons/Ice_Shotgun_Weapon.tres +++ b/Resources/Weapons/Ice_Shotgun_Weapon.tres @@ -1,11 +1,13 @@ -[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://cyntngidhcbkc"] +[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://cyntngidhcbkc"] +[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_m44wx"] [ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_puh43"] [ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_utbbo"] [resource] script = ExtResource("2_utbbo") Name = "Ice Shotgun" +BulletData = ExtResource("1_m44wx") BulletScene = ExtResource("1_puh43") RateOfFire = 0.1 BulletCapacity = 4 @@ -18,6 +20,8 @@ RandomSpread = 0.0 AmmoKey = "Ammo1" BulletSpeed = 300.0 BulletDamage = 1.0 +LifeTime = 10.0 _rotationOffset = 0.0 owner = 1 +_damageType = 0 _timeModifiers = null diff --git a/Resources/Weapons/IcicleGun.tres b/Resources/Weapons/IcicleGun.tres index 10c9c5e5..9c804d77 100644 --- a/Resources/Weapons/IcicleGun.tres +++ b/Resources/Weapons/IcicleGun.tres @@ -1,12 +1,16 @@ -[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://b8apu0l5fm4k"] +[gd_resource type="Resource" script_class="WeaponResource" load_steps=5 format=3 uid="uid://b8apu0l5fm4k"] +[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_85ef1"] [ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_yby7n"] +[ext_resource type="PackedScene" uid="uid://dfbmny3s4rili" path="res://Scenes/Particles/IceBulletParticle.tscn" id="2_icuny"] [ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_m8dps"] [resource] script = ExtResource("2_m8dps") Name = "Icicle Gun" +BulletData = ExtResource("1_85ef1") BulletScene = ExtResource("1_yby7n") +DestructionParticlesScene = ExtResource("2_icuny") RateOfFire = 0.1 BulletCapacity = 4 ReloadTime = 0.2 @@ -18,6 +22,8 @@ RandomSpread = 0.0 AmmoKey = "" BulletSpeed = 300.0 BulletDamage = 1.0 +LifeTime = 10.0 _rotationOffset = 0.0 owner = 1 +_damageType = 0 _timeModifiers = null diff --git a/Resources/Weapons/IcicleRepeater.tres b/Resources/Weapons/IcicleRepeater.tres index c00eeb53..e6f0ffcd 100644 --- a/Resources/Weapons/IcicleRepeater.tres +++ b/Resources/Weapons/IcicleRepeater.tres @@ -1,11 +1,13 @@ -[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://yuc0v7gojgep"] +[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://yuc0v7gojgep"] +[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_lg8jo"] [ext_resource type="PackedScene" uid="uid://b1qnfiuokpvsr" path="res://Scenes/Weapons/bullet.tscn" id="1_lmn8t"] [ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_f4135"] [resource] script = ExtResource("2_f4135") Name = "Icicle Gun" +BulletData = ExtResource("1_lg8jo") BulletScene = ExtResource("1_lmn8t") RateOfFire = 0.1 BulletCapacity = 100 @@ -15,9 +17,11 @@ InfiniteAmmo = true BulletsPerShot = 1 SpreadAngle = 0.0 RandomSpread = 0.0 +AmmoKey = "" BulletSpeed = 300.0 -bulletPerShotCount = 1 +BulletDamage = 1.0 +LifeTime = 10.0 _rotationOffset = 0.0 -spread = 0.0 owner = 1 +_damageType = 0 _timeModifiers = null diff --git a/Scenes/Barrel.cs b/Scenes/Barrel.cs index d0a9ca37..0566d99b 100644 --- a/Scenes/Barrel.cs +++ b/Scenes/Barrel.cs @@ -2,6 +2,7 @@ using Godot; using System; using System.Diagnostics; using Cirno.Scripts; +using Cirno.Scripts.Resources; public partial class Barrel : Area2D, IDestructible { @@ -14,8 +15,7 @@ public partial class Barrel : Area2D, IDestructible [Export] public PackedScene DebrisScene { get; set; } [Export] public PackedScene ExplosionParticles { get; set; } - - [Export] public PackedScene ExplosionScene { get; set; } + [Export] public BulletResource ExplosionData { get; set; } private float _currentHealth = 0f; @@ -43,11 +43,12 @@ public partial class Barrel : Area2D, IDestructible private void CreateExplosion() { - if (ExplosionScene == null) return; + if (ExplosionData == null) return; - var explosion = this.CreateSibling(ExplosionScene); + var explosion = this.CreateSibling(ExplosionData.BulletScene); explosion.Speed = 0; + explosion.Initialize(ExplosionData.MakeBullet(this.GlobalPosition)); } private void ApplyExplosionDamage() diff --git a/Scenes/Particles/IceBulletParticle.tscn b/Scenes/Particles/IceBulletParticle.tscn new file mode 100644 index 00000000..838f7baf --- /dev/null +++ b/Scenes/Particles/IceBulletParticle.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=3 format=3 uid="uid://dfbmny3s4rili"] + +[ext_resource type="Script" path="res://Scripts/Components/AutodeleteParticle.cs" id="1_rk44q"] + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_f8iyl"] +particle_flag_disable_z = true +radial_velocity_min = -2.23517e-05 +radial_velocity_max = 30.38 +gravity = Vector3(0, 0, 0) +linear_accel_min = -23.2 +linear_accel_max = -2.23517e-06 +scale_min = 0.5 +scale_max = 0.5 +color = Color(0.054902, 0.494118, 1, 1) + +[node name="IceBulletParticle" type="GPUParticles2D"] +emitting = false +amount = 4 +process_material = SubResource("ParticleProcessMaterial_f8iyl") +lifetime = 0.4 +one_shot = true +script = ExtResource("1_rk44q") +LifeTime = 1.0 diff --git a/Scenes/Props/Barrel.tscn b/Scenes/Props/Barrel.tscn index 0dd64ba9..faeda3f5 100644 --- a/Scenes/Props/Barrel.tscn +++ b/Scenes/Props/Barrel.tscn @@ -1,10 +1,21 @@ -[gd_scene load_steps=9 format=3 uid="uid://bj28qiai2x2ar"] +[gd_scene load_steps=11 format=3 uid="uid://bj28qiai2x2ar"] [ext_resource type="Script" path="res://Scenes/Barrel.cs" id="1_avwdx"] [ext_resource type="Texture2D" uid="uid://d2f16ke8c7vwx" path="res://Sprites/Barrel.png" id="1_e66t6"] [ext_resource type="PackedScene" uid="uid://clyyl3jgpfoo7" path="res://Scenes/Props/Broken_Barrel.tscn" id="2_f145b"] [ext_resource type="PackedScene" uid="uid://jmijre3eaf8m" path="res://Scenes/Explosion.tscn" id="3_sm378"] [ext_resource type="PackedScene" uid="uid://h11o0et1y54v" path="res://Scenes/Weapons/Bullets/explosion.tscn" id="4_epbro"] +[ext_resource type="Script" path="res://Scripts/Resources/BulletResource.cs" id="5_xl8uf"] + +[sub_resource type="Resource" id="Resource_kqink"] +script = ExtResource("5_xl8uf") +BulletScene = ExtResource("4_epbro") +BulletSpeed = 0.0 +BulletDamage = 8.0 +LifeTime = 1.0 +Owner = 0 +DamageType = 4 +TimeModifiers = null [sub_resource type="RectangleShape2D" id="RectangleShape2D_2ewfl"] size = Vector2(11, 14) @@ -25,7 +36,7 @@ ExplosionRadius = 4.0 ExplosionDamage = 3.0 DebrisScene = ExtResource("2_f145b") ExplosionParticles = ExtResource("3_sm378") -ExplosionScene = ExtResource("4_epbro") +ExplosionData = SubResource("Resource_kqink") metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/Scenes/Weapons/Bullets/explosion.tscn b/Scenes/Weapons/Bullets/explosion.tscn index 5ed3e345..12bed96d 100644 --- a/Scenes/Weapons/Bullets/explosion.tscn +++ b/Scenes/Weapons/Bullets/explosion.tscn @@ -4,14 +4,13 @@ [ext_resource type="Texture2D" uid="uid://b2bp03a70cpyd" path="res://Sprites/Explosion1.png" id="2_gmwb3"] [sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"] -radius = 12.0 +radius = 17.0 [node name="Bullet" type="Area2D" groups=["bullets"]] collision_layer = 136 collision_mask = 87 script = ExtResource("1_f0epf") Speed = 0.0 -Damage = 10.0 metadata/_edit_group_ = true [node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/Scenes/test.tscn b/Scenes/test.tscn index a2011585..8c730e45 100644 --- a/Scenes/test.tscn +++ b/Scenes/test.tscn @@ -212,11 +212,9 @@ position = Vector2(-710, -459) [node name="Barrel" parent="Factory Tilemaps" instance=ExtResource("18_vy02r")] position = Vector2(-711, -395) -ExplosionScene = null [node name="Barrel2" parent="Factory Tilemaps" instance=ExtResource("18_vy02r")] position = Vector2(-700, -381) -ExplosionScene = null [node name="CameraController" type="Camera2D" parent="."] script = ExtResource("6_t8ide") diff --git a/Scripts/Bullet.cs b/Scripts/Bullet.cs index db97f063..2c9c8838 100644 --- a/Scripts/Bullet.cs +++ b/Scripts/Bullet.cs @@ -1,6 +1,7 @@ using Godot; using System; using System.Diagnostics; +using Cirno.Scripts; using Cirno.Scripts.Components; using Cirno.Scripts.Resources; @@ -111,7 +112,7 @@ public partial class Bullet : Area2D private void _on_visible_on_screen_notifier_2d_screen_exited() { //Debug.WriteLine("Destroy bullet out of screen"); - QueueFree(); + Destroy(); } private void _on_body_entered(Node2D body) @@ -119,7 +120,7 @@ public partial class Bullet : Area2D if (body.IsInGroup("Solid")) { //Debug.WriteLine("Collision"); - QueueFree(); + Destroy(); } //// Do not Collide with body for purpose of destroying bullets // else if (body.IsInGroup("Destroyable")) @@ -134,7 +135,7 @@ public partial class Bullet : Area2D { if (area.IsInGroup("Solid")) { - QueueFree(); + Destroy(); return; } @@ -144,9 +145,21 @@ public partial class Bullet : Area2D destructible.Hit(Damage, DamageType); - QueueFree(); + Destroy(); } } + + public void Destroy() + { + if (_bulletInfo?.DestructionParticlesScene != null) + { + var particle = this.CreateSibling(_bulletInfo.DestructionParticlesScene); + + particle.Init(); + } + + QueueFree(); + } } public enum BulletOwner diff --git a/Scripts/Components/AutodeleteParticle.cs b/Scripts/Components/AutodeleteParticle.cs new file mode 100644 index 00000000..07a42f5f --- /dev/null +++ b/Scripts/Components/AutodeleteParticle.cs @@ -0,0 +1,27 @@ +using Godot; + +namespace Cirno.Scripts.Components; + +public partial class AutodeleteParticle : GpuParticles2D +{ + + [Export] + public double LifeTime { get; private set; } + + private double _timer = 0; + + public void Init() + { + this.Emitting = true; + } + + public override void _Process(double delta) + { + _timer += delta; + + if (_timer >= LifeTime || this.Emitting == false) + { + QueueFree(); + } + } +} \ No newline at end of file diff --git a/Scripts/Components/BulletSpawner.cs b/Scripts/Components/BulletSpawner.cs index 92128413..44f62f26 100644 --- a/Scripts/Components/BulletSpawner.cs +++ b/Scripts/Components/BulletSpawner.cs @@ -91,6 +91,7 @@ public class BulletInfo //public double Time { get; set; } public float Spread { get; set; } public PackedScene BulletScene { get; set; } + public PackedScene DestructionParticlesScene { get; set; } public IBulletModifier Modifier { get; set; } public List TimeModifiers { get; set; } = new List(); } \ No newline at end of file diff --git a/Scripts/Resources/BulletResource.cs b/Scripts/Resources/BulletResource.cs new file mode 100644 index 00000000..34d98790 --- /dev/null +++ b/Scripts/Resources/BulletResource.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using System.Linq; +using Cirno.Scripts.Components; +using Godot; +using Godot.Collections; + +namespace Cirno.Scripts.Resources; + +[GlobalClass] +public partial class BulletResource : Resource +{ + [Export] + public PackedScene BulletScene { get; set; } + [Export] public PackedScene DestructionParticlesScene { get; set; } + [Export] public float BulletSpeed = 100f; + [Export] public float BulletDamage = 1; + [Export] public float LifeTime = 10f; + [Export] public BulletOwner Owner = BulletOwner.None; + [Export] public DamageType DamageType = DamageType.Neutral; + + [Export] + public Resource Modifier; + [Export] public Array TimeModifiers; + + public BulletInfo MakeBullet(Vector2 position, int count = 1, float spread = 0f, float rotationOffset = 0f) + { + return new BulletInfo() + { + Position = position, + Direction = Vector2.Right, + Speed = BulletSpeed, + Owner = Owner, + DamageType = DamageType, + Damage = BulletDamage, + BulletCount = count, + Spread = spread, + BulletScene = BulletScene, + RotationOffset = rotationOffset, + Modifier = Modifier as IBulletModifier, + LifeTime = LifeTime, + DestructionParticlesScene = DestructionParticlesScene, + TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast().ToList() ?? + new List() + }; + } +} \ No newline at end of file diff --git a/Scripts/Resources/WeaponResource.cs b/Scripts/Resources/WeaponResource.cs index 99d7833c..1da96a8a 100644 --- a/Scripts/Resources/WeaponResource.cs +++ b/Scripts/Resources/WeaponResource.cs @@ -12,8 +12,12 @@ public partial class WeaponResource : Resource [Export] public string Name { get; set; } - [Export] - public PackedScene BulletScene { get; set; } + [Export] public BulletResource BulletData { get; private set; } + + //[Export] + //public PackedScene BulletScene { get; set; } + + //[Export] public PackedScene DestructionParticlesScene { get; set; } [Export] public double RateOfFire = 0.4f; @@ -33,35 +37,38 @@ public partial class WeaponResource : Resource #region Bullet spawn data [Export] public string AmmoKey; - [Export] public float BulletSpeed = 100f; - [Export] public float BulletDamage = 1; - [Export] public float LifeTime = 10f; + //[Export] public float BulletSpeed = 100f; + //[Export] public float BulletDamage = 1; + //[Export] public float LifeTime = 10f; [Export] private float _rotationOffset = 0f; - [Export] private BulletOwner owner = BulletOwner.None; - [Export] private DamageType _damageType = DamageType.Neutral; - [Export] private Resource _modifier; - [Export] private Array _timeModifiers; + //[Export] private BulletOwner owner = BulletOwner.None; + //[Export] private DamageType _damageType = DamageType.Neutral; + //[Export] private Resource _modifier; + //[Export] private Array _timeModifiers; #endregion public BulletInfo MakeBullet(Vector2 position) { - return new BulletInfo() - { - Position = position, - Direction = Vector2.Right, - Speed = BulletSpeed, - Owner = owner, - DamageType = _damageType, - Damage = BulletDamage, - BulletCount = BulletsPerShot, - Spread = SpreadAngle, - BulletScene = BulletScene, - RotationOffset = _rotationOffset, - Modifier = _modifier as IBulletModifier, - LifeTime = LifeTime, - TimeModifiers = _timeModifiers?.Where(mod => mod is TimeModifier).Cast().ToList() ?? - new List() - }; + return BulletData.MakeBullet(position, BulletsPerShot, SpreadAngle, _rotationOffset); + + // return new BulletInfo() + // { + // Position = position, + // Direction = Vector2.Right, + // Speed = BulletSpeed, + // Owner = owner, + // DamageType = _damageType, + // Damage = BulletDamage, + // BulletCount = BulletsPerShot, + // Spread = SpreadAngle, + // BulletScene = BulletScene, + // RotationOffset = _rotationOffset, + // Modifier = _modifier as IBulletModifier, + // LifeTime = LifeTime, + // DestructionParticlesScene = DestructionParticlesScene, + // TimeModifiers = _timeModifiers?.Where(mod => mod is TimeModifier).Cast().ToList() ?? + // new List() + // }; } } \ No newline at end of file diff --git a/Scripts/Weapon.cs b/Scripts/Weapon.cs index 2f9b15ed..d9282d1a 100644 --- a/Scripts/Weapon.cs +++ b/Scripts/Weapon.cs @@ -99,7 +99,7 @@ public partial class Weapon : Node2D // Rotate the ShootDirection by the spread angle Vector2 spreadDirection = ShootDirection.Rotated(Mathf.DegToRad(spreadOffset)); - var bullet = this.CreateChildOf(_gameManager.BulletsContainer, WeaponData.BulletScene, _muzzle.GlobalPosition); + var bullet = this.CreateChildOf(_gameManager.BulletsContainer, WeaponData.BulletData.BulletScene, _muzzle.GlobalPosition); if (bullet == null) { @@ -111,7 +111,7 @@ public partial class Weapon : Node2D //bullet.SetDirection(ShootDirection); bullet.SetDirection(spreadDirection); - bullet.Speed = WeaponData.BulletSpeed; + bullet.Speed = WeaponData.BulletData.BulletSpeed; } LoadedAmmo -= 1;