mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using NewHorizons.Components;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace NewHorizons.Handlers
|
|
{
|
|
public static class ProxyHandler
|
|
{
|
|
private static List<NHProxy> _proxies = new();
|
|
private static Dictionary<Transform, ProxyBody> _vanillaProxyBody = new();
|
|
private static Dictionary<Transform, ProxyOrbiter> _vanillaProxyOrbiter = new();
|
|
|
|
public static void OnSceneUnloaded()
|
|
{
|
|
_proxies.Clear();
|
|
_vanillaProxyBody.Clear();
|
|
_vanillaProxyOrbiter.Clear();
|
|
}
|
|
|
|
public static NHProxy GetProxy(string astroName)
|
|
{
|
|
foreach (NHProxy proxy in _proxies)
|
|
{
|
|
if (proxy.astroName.Equals(astroName))
|
|
return proxy;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void RegisterVanillaProxyBody(ProxyBody proxy)
|
|
{
|
|
_vanillaProxyBody.Add(proxy.realObjectTransform, proxy);
|
|
}
|
|
|
|
public static ProxyBody GetVanillaProxyBody(Transform t)
|
|
{
|
|
if (_vanillaProxyBody.TryGetValue(t, out ProxyBody proxy))
|
|
{
|
|
return proxy;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static void RegisterVanillaProxyOrbiter(ProxyOrbiter proxy)
|
|
{
|
|
_vanillaProxyOrbiter.Add(proxy._originalPlanetBody, proxy);
|
|
}
|
|
|
|
public static ProxyOrbiter GetVanillaProxyOrbiter(Transform t)
|
|
{
|
|
if (_vanillaProxyOrbiter.TryGetValue(t, out ProxyOrbiter proxy))
|
|
{
|
|
return proxy;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static void RegisterProxy(NHProxy proxy)
|
|
{
|
|
_proxies.SafeAdd(proxy);
|
|
}
|
|
|
|
public static void UnregisterProxy(NHProxy proxy)
|
|
{
|
|
_proxies.Remove(proxy);
|
|
}
|
|
}
|
|
}
|