Skip to content

Commit

Permalink
Populate ComputerLookup on add to netMap list
Browse files Browse the repository at this point in the history
  • Loading branch information
Windows10CE committed Jul 22, 2021
1 parent 3b3d745 commit 88ba02b
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions PathfinderAPI/BaseGameFixes/Performance/NodeLookup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Hacknet;
using System.Collections.Generic;
using Hacknet;
using HarmonyLib;
using Pathfinder.Event;
using Pathfinder.Event.Loading;
Expand All @@ -9,24 +10,14 @@ namespace Pathfinder.BaseGameFixes.Performance
[HarmonyPatch]
internal static class NodeLookup
{
[Util.Initialize]
internal static void Initialize()
{
EventManager<SaveComputerLoadedEvent>.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<Computer>), nameof(List<Computer>.Add))]
internal static void AddComputerReference(List<Computer> __instance, Computer item)
{
ComputerLookup.PopulateLookups(args.Comp);
if (object.ReferenceEquals(__instance, OS.currentInstance?.netMap?.nodes))
{
ComputerLookup.PopulateLookups(item);
}
}

[HarmonyPrefix]
Expand Down

0 comments on commit 88ba02b

Please sign in to comment.