internal static void MapBlueprint(ModBlueprint modBlueprint) { BlueprintItem bpItem = GameManager.GetBlueprints().AddComponent <BlueprintItem>(); if (bpItem == null) { throw new Exception("Error creating Blueprint"); } bpItem.m_DurationMinutes = modBlueprint.DurationMinutes; bpItem.m_CraftingAudio = modBlueprint.CraftingAudio; bpItem.m_RequiresForge = modBlueprint.RequiresForge; bpItem.m_RequiresWorkbench = modBlueprint.RequiresWorkbench; bpItem.m_RequiresLight = modBlueprint.RequiresLight; bpItem.m_Locked = modBlueprint.Locked; bpItem.m_CraftedResultCount = modBlueprint.CraftedResultCount; bpItem.m_CraftedResult = ModUtils.GetItem <GearItem>(modBlueprint.CraftedResult); if (!string.IsNullOrEmpty(modBlueprint.RequiredTool)) { bpItem.m_RequiredTool = ModUtils.GetItem <ToolsItem>(modBlueprint.RequiredTool); } bpItem.m_OptionalTools = ModUtils.NotNull(ModUtils.GetMatchingItems <ToolsItem>(modBlueprint.OptionalTools)); bpItem.m_RequiredGear = ModUtils.NotNull(ModUtils.GetMatchingItems <GearItem>(modBlueprint.RequiredGear)); bpItem.m_RequiredGearUnits = modBlueprint.RequiredGearUnits; }
internal static void ValidateBlueprint(ModBlueprint modBlueprint, string sourcePath) { try { ModUtils.GetItem <GearItem>(modBlueprint.CraftedResult); if (!string.IsNullOrEmpty(modBlueprint.RequiredTool)) { ModUtils.GetItem <ToolsItem>(modBlueprint.RequiredTool); } if (modBlueprint.OptionalTools != null) { ModUtils.GetMatchingItems <ToolsItem>(modBlueprint.OptionalTools); } ModUtils.GetMatchingItems <GearItem>(modBlueprint.RequiredGear); } catch (Exception e) { throw new ArgumentException("Validation of blueprint " + modBlueprint.name + " failed: " + e.Message + "\nThe blueprint was provided by '" + sourcePath + "', which may be out-of-date or installed incorrectly."); } }