diff --git a/PathfinderAPI/BaseGameFixes/Performance/NodeLookup.cs b/PathfinderAPI/BaseGameFixes/Performance/NodeLookup.cs index fa8e477b..4bff3e77 100644 --- a/PathfinderAPI/BaseGameFixes/Performance/NodeLookup.cs +++ b/PathfinderAPI/BaseGameFixes/Performance/NodeLookup.cs @@ -1,4 +1,5 @@ -using Hacknet; +using System.Collections.Generic; +using Hacknet; using HarmonyLib; using Pathfinder.Event; using Pathfinder.Event.Loading; @@ -9,24 +10,14 @@ namespace Pathfinder.BaseGameFixes.Performance [HarmonyPatch] internal static class NodeLookup { - [Util.Initialize] - internal static void Initialize() - { - EventManager.AddHandler(PopulateOnComputerLoad); - } - [HarmonyPostfix] - [HarmonyPatch(typeof(ComputerLoader), nameof(ComputerLoader.loadComputer))] - internal static void PopulateOnComputerCreation(object __result) - { - if (__result == null) - return; - ComputerLookup.PopulateLookups((Computer) __result); - } - - internal static void PopulateOnComputerLoad(SaveComputerLoadedEvent args) + [HarmonyPatch(typeof(List), nameof(List.Add))] + internal static void AddComputerReference(List __instance, Computer item) { - ComputerLookup.PopulateLookups(args.Comp); + if (object.ReferenceEquals(__instance, OS.currentInstance?.netMap?.nodes)) + { + ComputerLookup.PopulateLookups(item); + } } [HarmonyPrefix]