cirnogodot/Scripts/Resources/BulletResource.cs

60 lines
2.2 KiB
C#
Raw Normal View History

2025-02-12 16:20:55 +01:00
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;
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;
[Export] public float LifeTime = 10f;
2025-02-20 12:17:21 +01:00
[Export] public bool DestroyOnCollision = true;
2025-02-12 16:20:55 +01:00
[Export] public BulletOwner Owner = BulletOwner.None;
[Export] public DamageType DamageType = DamageType.Neutral;
[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;
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()
{
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,
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-02-20 12:17:21 +01:00
DestroyOnCollision = DestroyOnCollision,
2025-02-12 16:20:55 +01:00
DestructionParticlesScene = DestructionParticlesScene,
2025-02-14 16:18:33 +01:00
TimeModifiers = TimeModifiers.Select(x => x).ToList()
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
};
}
}