36 lines
925 B
C#
36 lines
925 B
C#
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];
|
|
}
|
|
}
|