Skip to content

Commit

Permalink
Fixed log spams for buildables
Browse files Browse the repository at this point in the history
Since buildables are never registered to a crafting tree, Nautilus always logs a warning for that interpreting it as a mistake, when in reality it isn't.
  • Loading branch information
Metious committed Oct 16, 2023
1 parent 35d7ead commit 16b83ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 7 additions & 5 deletions Nautilus/Assets/Gadgets/CraftingGadget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ protected internal override void Build()

CraftDataHandler.SetRecipeData(prefab.Info.TechType, RecipeData);

if (FabricatorType == CraftTree.Type.None)
{
InternalLogger.Log($"Prefab '{prefab.Info.ClassID}' was not automatically registered into a crafting tree.");
}
else

if (FabricatorType is not CraftTree.Type.None)
{
if (StepsToFabricatorTab == null || StepsToFabricatorTab.Length == 0)
{
Expand All @@ -103,6 +100,11 @@ protected internal override void Build()
{
CraftTreeHandler.AddCraftingNode(FabricatorType, prefab.Info.TechType, StepsToFabricatorTab);
}

}
else if (!prefab.TryGetGadget(out ScanningGadget scanningGadget) || !scanningGadget.IsBuildable)
{
InternalLogger.Log($"Prefab '{prefab.Info.ClassID}' was not automatically registered into a crafting tree.");
}

if (CraftingTime >= 0f)
Expand Down
9 changes: 6 additions & 3 deletions Nautilus/Assets/Gadgets/ScanningGadget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ namespace Nautilus.Assets.Gadgets;
/// </summary>
public class ScanningGadget : Gadget
{
private bool _isBuildable;
/// <summary>
/// Classifies this item as buildable via the habitat builder.
/// </summary>
public bool IsBuildable { get; set; }

/// <summary>
/// The blueprint that must first be scanned or picked up to unlocked this item.
Expand Down Expand Up @@ -184,7 +187,7 @@ public ScanningGadget WithPdaGroupCategoryBefore(TechGroup group, TechCategory c
/// <returns>A reference to this instance after the operation has completed.</returns>
public ScanningGadget SetBuildable(bool isBuildable = true)
{
_isBuildable = isBuildable;
IsBuildable = isBuildable;
return this;
}

Expand Down Expand Up @@ -320,7 +323,7 @@ protected internal override void Build()
InternalLogger.Error($"Failed to add {prefab.Info.TechType.AsString()} to {GroupForPda}/{CategoryForPda} as it is not a registered combination.");
}

if (_isBuildable)
if (IsBuildable)
CraftDataHandler.AddBuildable(prefab.Info.TechType);
}

Expand Down

0 comments on commit 16b83ac

Please sign in to comment.