Files
megakoop/Game/Scripts/WeaponSystem/WeaponView.cs
2025-10-05 18:21:16 +02:00

44 lines
1.0 KiB
C#

using UnityEngine;
namespace MegaKoop.Game.WeaponSystem
{
public class WeaponView : MonoBehaviour
{
[SerializeField] private Transform[] muzzles;
public Transform[] Muzzles => muzzles;
public Transform GetMuzzle(int index = 0)
{
if (muzzles == null || muzzles.Length == 0)
{
return transform;
}
index = Mathf.Clamp(index, 0, muzzles.Length - 1);
return muzzles[index] == null ? transform : muzzles[index];
}
#if UNITY_EDITOR
private void OnDrawGizmosSelected()
{
if (muzzles == null)
{
return;
}
Gizmos.color = Color.cyan;
foreach (Transform muzzle in muzzles)
{
if (muzzle == null)
{
continue;
}
Gizmos.DrawLine(muzzle.position, muzzle.position + muzzle.forward * 0.5f);
}
}
#endif
}
}