2026-05-20 무기슬롯
This commit is contained in:
@@ -27,6 +27,9 @@ public class PlayerWeaponInventory : MonoBehaviour
|
||||
// 무기 교체 시 발화. null이면 맨손.
|
||||
public event Action<WeaponData> OnWeaponChanged;
|
||||
|
||||
// 인벤토리 상태(목록 추가·장착 변경)가 바뀔 때마다 발화. UI 갱신용.
|
||||
public event Action OnInventoryChanged;
|
||||
|
||||
public WeaponData CurrentWeapon =>
|
||||
_currentIndex >= 0 && _currentIndex < _weapons.Count
|
||||
? _weapons[_currentIndex]
|
||||
@@ -34,6 +37,10 @@ public class PlayerWeaponInventory : MonoBehaviour
|
||||
public bool IsArmed => CurrentWeapon != null;
|
||||
public int Count => _weapons.Count;
|
||||
|
||||
// UI 등 외부에서 읽기 전용으로 목록/장착 인덱스 조회 (UI는 데이터를 소유하지 않는다).
|
||||
public IReadOnlyList<WeaponData> Weapons => _weapons;
|
||||
public int CurrentIndex => _currentIndex;
|
||||
|
||||
// 무기 추가. 이미 보유 중이면 false 반환 (중복 픽업 방지).
|
||||
// 첫 픽업 시 자동 장착할지는 호출자가 OnWeaponChanged를 보고 결정.
|
||||
public bool Pickup(WeaponData weapon)
|
||||
@@ -50,6 +57,7 @@ public bool Pickup(WeaponData weapon)
|
||||
OnWeaponChanged?.Invoke(_weapons[0]);
|
||||
}
|
||||
|
||||
OnInventoryChanged?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -59,6 +67,7 @@ public void EquipUnarmed()
|
||||
if (_currentIndex == -1) return;
|
||||
_currentIndex = -1;
|
||||
OnWeaponChanged?.Invoke(null);
|
||||
OnInventoryChanged?.Invoke();
|
||||
}
|
||||
|
||||
// 슬롯 번호로 직접 장착. 슬롯이 비어있으면 무시.
|
||||
@@ -68,6 +77,7 @@ public void EquipSlot(int slotIndex)
|
||||
if (_currentIndex == slotIndex) return;
|
||||
_currentIndex = slotIndex;
|
||||
OnWeaponChanged?.Invoke(_weapons[slotIndex]);
|
||||
OnInventoryChanged?.Invoke();
|
||||
}
|
||||
|
||||
// 디버그용: 슬롯에 해당 무기가 있는지 확인.
|
||||
|
||||
Reference in New Issue
Block a user