mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-13 18:25:55 +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"]
|
||||
|
||||
[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"]
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -22,6 +22,6 @@ Controllable = true
|
|||
Freezable = true
|
||||
Grazeable = false
|
||||
GrazeValue = 0.2
|
||||
Attributes = 4
|
||||
Attributes = 260
|
||||
TimeModifiers = []
|
||||
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||
|
|
|
|||
|
|
@ -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 = []
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ Controllable = false
|
|||
Freezable = true
|
||||
Grazeable = false
|
||||
GrazeValue = 0.2
|
||||
Attributes = 0
|
||||
Attributes = 256
|
||||
TimeModifiers = []
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ Controllable = false
|
|||
Freezable = false
|
||||
Grazeable = false
|
||||
GrazeValue = 1.0
|
||||
Attributes = 64
|
||||
Attributes = 320
|
||||
TimeModifiers = []
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ Controllable = false
|
|||
Freezable = true
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
Attributes = 34
|
||||
Attributes = 290
|
||||
TimeModifiers = []
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ Controllable = false
|
|||
Freezable = true
|
||||
Grazeable = true
|
||||
GrazeValue = 1.0
|
||||
Attributes = 34
|
||||
Attributes = 290
|
||||
TimeModifiers = []
|
||||
|
|
|
|||
|
|
@ -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 = []
|
||||
|
|
|
|||
|
|
@ -34,5 +34,5 @@ Controllable = false
|
|||
Freezable = true
|
||||
Grazeable = false
|
||||
GrazeValue = 1.0
|
||||
Attributes = 8
|
||||
Attributes = 264
|
||||
TimeModifiers = Array[Object]([SubResource("Resource_lcgqc")])
|
||||
|
|
|
|||
|
|
@ -6,4 +6,3 @@
|
|||
z_index = 1
|
||||
script = ExtResource("1_ji88p")
|
||||
PoolOnStart = Array[Resource]([])
|
||||
DebugView = true
|
||||
|
|
|
|||
|
|
@ -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>("AudioStreamPlayer2D");
|
||||
|
|
@ -48,7 +49,7 @@ public partial class Bullet : Area2D
|
|||
|
||||
_collisionShape2D = GetNode<CollisionShape2D>("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");
|
||||
}
|
||||
|
||||
|
||||
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, false);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
_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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue