stack item pickup (in progress), throwable hand consumes items, spawnable objects tied to item definitions

This commit is contained in:
2026-09-16 22:48:52 -05:00
parent d8295719b0
commit f4642ea005
17 changed files with 444 additions and 26 deletions
+2
View File
@@ -17,6 +17,7 @@ public class GameManager : MonoBehaviour
public MenuController MenuController { get; private set; }
public SoundSettingManager SoundSettingManager { get; private set; }
public PlayerController PlayerController { get; private set; }
public ItemInstantiationManager ItemInstantiationManager { get; private set; }
public Image BlackScreen { get; private set; }
// Are we currently in a scene transition?
@@ -59,6 +60,7 @@ private void ReloadReferences()
Instance.Inventory = GetComponent<Inventory>();
Instance.TimeManager = GetComponent<TimeManager>();
Instance.PlayerManager = GetComponent<PlayerManager>();
Instance.ItemInstantiationManager = GetComponent<ItemInstantiationManager>();
Instance.SoundSettingManager = GetComponent<SoundSettingManager>();
Instance.SoundSettingManager.ReloadReferences();
@@ -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];
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f2dcea982e135f3448df561481c5fea7
@@ -255,14 +255,14 @@ void RotatePlayerTowardMouse()
Vector3 targetPoint;
// 1. Try real world hit first (most stable)
if (Physics.Raycast(ray, out RaycastHit hit, 1000f))
// Try real world hit first (most stable), ignoring Dither layer
if (Physics.Raycast(ray, out RaycastHit hit, 1000f, ~LayerMask.GetMask("Dither")))
{
targetPoint = hit.point;
}
else
{
// 2. Fallback to plane at player height
// Fallback to plane at player height
Plane plane = new Plane(Vector3.up, DougBody.transform.position);
if (!plane.Raycast(ray, out float enter))