Remove dependencies on legacy variables in GameManager.Instance
This commit is contained in:
@@ -3,6 +3,7 @@ using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using System; // for Action<T>
|
||||
using Core; // register with ItemManager
|
||||
using AppleHills.Core.Settings; // Added for IInteractionSettings
|
||||
|
||||
namespace Interactions
|
||||
{
|
||||
@@ -24,6 +25,10 @@ namespace Interactions
|
||||
// Tracks the current state of the slotted item
|
||||
private ItemSlotState _currentState = ItemSlotState.None;
|
||||
|
||||
// Settings reference
|
||||
private IInteractionSettings _interactionSettings;
|
||||
private IPlayerFollowerSettings _playerFollowerSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Read-only access to the current slotted item state.
|
||||
/// </summary>
|
||||
@@ -64,13 +69,22 @@ namespace Interactions
|
||||
}
|
||||
}
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
// Initialize settings references
|
||||
_interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>();
|
||||
_playerFollowerSettings = GameManager.GetSettingsObject<IPlayerFollowerSettings>();
|
||||
}
|
||||
|
||||
protected override void OnCharacterArrived()
|
||||
{
|
||||
Debug.Log("[ItemSlot] OnCharacterArrived");
|
||||
|
||||
var heldItemData = FollowerController.CurrentlyHeldItemData;
|
||||
var heldItemObj = FollowerController.GetHeldPickupObject();
|
||||
var config = GameManager.Instance.GetSlotItemConfig(itemData);
|
||||
var config = _interactionSettings?.GetSlotItemConfig(itemData);
|
||||
var forbidden = config?.forbiddenItems ?? new List<PickupItemData>();
|
||||
|
||||
// Held item, slot empty -> try to slot item
|
||||
@@ -120,7 +134,7 @@ namespace Interactions
|
||||
{
|
||||
slottedItemRenderer.sprite = _currentlySlottedItemData.mapSprite;
|
||||
// Scale sprite to desired height, preserve aspect ratio, compensate for parent scale
|
||||
float desiredHeight = GameManager.Instance.HeldIconDisplayHeight;
|
||||
float desiredHeight = _playerFollowerSettings?.HeldIconDisplayHeight ?? 2.0f;
|
||||
var sprite = _currentlySlottedItemData.mapSprite;
|
||||
float spriteHeight = sprite.bounds.size.y;
|
||||
float spriteWidth = sprite.bounds.size.x;
|
||||
@@ -175,7 +189,7 @@ namespace Interactions
|
||||
|
||||
// Once an item is slotted, we know it is not forbidden, so we can skip that check, but now check if it was
|
||||
// the correct item we're looking for
|
||||
var config = GameManager.Instance.GetSlotItemConfig(itemData);
|
||||
var config = _interactionSettings?.GetSlotItemConfig(itemData);
|
||||
var allowed = config?.allowedItems ?? new List<PickupItemData>();
|
||||
if (itemToSlotData != null && PickupItemData.ListContainsEquivalent(allowed, itemToSlotData))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user