Pattern burst rotation

This commit is contained in:
Marco 2025-09-24 16:51:47 +02:00
commit 099c8acf5e
10 changed files with 538 additions and 477 deletions

View file

@ -1,5 +1,6 @@
using Cirno.Scripts.Actors;
using Cirno.Scripts.Components;
using Cirno.Scripts.Enums;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Utils;
using Godot;
@ -11,12 +12,14 @@ namespace Cirno.Scripts.AttackPatterns;
[Tool]
public partial class ShootingPattern3D : AttackPattern
{
[Export] public LoopType LoopType { get; set; }
[Export] public BulletResource BulletResource { get; set; }
[Export] public Vector3 EmitterOffset { get; set; } = Vector3.Zero;
[Export] public int bulletCount = 16;
[Export] public float rotationSpeed = 0f;
[Export] public float BurstRotationSpeed = 0f;
[Export] public bool UseParentRotationOffset { get; set; } = false;
[Export] public float _rotationOffset = 0f;
[Export] public float duration = 5f;
@ -31,13 +34,27 @@ public partial class ShootingPattern3D : AttackPattern
[ExportCategory("Other")] [Export] public bool _predictPlayer = false;
[ExportCategory("Overrides")]
[ExportGroup("Override Damage")]
[Export(PropertyHint.GroupEnable)] public bool OverrideDamage { get; private set; } = false;
[Export] public float DamageOverride { get; private set; } = 10f;
[ExportGroup("Override Speed")]
[Export(PropertyHint.GroupEnable)] public bool OverrideSpeed { get; private set; } = false;
[Export] public float SpeedOverride { get; private set; } = 10f;
[ExportGroup("Override Owner")]
[Export(PropertyHint.GroupEnable)] public bool OverrideOwner { get; private set; } = false;
[Export] public BulletOwner Owner { get; private set; } = BulletOwner.None;
[ExportGroup("Override Damage Type")]
[Export(PropertyHint.GroupEnable)] public bool OverrideDamageType { get; private set; } = false;
[Export] public DamageType DamageType { get; private set; } = DamageType.Neutral;
[ExportGroup("Override Controllable")]
[ExportGroup("Override Attributes")]
[Export(PropertyHint.GroupEnable)] public bool OverrideAttributes { get; private set; } = false;
[Export] public BulletFlags AttributesOverride { get; private set; }
[ExportGroup("Override Controllable (deprecated)")]
[Export(PropertyHint.GroupEnable)] public bool OverrideControllable { get; private set; } = false;
[Export] public bool Controllable { get; private set; } = false;
@ -55,6 +72,16 @@ public partial class ShootingPattern3D : AttackPattern
var bullet = this.BulletResource.MakeBullet(position, count,
spread, rotationOffset);
if (OverrideDamage)
{
bullet.Damage = this.DamageOverride;
}
if (OverrideSpeed)
{
bullet.Speed = this.SpeedOverride;
}
if (OverrideOwner)
{
bullet.Owner = this.Owner;
@ -65,10 +92,15 @@ public partial class ShootingPattern3D : AttackPattern
bullet.DamageType = DamageType;
}
if (OverrideControllable)
if (OverrideAttributes)
{
bullet.Controllabe = Controllable;
bullet.Attributes = AttributesOverride;
}
// if (OverrideControllable)
// {
// bullet.Controllabe = Controllable;
// }
if (OverrideCreationModifier)
{
@ -101,6 +133,8 @@ public partial class ShootingPattern3D : AttackPattern
private int _burstBullets;
private int _currentBurstOffset = 0;
public void Start()
{
ScriptHost = Parent as IScriptHost3D;
@ -147,6 +181,7 @@ public partial class ShootingPattern3D : AttackPattern
if (_burstBullets <= 0)
{
_state = ShootStatus.WaitingReload;
_currentBurstOffset++;
}
else
{
@ -181,7 +216,7 @@ public partial class ShootingPattern3D : AttackPattern
private void Shoot()
{
float angleOffset = pattern._rotationOffset + (float)(pattern.rotationSpeed * timer);
float angleOffset = pattern._rotationOffset + (float)(pattern.rotationSpeed * timer) + (float)(pattern.BurstRotationSpeed * _currentBurstOffset);
Vector2 direction = pattern.BulletResource.Direction;

View file

@ -43,15 +43,25 @@ public partial class SpiralPattern : AttackPattern
[ExportCategory("Other")] [Export] public bool _predictPlayer = false;
[ExportCategory("Overrides")]
[Export] public bool OverrideOwner { get; private set; } = false;
[ExportGroup("Override Damage")]
[Export(PropertyHint.GroupEnable)] public bool OverrideDamage { get; private set; } = false;
[Export] public float DamageOverride { get; private set; } = 10f;
[ExportGroup("Override Owner")]
[Export(PropertyHint.GroupEnable)] public bool OverrideOwner { get; private set; } = false;
[Export] public BulletOwner Owner { get; private set; } = BulletOwner.None;
[Export] public bool OverrideDamageType { get; private set; } = false;
[ExportGroup("Override Damage Type")]
[Export(PropertyHint.GroupEnable)] public bool OverrideDamageType { get; private set; } = false;
[Export] public DamageType DamageType { get; private set; } = DamageType.Neutral;
[Export] public bool OverrideControllable { get; private set; } = false;
[Export] public bool Controllable { get; private set; } = false;
[ExportGroup("Override Attributes")]
[Export(PropertyHint.GroupEnable)] public bool OverrideAttributes { get; private set; } = false;
[Export] public BulletFlags AttributesOverride { get; private set; }
[ExportCategory("Extra Modifiers")]
[Export]
[Export(PropertyHint.GroupEnable)]
public bool OverrideCreationModifier { get; private set; } = false;
[Export] public BulletCreationModifier Modifier;
@ -72,9 +82,9 @@ public partial class SpiralPattern : AttackPattern
bullet.DamageType = DamageType;
}
if (OverrideControllable)
if (OverrideAttributes)
{
bullet.Controllabe = Controllable;
bullet.Attributes = AttributesOverride;
}
if (OverrideCreationModifier)

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Utils;
using Godot;
namespace Cirno.Scripts.Components;
@ -11,7 +12,7 @@ public class BulletInfo(BulletResource originalBulletResource)
public Vector2 Direction { get; set; }
public float Speed { get; set; }
public float LifeTime { get; set; }
public bool DestroyOnCollision { get; set; }
public bool DestroyOnCollision => Attributes.HasNoFlags(BulletFlags.Piercing);
public BulletOwner Owner { get; set; }
public DamageType DamageType { get; set; }
public float Damage { get; set; }
@ -21,15 +22,17 @@ public class BulletInfo(BulletResource originalBulletResource)
public float RotationOffset { get; set; }
//public double Time { get; set; }
public float Spread { get; set; }
public bool RotateSprite { get; set; } = false;
public bool Controllabe { get; set; } = false;
public bool Freezable { get; set; } = true;
public bool RotateSprite => Attributes.HasFlag(BulletFlags.Rotateable);
public bool Controllabe => Attributes.HasFlag(BulletFlags.Controllable);
public bool Freezable => Attributes.HasFlag(BulletFlags.Freezable);
public PackedScene BulletScene { get; set; }
public PackedScene DestructionParticlesScene { get; set; }
public IBulletModifier Modifier { get; set; }
public List<TimeModifier> TimeModifiers { get; set; } = new List<TimeModifier>();
public bool Grazeable { get; set; }
public bool Grazeable => Attributes.HasFlag(BulletFlags.Grazeable);
public float GrazeValue { get; set; }
public BulletFlags Attributes { get; set; }

View file

@ -0,0 +1,7 @@
namespace Cirno.Scripts.Enums;
public enum LoopType
{
PlayOnce,
Loop
}

View file

@ -0,0 +1 @@
uid://bn5p0n583d3tj

View file

@ -50,13 +50,13 @@ public partial class BulletResource : Resource
RotationOffset = rotationOffset,
Modifier = Modifier,
LifeTime = LifeTime,
DestroyOnCollision = Attributes.HasNoFlags(BulletFlags.Piercing),
//DestroyOnCollision = Attributes.HasNoFlags(BulletFlags.Piercing),
DestructionParticlesScene = DestructionParticlesScene,
RotateSprite = Attributes.HasFlag(BulletFlags.Rotateable),
Controllabe = Attributes.HasFlag(BulletFlags.Controllable),
Freezable = Attributes.HasFlag(BulletFlags.Freezable),
//RotateSprite = Attributes.HasFlag(BulletFlags.Rotateable),
//Controllabe = Attributes.HasFlag(BulletFlags.Controllable),
//Freezable = Attributes.HasFlag(BulletFlags.Freezable),
TimeModifiers = TimeModifiers.Select(x => x).ToList(),
Grazeable = Attributes.HasFlag(BulletFlags.Grazeable),
//Grazeable = Attributes.HasFlag(BulletFlags.Grazeable),
GrazeValue = GrazeValue,
Attributes = Attributes,
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()