Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Existing Node checks. #532

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Existing Node checks.
  • Loading branch information
MrPurple6411 committed Jan 15, 2024
commit 520be629c045c7b622d82db1460fddcd16a5175c
26 changes: 16 additions & 10 deletions Nautilus/Patchers/CraftTreePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static void GetTreePreFix(CraftTree.Type treeType, ref CraftTree __resul

private static void PatchCraftTree(ref CraftTree __result, CraftTree.Type type)
{
List<Node> removals = NodesToRemove.TryGetValue(type, out removals)? removals: new List<Node>();
List<Node> removals = NodesToRemove.TryGetValue(type, out removals) ? removals : new List<Node>();
RemoveNodes(ref __result, ref removals);

AddCustomTabs(ref __result, type);
Expand All @@ -135,7 +135,7 @@ private static void AddCustomTabs(ref CraftTree tree, CraftTree.Type type)
List<TabNode> customTabs = TabNodes.TryGetValue(type, out customTabs) ? customTabs : new List<TabNode>();
foreach (TabNode customNode in customTabs)
{
if(!TraverseTree(tree.nodes, customNode.Path, out var currentNode))
if (!TraverseTree(tree.nodes, customNode.Path, out var currentNode))
{
InternalLogger.Error($"Cannot add tab: {customNode.Name} to {customNode.Scheme} at {string.Join("/", customNode.Path)} as the parent node could not be found.");
continue;
Expand All @@ -147,11 +147,14 @@ private static void AddCustomTabs(ref CraftTree tree, CraftTree.Type type)
continue;
}

// Add the new tab node.
currentNode.AddNode(new TreeNode[]
if (TraverseTree(currentNode, new[] { customNode.Name }, out _))
{
new CraftNode(customNode.Name, TreeAction.Expand, TechType.None)
});
// This node already exists, skip it.
continue;
}

// Add the new tab node.
currentNode.AddNode(new CraftNode(customNode.Name, TreeAction.Expand, TechType.None));
InternalLogger.Debug($"Added tab: {customNode.Name} to {customNode.Scheme} at {string.Join("/", customNode.Path)}");
}
}
Expand Down Expand Up @@ -184,11 +187,14 @@ private static void PatchNodes(ref CraftTree tree, CraftTree.Type type)
}
}

// Add the node.
currentNode.AddNode(new TreeNode[]
if (TraverseTree(currentNode, new[] { customNode.TechType.AsString(false) }, out _))
{
new CraftNode(customNode.TechType.AsString(false), TreeAction.Craft, customNode.TechType)
});
// This node already exists, skip it.
continue;
}

// Add the node.
currentNode.AddNode(new CraftNode(customNode.TechType.AsString(false), TreeAction.Craft, customNode.TechType));
InternalLogger.Debug($"Added Crafting node: {customNode.TechType.AsString()} to {customNode.Scheme} at {string.Join("/", customNode.Path)}");
}
}
Expand Down