cirnogodot/Scripts/Resources/BulletResource.cs

77 lines
2.8 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]
[Tool]
2025-02-12 16:20:55 +01:00
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;
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;
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;
2025-04-09 16:41:22 +02:00
[Export] public bool RotateSprite = false;
2025-02-27 18:48:13 +01:00
[Export] public bool Controllable = false;
2025-04-26 11:24:20 +02:00
[Export] public bool Freezable { get; set; } = true;
2025-04-01 15:46:25 +02:00
[Export] public bool Grazeable { get; set; } = true;
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;
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-02-20 12:17:21 +01:00
DestroyOnCollision = DestroyOnCollision,
2025-02-12 16:20:55 +01:00
DestructionParticlesScene = DestructionParticlesScene,
2025-04-09 16:41:22 +02:00
RotateSprite = RotateSprite,
2025-02-27 18:48:13 +01:00
Controllabe = Controllable,
2025-04-26 11:24:20 +02:00
Freezable = Freezable,
2025-04-01 15:46:25 +02:00
TimeModifiers = TimeModifiers.Select(x => x).ToList(),
Grazeable = Grazeable,
GrazeValue = GrazeValue,
2025-06-03 10:11:09 +02:00
Attributes = Attributes,
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
};
}
}