cirnogodot/Scripts/Resources/BulletResource.cs

84 lines
3.2 KiB
C#
Raw Permalink Normal View History

2025-02-12 16:20:55 +01:00
using System.Collections.Generic;
using System.Linq;
2026-01-31 10:23:10 +01:00
using Cirno.Scripts.Actors._3D;
2025-02-12 16:20:55 +01:00
using Cirno.Scripts.Components;
2025-07-01 13:40:13 +02:00
using Cirno.Scripts.Utils;
2025-02-12 16:20:55 +01:00
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Resources;
[GlobalClass]
[Tool]
2025-02-12 16:20:55 +01:00
public partial class BulletResource : Resource
{
[Export]
public PackedScene BulletScene { get; set; }
2025-07-01 13:40:13 +02:00
[Export] public Texture2D BulletSprite { get; set; }
[Export] public float BulletSize { get; set; }
2025-02-12 16:20:55 +01:00
[Export] public PackedScene DestructionParticlesScene { get; set; }
2025-08-06 15:31:52 +02:00
[Export] public BulletResource DestructionParticlesBullet { get; set; }
2025-02-12 16:20:55 +01:00
[Export] public float BulletSpeed = 100f;
2025-02-20 17:43:05 +01:00
[Export] public Vector2 Direction = Vector2.Right;
2025-02-12 16:20:55 +01:00
[Export] public float BulletDamage = 1;
2025-05-20 15:57:35 +02:00
[Export] public float MaxDamage = 1;
2025-05-06 16:06:00 +02:00
[Export] public float Knockback = 1;
2025-02-12 16:20:55 +01:00
[Export] public float LifeTime = 10f;
[Export] public BulletOwner Owner = BulletOwner.None;
[Export] public DamageType DamageType = DamageType.Neutral;
2025-04-08 19:06:39 +02:00
[Export] public float GrazeValue { get; set; } = 0.2f;
2025-02-12 16:20:55 +01:00
2025-06-03 10:11:09 +02:00
[Export] public BulletFlags Attributes { get; set; }
2025-02-12 16:20:55 +01:00
[Export]
2025-02-13 14:32:24 +01:00
public BulletCreationModifier Modifier;
2025-02-14 13:47:20 +01:00
[Export] public Array<TimeModifier> TimeModifiers;
2026-01-31 10:23:10 +01:00
// Laser-specific properties
[ExportGroup("Laser Settings")]
[Export] public bool IsLaser { get; set; }
[Export] public LaserConfig LaserConfig { get; set; }
2025-02-27 18:48:13 +01:00
2025-02-12 16:20:55 +01:00
public BulletInfo MakeBullet(Vector2 position, int count = 1, float spread = 0f, float rotationOffset = 0f)
{
return new BulletInfo(this)
2025-02-12 16:20:55 +01:00
{
Position = position,
2025-02-20 17:43:05 +01:00
Direction = Direction,
2025-02-12 16:20:55 +01:00
Speed = BulletSpeed,
Owner = Owner,
DamageType = DamageType,
Damage = BulletDamage,
2025-05-06 16:06:00 +02:00
Knockback = Knockback,
2025-02-12 16:20:55 +01:00
BulletCount = count,
Spread = spread,
BulletScene = BulletScene,
RotationOffset = rotationOffset,
2025-02-13 14:32:24 +01:00
Modifier = Modifier,
2025-02-12 16:20:55 +01:00
LifeTime = LifeTime,
2025-09-24 16:51:47 +02:00
//DestroyOnCollision = Attributes.HasNoFlags(BulletFlags.Piercing),
2025-02-12 16:20:55 +01:00
DestructionParticlesScene = DestructionParticlesScene,
2025-09-24 16:51:47 +02:00
//RotateSprite = Attributes.HasFlag(BulletFlags.Rotateable),
//Controllabe = Attributes.HasFlag(BulletFlags.Controllable),
//Freezable = Attributes.HasFlag(BulletFlags.Freezable),
2025-04-01 15:46:25 +02:00
TimeModifiers = TimeModifiers.Select(x => x).ToList(),
2025-09-24 16:51:47 +02:00
//Grazeable = Attributes.HasFlag(BulletFlags.Grazeable),
2025-04-01 15:46:25 +02:00
GrazeValue = GrazeValue,
2025-06-03 10:11:09 +02:00
Attributes = Attributes,
2026-01-31 10:23:10 +01:00
IsLaser = IsLaser,
LaserConfig = LaserConfig
2025-02-14 13:47:20 +01:00
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
// {
// TimeModifier = m,
// Applied = false
// }).ToList()
2025-02-13 18:25:55 +01:00
// TimeModifiers = TimeModifiers?.Select(x => new ModifierWrapper()
// {
// Applied = false,
// TimeModifier = x
// })
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ??
// new List<TimeModifier>()
2025-02-12 16:20:55 +01:00
};
}
}