Moved the player inventory and selected slot to VesnaEntity
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
using Babushka.scripts.CSharp.Common.Inventory;
|
||||
using Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
using Babushka.scripts.CSharp.GameEntity.Management;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
@@ -10,21 +12,21 @@ public partial class InventoryDependentInteractable : Node2D
|
||||
[Export] private InteractionArea2D _interactionArea;
|
||||
[Export] private Array<ItemResource> _itemsToReactTo;
|
||||
[Export] private bool _activateOnItem = true;
|
||||
|
||||
private InventoryManager _inventoryManager;
|
||||
private InventoryInstance _inventoryInstance;
|
||||
|
||||
private VesnaEntity _vesnaEntity;
|
||||
private InventoryInstance _playerInventory;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_inventoryManager = InventoryManager.Instance;
|
||||
_inventoryInstance = _inventoryManager.playerInventory;
|
||||
_inventoryManager.SlotIndexChanged += HandleInventorySelectedSlotIndexChanged;
|
||||
_vesnaEntity = EntityManager.Instance.GetUniqueEntity<VesnaEntity>();
|
||||
_playerInventory = _vesnaEntity.inventory;
|
||||
_vesnaEntity.SlotIndexChanged += HandleInventorySelectedSlotIndexChanged;
|
||||
}
|
||||
|
||||
private void HandleInventorySelectedSlotIndexChanged(int newIndex)
|
||||
{
|
||||
int currentSlotIndex = InventoryManager.Instance.CurrentSelectedSlotIndex;
|
||||
ItemInstance? item = InventoryManager.Instance.playerInventory.Slots[currentSlotIndex].itemInstance;
|
||||
int currentSlotIndex = _vesnaEntity.CurrentSelectedSlotIndex;
|
||||
ItemInstance? item = _playerInventory.Slots[currentSlotIndex].itemInstance;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user