stack item pickup (in progress), throwable hand consumes items, spawnable objects tied to item definitions
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ItemInstantiationManager : MonoBehaviour
|
||||
{
|
||||
private Dictionary<ItemIdEnum, GameObject> spawnablePrefabs = new Dictionary<ItemIdEnum, GameObject>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
LoadSpawnablePrefabs();
|
||||
}
|
||||
|
||||
private void LoadSpawnablePrefabs()
|
||||
{
|
||||
foreach (ItemIdEnum itemId in Enum.GetValues(typeof(ItemIdEnum)))
|
||||
{
|
||||
Item item = ItemUtilities.GetItemFromId(itemId);
|
||||
|
||||
if (item.throwable)
|
||||
{
|
||||
GameObject prefab = Resources.Load<GameObject>($"SpawnablePrefabs/ID_{itemId.ToString()}");
|
||||
if (prefab != null)
|
||||
{
|
||||
spawnablePrefabs.Add(itemId, prefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject GetThrowablePrefab(ItemIdEnum itemId)
|
||||
{
|
||||
return spawnablePrefabs[itemId];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user