Skip to content

Commit

Permalink
Fix Custom Fabricators not being able to be changed by handlers. (#481)
Browse files Browse the repository at this point in the history
fix: Correct not using the ModCraftTreeLinkingNode.CraftTreeLinkingNodes when making custom fabricators.
  • Loading branch information
MrPurple6411 committed Oct 1, 2023
1 parent 9f27720 commit 0c0c45c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Nautilus/Assets/Gadgets/FabricatorGadget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Nautilus.Assets.Gadgets;
public class FabricatorGadget : Gadget
{
private const string RootNode = "root";
private readonly Dictionary<string, ModCraftTreeLinkingNode> _craftTreeLinkingNodes = new();
private readonly List<Action> _orderedCraftTreeActions = new();

/// <summary>
Expand All @@ -38,7 +37,6 @@ public FabricatorGadget(ICustomPrefab prefab) : base(prefab)
{
CraftTreeType = EnumHandler.AddEntry<CraftTree.Type>(prefab.Info.ClassID).CreateCraftTreeRoot(out var root);
Root = root;
_craftTreeLinkingNodes.Add(RootNode, root);
}

/// <summary>
Expand All @@ -54,9 +52,9 @@ public FabricatorGadget AddTabNode(string tabId, string displayText, Sprite tabI
{
_orderedCraftTreeActions.Add(() =>
{
var parentNode = _craftTreeLinkingNodes[parentTabId ?? RootNode];
var parentNode = Root.CraftTreeLinkingNodes[parentTabId ?? RootNode];
var tab = parentNode.AddTabNode(tabId, displayText, tabIcon, language);
_craftTreeLinkingNodes[tabId] = tab;
Root.CraftTreeLinkingNodes[tabId] = tab;
});

return this;
Expand All @@ -73,7 +71,7 @@ public FabricatorGadget AddCraftNode(TechType techType, string parentTabId = nul
InternalLogger.Debug($"'{techType.AsString()}' will be added to the custom craft tree '{prefab.Info.ClassID}'");
_orderedCraftTreeActions.Add(() =>
{
ModCraftTreeLinkingNode parentTab = _craftTreeLinkingNodes[parentTabId ?? RootNode];
ModCraftTreeLinkingNode parentTab = Root.CraftTreeLinkingNodes[parentTabId ?? RootNode];
parentTab.AddCraftingNode(techType);
});

Expand All @@ -94,7 +92,7 @@ public FabricatorGadget AddCraftNode(string moddedTechType, string parentTabId =
{
if (EnumHandler.TryGetValue(moddedTechType, out TechType techType))
{
ModCraftTreeLinkingNode parentTab = _craftTreeLinkingNodes[parentTabId ?? RootNode];
ModCraftTreeLinkingNode parentTab = Root.CraftTreeLinkingNodes[parentTabId ?? RootNode];
parentTab.AddCraftingNode(techType);
}
else
Expand Down

0 comments on commit 0c0c45c

Please sign in to comment.