mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Make proxies searchable
This commit is contained in:
parent
6eb1209bcc
commit
e397cbc7c5
@ -1,4 +1,5 @@
|
||||
using NewHorizons.Components.SizeControllers;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -19,6 +20,7 @@ namespace NewHorizons.Components
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
ProxyHandler.RegisterProxy(this);
|
||||
base.Awake();
|
||||
|
||||
// The star part cant be disabled like the rest and we have to manually disable the renderers
|
||||
@ -42,6 +44,11 @@ namespace NewHorizons.Components
|
||||
ToggleRendering(false);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
ProxyHandler.UnregisterProxy(this);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AstroObject astroObject = AstroObjectLocator.GetAstroObject(astroName);
|
||||
|
||||
34
NewHorizons/Handlers/ProxyHandler.cs
Normal file
34
NewHorizons/Handlers/ProxyHandler.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using NewHorizons.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
public static class ProxyHandler
|
||||
{
|
||||
private static List<NHProxy> _proxies = new List<NHProxy>();
|
||||
|
||||
public static NHProxy GetProxy(string astroName)
|
||||
{
|
||||
foreach (NHProxy proxy in _proxies)
|
||||
{
|
||||
if (proxy.astroName.Equals(astroName))
|
||||
return proxy;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void RegisterProxy(NHProxy proxy)
|
||||
{
|
||||
_proxies.SafeAdd(proxy);
|
||||
}
|
||||
|
||||
public static void UnregisterProxy(NHProxy proxy)
|
||||
{
|
||||
_proxies.Remove(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user