cirnogodot/Scripts/Resources/BulletResource.cs
2025-04-08 19:06:39 +02:00

66 lines
No EOL
2.4 KiB
C#

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 Vector2 Direction = Vector2.Right;
[Export] public float BulletDamage = 1;
[Export] public float LifeTime = 10f;
[Export] public bool DestroyOnCollision = true;
[Export] public BulletOwner Owner = BulletOwner.None;
[Export] public DamageType DamageType = DamageType.Neutral;
[Export] public bool Controllable = false;
[Export] public bool Grazeable { get; set; } = true;
[Export] public float GrazeValue { get; set; } = 0.2f;
[Export]
public BulletCreationModifier Modifier;
[Export] public Array<TimeModifier> TimeModifiers;
public BulletInfo MakeBullet(Vector2 position, int count = 1, float spread = 0f, float rotationOffset = 0f)
{
return new BulletInfo()
{
Position = position,
Direction = Direction,
Speed = BulletSpeed,
Owner = Owner,
DamageType = DamageType,
Damage = BulletDamage,
BulletCount = count,
Spread = spread,
BulletScene = BulletScene,
RotationOffset = rotationOffset,
Modifier = Modifier,
LifeTime = LifeTime,
DestroyOnCollision = DestroyOnCollision,
DestructionParticlesScene = DestructionParticlesScene,
Controllabe = Controllable,
TimeModifiers = TimeModifiers.Select(x => x).ToList(),
Grazeable = Grazeable,
GrazeValue = GrazeValue,
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
// {
// TimeModifier = m,
// Applied = false
// }).ToList()
// TimeModifiers = TimeModifiers?.Select(x => new ModifierWrapper()
// {
// Applied = false,
// TimeModifier = x
// })
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ??
// new List<TimeModifier>()
};
}
}