Characters
This commit is contained in:
48
Game/Scripts/WeaponSystem/WeaponDefinition.cs
Normal file
48
Game/Scripts/WeaponSystem/WeaponDefinition.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MegaKoop.Game.WeaponSystem
|
||||
{
|
||||
[CreateAssetMenu(fileName = "WeaponDefinition", menuName = "MegaKoop/Weapons/Weapon Definition", order = 0)]
|
||||
public class WeaponDefinition : ScriptableObject
|
||||
{
|
||||
[Header("Presentation")]
|
||||
[SerializeField] private string displayName = "Weapon";
|
||||
[SerializeField] private WeaponView viewPrefab;
|
||||
|
||||
[Header("Projectile")]
|
||||
[SerializeField] private Projectile projectilePrefab;
|
||||
[SerializeField] private float projectileSpeed = 25f;
|
||||
[SerializeField] private float projectileLifetime = 3f;
|
||||
|
||||
[Header("Firing")]
|
||||
[SerializeField] private float shotsPerSecond = 2f;
|
||||
[SerializeField] private float baseDamage = 10f;
|
||||
[SerializeField] private float range = 25f;
|
||||
[SerializeField] private int projectilesPerShot = 1;
|
||||
[SerializeField, Range(0f, 45f)] private float spreadAngle = 0f;
|
||||
[SerializeField] private LayerMask hitMask = Physics.DefaultRaycastLayers;
|
||||
|
||||
public string DisplayName => displayName;
|
||||
public WeaponView ViewPrefab => viewPrefab;
|
||||
public Projectile ProjectilePrefab => projectilePrefab;
|
||||
public float ProjectileSpeed => Mathf.Max(0f, projectileSpeed);
|
||||
public float ProjectileLifetime => Mathf.Max(0.05f, projectileLifetime);
|
||||
public float FireInterval => shotsPerSecond <= 0f ? float.MaxValue : 1f / shotsPerSecond;
|
||||
public float Damage => Mathf.Max(0f, baseDamage);
|
||||
public float Range => Mathf.Max(0f, range);
|
||||
public int ProjectilesPerShot => Mathf.Max(1, projectilesPerShot);
|
||||
public float SpreadAngle => Mathf.Abs(spreadAngle);
|
||||
public LayerMask HitMask => hitMask;
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
projectileSpeed = Mathf.Max(0f, projectileSpeed);
|
||||
projectileLifetime = Mathf.Max(0.05f, projectileLifetime);
|
||||
shotsPerSecond = Mathf.Max(0.01f, shotsPerSecond);
|
||||
baseDamage = Mathf.Max(0f, baseDamage);
|
||||
range = Mathf.Max(0f, range);
|
||||
projectilesPerShot = Mathf.Max(1, projectilesPerShot);
|
||||
spreadAngle = Mathf.Clamp(spreadAngle, 0f, 90f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user