Further updates to state machines
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Interactions;
|
||||
|
||||
namespace AppleHills.Core.Settings
|
||||
{
|
||||
@@ -88,5 +89,31 @@ namespace AppleHills.Core.Settings
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a pickup prefab by its itemData.itemId.
|
||||
/// Searches through combination rules to find result prefabs.
|
||||
/// Used to spawn dynamically created items during save/load.
|
||||
/// </summary>
|
||||
public GameObject FindPickupPrefabByItemId(string itemId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(itemId) || combinationRules == null)
|
||||
return null;
|
||||
|
||||
// Search through combination rules to find a result prefab with matching itemId
|
||||
foreach (var rule in combinationRules)
|
||||
{
|
||||
if (rule.resultPrefab != null)
|
||||
{
|
||||
var pickup = rule.resultPrefab.GetComponent<Pickup>();
|
||||
if (pickup != null && pickup.itemData != null && pickup.itemData.itemId == itemId)
|
||||
{
|
||||
return rule.resultPrefab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace AppleHills.Core.Settings
|
||||
// Methods to query item configurations
|
||||
CombinationRule GetCombinationRule(PickupItemData item1, PickupItemData item2);
|
||||
SlotItemConfig GetSlotItemConfig(PickupItemData slotItem);
|
||||
GameObject FindPickupPrefabByItemId(string itemId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user