mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-04 23:21:17 +00:00
Use bullet flags instead of bools
This commit is contained in:
parent
fa3805ecfe
commit
72c6270eb5
14 changed files with 49 additions and 38 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
[gd_resource type="Resource" script_class="BossPhase" load_steps=15 format=3 uid="uid://bu3a6hv5i1qam"]
|
[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="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://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://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="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://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"]
|
[ext_resource type="Script" uid="uid://cq7pfooyqayc4" path="res://Scripts/Resources/Modifiers/DelayedSpeedModifier.cs" id="6_8tj6w"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://t2tbu5bfge4b"]
|
[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="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_olcd3"]
|
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_mvqvb"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_olcd3")
|
script = ExtResource("2_mvqvb")
|
||||||
BulletScene = ExtResource("1_371nf")
|
BulletScene = ExtResource("1_hv3jl")
|
||||||
BulletSpeed = 100.0
|
BulletSpeed = 100.0
|
||||||
Direction = Vector2(1, 0)
|
Direction = Vector2(1, 0)
|
||||||
BulletDamage = 30.0
|
BulletDamage = 30.0
|
||||||
|
|
@ -20,6 +20,6 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = true
|
Grazeable = true
|
||||||
GrazeValue = 1.0
|
GrazeValue = 1.0
|
||||||
Attributes = 96
|
Attributes = 98
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://djjp4nyufqxlp"]
|
[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="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_gj3rh"]
|
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_72228"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_gj3rh")
|
script = ExtResource("2_72228")
|
||||||
BulletScene = ExtResource("1_ie3bo")
|
BulletScene = ExtResource("1_vfoj8")
|
||||||
BulletSpeed = 100.0
|
BulletSpeed = 100.0
|
||||||
Direction = Vector2(1, 0)
|
Direction = Vector2(1, 0)
|
||||||
BulletDamage = 30.0
|
BulletDamage = 30.0
|
||||||
|
|
@ -20,6 +20,6 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = true
|
Grazeable = true
|
||||||
GrazeValue = 1.0
|
GrazeValue = 1.0
|
||||||
Attributes = 96
|
Attributes = 98
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||||
|
|
@ -22,6 +22,6 @@ Controllable = true
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = false
|
Grazeable = false
|
||||||
GrazeValue = 0.2
|
GrazeValue = 0.2
|
||||||
Attributes = 4
|
Attributes = 260
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ DestructionParticlesScene = ExtResource("2_ibcyh")
|
||||||
BulletSpeed = 300.0
|
BulletSpeed = 300.0
|
||||||
Direction = Vector2(1, 0)
|
Direction = Vector2(1, 0)
|
||||||
BulletDamage = 1.0
|
BulletDamage = 1.0
|
||||||
|
MaxDamage = 1.0
|
||||||
Knockback = 200.0
|
Knockback = 200.0
|
||||||
LifeTime = 4.0
|
LifeTime = 4.0
|
||||||
DestroyOnCollision = true
|
DestroyOnCollision = true
|
||||||
|
|
@ -21,4 +22,5 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = false
|
Grazeable = false
|
||||||
GrazeValue = 0.2
|
GrazeValue = 0.2
|
||||||
|
Attributes = 256
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,5 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = false
|
Grazeable = false
|
||||||
GrazeValue = 0.2
|
GrazeValue = 0.2
|
||||||
Attributes = 0
|
Attributes = 256
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,5 @@ Controllable = false
|
||||||
Freezable = false
|
Freezable = false
|
||||||
Grazeable = false
|
Grazeable = false
|
||||||
GrazeValue = 1.0
|
GrazeValue = 1.0
|
||||||
Attributes = 64
|
Attributes = 320
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,5 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = true
|
Grazeable = true
|
||||||
GrazeValue = 1.0
|
GrazeValue = 1.0
|
||||||
Attributes = 34
|
Attributes = 290
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,5 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = true
|
Grazeable = true
|
||||||
GrazeValue = 1.0
|
GrazeValue = 1.0
|
||||||
Attributes = 34
|
Attributes = 290
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ DestructionParticlesScene = ExtResource("2_fkpjr")
|
||||||
BulletSpeed = 300.0
|
BulletSpeed = 300.0
|
||||||
Direction = Vector2(1, 0)
|
Direction = Vector2(1, 0)
|
||||||
BulletDamage = 0.6
|
BulletDamage = 0.6
|
||||||
|
MaxDamage = 1.0
|
||||||
Knockback = 200.0
|
Knockback = 200.0
|
||||||
LifeTime = 10.0
|
LifeTime = 10.0
|
||||||
DestroyOnCollision = true
|
DestroyOnCollision = true
|
||||||
|
|
@ -21,4 +22,5 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = false
|
Grazeable = false
|
||||||
GrazeValue = 0.2
|
GrazeValue = 0.2
|
||||||
|
Attributes = 256
|
||||||
TimeModifiers = []
|
TimeModifiers = []
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,5 @@ Controllable = false
|
||||||
Freezable = true
|
Freezable = true
|
||||||
Grazeable = false
|
Grazeable = false
|
||||||
GrazeValue = 1.0
|
GrazeValue = 1.0
|
||||||
Attributes = 8
|
Attributes = 264
|
||||||
TimeModifiers = Array[Object]([SubResource("Resource_lcgqc")])
|
TimeModifiers = Array[Object]([SubResource("Resource_lcgqc")])
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,3 @@
|
||||||
z_index = 1
|
z_index = 1
|
||||||
script = ExtResource("1_ji88p")
|
script = ExtResource("1_ji88p")
|
||||||
PoolOnStart = Array[Resource]([])
|
PoolOnStart = Array[Resource]([])
|
||||||
DebugView = true
|
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,14 @@ public partial class Bullet : Area2D
|
||||||
public bool IsFrozen { get; private set; } = false;
|
public bool IsFrozen { get; private set; } = false;
|
||||||
public bool Enabled { 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 AudioStreamPlayer2D _grazeSound;
|
||||||
private GpuParticles2D _grazeParticles;
|
private GpuParticles2D _grazeParticles;
|
||||||
|
|
||||||
private CollisionShape2D _collisionShape2D;
|
private CollisionShape2D _collisionShape2D;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_grazeSound = GetNodeOrNull<AudioStreamPlayer2D>("AudioStreamPlayer2D");
|
_grazeSound = GetNodeOrNull<AudioStreamPlayer2D>("AudioStreamPlayer2D");
|
||||||
|
|
@ -48,7 +49,7 @@ public partial class Bullet : Area2D
|
||||||
|
|
||||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
||||||
{
|
{
|
||||||
_bulletInfo = bulletInfo;
|
_bulletInfo = bulletInfo;
|
||||||
|
|
@ -58,7 +59,7 @@ public partial class Bullet : Area2D
|
||||||
_elapsedTime = 0f;
|
_elapsedTime = 0f;
|
||||||
|
|
||||||
this.Speed = bulletInfo.Speed;
|
this.Speed = bulletInfo.Speed;
|
||||||
|
|
||||||
// Need to clone them here
|
// Need to clone them here
|
||||||
// _modifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone()).ToList();
|
// _modifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone()).ToList();
|
||||||
|
|
||||||
|
|
@ -81,9 +82,8 @@ public partial class Bullet : Area2D
|
||||||
{
|
{
|
||||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||||
}
|
}
|
||||||
|
|
||||||
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, false);
|
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -92,18 +92,19 @@ public partial class Bullet : Area2D
|
||||||
public void Disable(bool hideSprite = true)
|
public void Disable(bool hideSprite = true)
|
||||||
{
|
{
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
if (hideSprite)
|
if (hideSprite && !BulletInfo.Attributes.HasFlag(BulletFlags.PersistSprite))
|
||||||
{
|
{
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._collisionShape2D is null)
|
if (this._collisionShape2D is null)
|
||||||
{
|
{
|
||||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||||
}
|
}
|
||||||
|
|
||||||
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
|
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Graze()
|
public void Graze()
|
||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
|
|
@ -112,6 +113,7 @@ public partial class Bullet : Area2D
|
||||||
{
|
{
|
||||||
_grazeParticles.Emitting = true;
|
_grazeParticles.Emitting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsGrazed = true;
|
IsGrazed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,19 +164,20 @@ public partial class Bullet : Area2D
|
||||||
//SetRotationDegrees(RotationDegrees + degrees);
|
//SetRotationDegrees(RotationDegrees + degrees);
|
||||||
float radians = Mathf.DegToRad(degrees);
|
float radians = Mathf.DegToRad(degrees);
|
||||||
_direction = _direction.Rotated(radians).Normalized(); // Rotate direction
|
_direction = _direction.Rotated(radians).Normalized(); // Rotate direction
|
||||||
if (!BulletInfo.RotateSprite) return;
|
|
||||||
|
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||||
SetRotation(Rotation + radians);
|
SetRotation(Rotation + radians);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void RotateSpriteDegrees(float degrees)
|
public virtual void RotateSpriteDegrees(float degrees)
|
||||||
{
|
{
|
||||||
if (!BulletInfo.RotateSprite) return;
|
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||||
SetRotationDegrees(RotationDegrees + degrees);
|
SetRotationDegrees(RotationDegrees + degrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void RotateSprite(float radians)
|
public virtual void RotateSprite(float radians)
|
||||||
{
|
{
|
||||||
if (!BulletInfo.RotateSprite) return;
|
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||||
SetRotation(Rotation + radians);
|
SetRotation(Rotation + radians);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,7 +207,7 @@ public partial class Bullet : Area2D
|
||||||
|
|
||||||
_direction = normalized;
|
_direction = normalized;
|
||||||
|
|
||||||
if (!BulletInfo.RotateSprite) return;
|
if (!BulletInfo.Attributes.HasFlag(BulletFlags.Rotateable)) return;
|
||||||
SetRotation(Mathf.Atan2(normalized.Y, normalized.X) + Mathf.Pi / 2);
|
SetRotation(Mathf.Atan2(normalized.Y, normalized.X) + Mathf.Pi / 2);
|
||||||
|
|
||||||
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
//Debug.WriteLine($"Bullet Shot at direction {direction.X} {direction.Y}");
|
||||||
|
|
@ -229,8 +232,8 @@ public partial class Bullet : Area2D
|
||||||
{
|
{
|
||||||
ApplyTimeModifiers(delta);
|
ApplyTimeModifiers(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BulletInfo.Controllabe)
|
if (BulletInfo.Attributes.HasFlag(BulletFlags.Controllable))
|
||||||
{
|
{
|
||||||
ControlBullet(delta);
|
ControlBullet(delta);
|
||||||
}
|
}
|
||||||
|
|
@ -253,6 +256,7 @@ public partial class Bullet : Area2D
|
||||||
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
|
if (!BulletInfo.Attributes.HasFlag(BulletFlags.DieOutOfScreen)) return;
|
||||||
//Debug.WriteLine("Destroy bullet out of screen");
|
//Debug.WriteLine("Destroy bullet out of screen");
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
@ -319,6 +323,7 @@ public partial class Bullet : Area2D
|
||||||
|
|
||||||
//particle.Init();
|
//particle.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
EmitSignal(SignalName.OnDestroy);
|
EmitSignal(SignalName.OnDestroy);
|
||||||
//QueueFree();
|
//QueueFree();
|
||||||
PoolingManager.Instance.DisableBullet(this);
|
PoolingManager.Instance.DisableBullet(this);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@ public enum BulletFlags
|
||||||
Freezable = 1 << 1,
|
Freezable = 1 << 1,
|
||||||
Controllable = 1 << 2,
|
Controllable = 1 << 2,
|
||||||
Bouncy = 1 << 3,
|
Bouncy = 1 << 3,
|
||||||
Piercing = 1 << 4,
|
Piercing = 1 << 4,
|
||||||
Grazeable = 1 << 5,
|
Grazeable = 1 << 5,
|
||||||
Rotateable = 1 << 6,
|
Rotateable = 1 << 6,
|
||||||
|
PersistSprite = 1 << 7,
|
||||||
|
DieOutOfScreen = 1 << 8,
|
||||||
|
// Max 31
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue