mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Account for going back and forth and yanking tons of items
This commit is contained in:
parent
5ddcae3d15
commit
fafb0a5df0
@ -17,7 +17,7 @@ public static class HeldItemHandler
|
|||||||
/// Dictionary of system name to item path
|
/// Dictionary of system name to item path
|
||||||
/// If we travel to multiple systems within a single loop, this will hold the items we move between systems
|
/// If we travel to multiple systems within a single loop, this will hold the items we move between systems
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static Dictionary<string, string> _pathOfItemTakenFromSystem = new();
|
private static Dictionary<string, List<string>> _pathOfItemTakenFromSystem = new();
|
||||||
|
|
||||||
private static GameObject _currentlyHeldItem;
|
private static GameObject _currentlyHeldItem;
|
||||||
|
|
||||||
@ -86,7 +86,11 @@ public static class HeldItemHandler
|
|||||||
// Track it so that when we return to this system we can delete the original
|
// Track it so that when we return to this system we can delete the original
|
||||||
if (_trackedPaths.TryGetValue(_currentlyHeldItem, out var path))
|
if (_trackedPaths.TryGetValue(_currentlyHeldItem, out var path))
|
||||||
{
|
{
|
||||||
_pathOfItemTakenFromSystem[Main.Instance.CurrentStarSystem] = path;
|
if (!_pathOfItemTakenFromSystem.ContainsKey(Main.Instance.CurrentStarSystem))
|
||||||
|
{
|
||||||
|
_pathOfItemTakenFromSystem[Main.Instance.CurrentStarSystem] = new();
|
||||||
|
}
|
||||||
|
_pathOfItemTakenFromSystem[Main.Instance.CurrentStarSystem].Add(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
NHLogger.Log($"Scene unloaded, preserved inactive held item {_currentlyHeldItem.name}");
|
NHLogger.Log($"Scene unloaded, preserved inactive held item {_currentlyHeldItem.name}");
|
||||||
@ -101,7 +105,9 @@ public static class HeldItemHandler
|
|||||||
private static void OnSystemReady(string _)
|
private static void OnSystemReady(string _)
|
||||||
{
|
{
|
||||||
// If something was taken from this system during this life, remove it
|
// If something was taken from this system during this life, remove it
|
||||||
if (_pathOfItemTakenFromSystem.TryGetValue(Main.Instance.CurrentStarSystem, out var path))
|
if (_pathOfItemTakenFromSystem.TryGetValue(Main.Instance.CurrentStarSystem, out var paths))
|
||||||
|
{
|
||||||
|
foreach (var path in paths)
|
||||||
{
|
{
|
||||||
NHLogger.Log($"Removing item that was taken from this system at {path}");
|
NHLogger.Log($"Removing item that was taken from this system at {path}");
|
||||||
var item = SearchUtilities.Find(path)?.GetComponent<OWItem>();
|
var item = SearchUtilities.Find(path)?.GetComponent<OWItem>();
|
||||||
@ -112,6 +118,7 @@ public static class HeldItemHandler
|
|||||||
}
|
}
|
||||||
GameObject.Destroy(item.gameObject);
|
GameObject.Destroy(item.gameObject);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Give whatever item we were previously holding
|
// Give whatever item we were previously holding
|
||||||
if (_currentlyHeldItem != null)
|
if (_currentlyHeldItem != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user