cirnogodot/Scripts/Resources/WeaponResource.cs

82 lines
2.5 KiB
C#
Raw Normal View History

2025-02-11 19:00:01 +01:00
using System.Collections.Generic;
using System.Linq;
2025-02-09 23:20:49 +01:00
using Cirno.Scripts.Components;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Resources;
[GlobalClass]
[Tool]
2025-02-09 23:20:49 +01:00
public partial class WeaponResource : Resource
{
[Export]
2025-03-13 13:29:13 +01:00
public StringName Name { get; set; }
2025-02-09 23:20:49 +01:00
2025-02-12 16:20:55 +01:00
[Export] public BulletResource BulletData { get; private set; }
//[Export]
//public PackedScene BulletScene { get; set; }
//[Export] public PackedScene DestructionParticlesScene { get; set; }
2025-05-01 11:10:36 +02:00
[Export] public int Priority { get; set; } = 0;
2025-05-02 13:10:38 +02:00
[Export] public int AmmoPerShot { get; set; } = 1;
2025-02-09 23:20:49 +01:00
[Export] public double RateOfFire = 0.4f;
[Export] public int BulletCapacity = 20;
[Export] public double ReloadTime = 1.0f;
[Export] public bool AutoReload = true;
[Export] public bool InfiniteAmmo = true;
2025-03-13 13:29:13 +01:00
[Export] public StringName ItemKey;
2025-04-08 17:59:20 +02:00
[Export] public StringName AmmoKey;
2025-02-09 23:20:49 +01:00
#region Bullet spawn data
2025-04-08 17:59:20 +02:00
[ExportCategory("Bullet Spawn Data")]
[Export] public int BulletsPerShot = 1;
2025-02-09 23:20:49 +01:00
2025-04-08 17:59:20 +02:00
[Export] public float SpreadAngle = 0f;
[Export] public float RandomSpread = 0f;
2025-02-12 16:20:55 +01:00
//[Export] public float BulletSpeed = 100f;
//[Export] public float BulletDamage = 1;
//[Export] public float LifeTime = 10f;
2025-02-09 23:20:49 +01:00
[Export] private float _rotationOffset = 0f;
2025-02-12 16:20:55 +01:00
//[Export] private BulletOwner owner = BulletOwner.None;
//[Export] private DamageType _damageType = DamageType.Neutral;
//[Export] private Resource _modifier;
//[Export] private Array<Resource> _timeModifiers;
2025-02-09 23:20:49 +01:00
#endregion
2025-04-08 17:59:20 +02:00
[ExportCategory("Sounds")]
[Export] public AudioStream ReloadSound { get; set; }
[Export] public AudioStream ShootSound { get; set; }
[Export] public AudioStream EmptySound { get; set; }
2025-02-09 23:20:49 +01:00
2025-02-11 19:00:01 +01:00
public BulletInfo MakeBullet(Vector2 position)
{
2025-02-12 16:20:55 +01:00
return BulletData.MakeBullet(position, BulletsPerShot, SpreadAngle, _rotationOffset);
// return new BulletInfo()
// {
// Position = position,
// Direction = Vector2.Right,
// Speed = BulletSpeed,
// Owner = owner,
// DamageType = _damageType,
// Damage = BulletDamage,
// BulletCount = BulletsPerShot,
// Spread = SpreadAngle,
// BulletScene = BulletScene,
// RotationOffset = _rotationOffset,
// Modifier = _modifier as IBulletModifier,
// LifeTime = LifeTime,
// DestructionParticlesScene = DestructionParticlesScene,
// TimeModifiers = _timeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ??
// new List<TimeModifier>()
// };
2025-02-11 19:00:01 +01:00
}
2025-02-09 23:20:49 +01:00
}