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; }
private static void ConfigureCookingPot(ModComponent modComponent) { ModCookingPotComponent modCookingPotComponent = modComponent as ModCookingPotComponent; if (modCookingPotComponent == null) { return; } CookingPotItem cookingPotItem = ModUtils.GetOrCreateComponent <CookingPotItem>(modComponent); cookingPotItem.m_WaterCapacityLiters = modCookingPotComponent.Capacity; cookingPotItem.m_CanCookGrub = modCookingPotComponent.CanCookGrub; cookingPotItem.m_CanCookLiquid = modCookingPotComponent.CanCookLiquid; cookingPotItem.m_CanCookMeat = modCookingPotComponent.CanCookMeat; cookingPotItem.m_CanOnlyWarmUpFood = false; CookingPotItem template = ModUtils.GetItem <CookingPotItem>(modCookingPotComponent.Template, modComponent.name); cookingPotItem.m_BoilingTimeMultiplier = template.m_BoilingTimeMultiplier; cookingPotItem.m_BoilWaterPotMaterialsList = template.m_BoilWaterPotMaterialsList; cookingPotItem.m_BoilWaterReadyMaterialsList = template.m_BoilWaterReadyMaterialsList; cookingPotItem.m_ConditionPercentDamageFromBoilingDry = template.m_ConditionPercentDamageFromBoilingDry; cookingPotItem.m_ConditionPercentDamageFromBurningFood = template.m_ConditionPercentDamageFromBurningFood; cookingPotItem.m_CookedCalorieMultiplier = template.m_CookedCalorieMultiplier; cookingPotItem.m_CookingTimeMultiplier = template.m_CookingTimeMultiplier; cookingPotItem.m_GrubMeshType = template.m_GrubMeshType; cookingPotItem.m_LampOilMultiplier = template.m_LampOilMultiplier; cookingPotItem.m_MeltSnowMaterialsList = template.m_MeltSnowMaterialsList; cookingPotItem.m_NearFireWarmUpCookingTimeMultiplier = template.m_NearFireWarmUpCookingTimeMultiplier; cookingPotItem.m_NearFireWarmUpReadyTimeMultiplier = template.m_NearFireWarmUpReadyTimeMultiplier; cookingPotItem.m_ParticlesItemCooking = template.m_ParticlesItemCooking; cookingPotItem.m_ParticlesItemReady = template.m_ParticlesItemReady; cookingPotItem.m_ParticlesItemRuined = template.m_ParticlesItemRuined; cookingPotItem.m_ParticlesSnowMelting = template.m_ParticlesSnowMelting; cookingPotItem.m_ParticlesWaterBoiling = template.m_ParticlesWaterBoiling; cookingPotItem.m_ParticlesWaterReady = template.m_ParticlesWaterReady; cookingPotItem.m_ParticlesWaterRuined = template.m_ParticlesWaterRuined; cookingPotItem.m_ReadyTimeMultiplier = template.m_ReadyTimeMultiplier; cookingPotItem.m_RuinedFoodMaterialsList = template.m_RuinedFoodMaterialsList; cookingPotItem.m_SnowMesh = modCookingPotComponent.SnowMesh; cookingPotItem.m_WaterMesh = modCookingPotComponent.WaterMesh; GameObject grubMesh = UnityEngine.Object.Instantiate(template.m_GrubMeshFilter.gameObject, cookingPotItem.transform); cookingPotItem.m_GrubMeshFilter = grubMesh.GetComponent <MeshFilter>(); cookingPotItem.m_GrubMeshRenderer = grubMesh.GetComponent <MeshRenderer>(); PlaceableItem placeableItem = ModUtils.GetOrCreateComponent <PlaceableItem>(modComponent); placeableItem.m_Range = template.GetComponent <PlaceableItem>()?.m_Range ?? 3; }
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."); } }