Skip to content

Commit

Permalink
pillar fix queue
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Dec 15, 2022
1 parent 86c217e commit 4722df8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions NodeController/Patches/BuilidingManger_SimulationStep_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace NodeController.Patches {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HarmonyLib;

[HarmonyPatch(typeof(BuildingManager),"SimulationStepImpl")]
internal static class BuilidingManger_SimulationStep_Patch {
// must be read/write from simulation thread.
internal static HashSet<ushort> FixPillarNodeIDs = new();
static void Prefix() {
foreach(var nodeID in FixPillarNodeIDs) {
NodeData.FixPillar(nodeID);
}
FixPillarNodeIDs.Clear();
}
}
}
2 changes: 1 addition & 1 deletion NodeController/Patches/NetNodePatches/UpdateBuilding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NodeController.Patches;
class UpdateBuilding {
/// <summary>in case another mod updated node building without performing a full update</summary>
static void Postfix(ushort nodeID) {
SimulationManager.instance.AddAction(() => NodeData.FixPillar(nodeID));
BuilidingManger_SimulationStep_Patch.FixPillarNodeIDs.Add(nodeID);
}
}
#endif
2 changes: 1 addition & 1 deletion NodeController/Patches/NetSegmentPatches/UpdateSegments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static void Postfix(ushort segmentID, bool startNode) {

ref NetSegment segment = ref segmentID.ToSegment();
ushort nodeID = segment.GetNode(startNode);
SimulationManager.instance.AddAction(() => NodeData.FixPillar(nodeID));
BuilidingManger_SimulationStep_Patch.FixPillarNodeIDs.Add(nodeID);
} catch (Exception ex) { ex.Log($"segment:{segmentID}"); }
}
}
Expand Down

0 comments on commit 4722df8

Please sign in to comment.