Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        internal static void ValidateBlueprint(ModBlueprint modBlueprint, string sourcePath)
        {
            try
            {
                ModComponentUtils.ModUtils.GetItem <GearItem>(modBlueprint.CraftedResult);

                if (!string.IsNullOrEmpty(modBlueprint.RequiredTool))
                {
                    ModComponentUtils.ModUtils.GetItem <ToolsItem>(modBlueprint.RequiredTool);
                }

                if (modBlueprint.OptionalTools != null)
                {
                    ModComponentUtils.ModUtils.GetMatchingItems <ToolsItem>(modBlueprint.OptionalTools);
                }

                ModComponentUtils.ModUtils.GetMatchingItems <GearItem>(modBlueprint.RequiredGear);
            }
            catch (Exception e)
            {
                if (string.IsNullOrEmpty(sourcePath))
                {
                    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.");
                }
                else
                {
                    throw new ArgumentException("Validation of blueprint " + modBlueprint.name + " failed: " + e.Message + "\nThe blueprint may be out-of-date or installed incorrectly.");
                }
            }
        }
Exemplo n.º 3
0
        private static void MapBlueprint(GameObject prefab, string sourcePath)
        {
            ModBlueprint modBlueprint = ModUtils.GetComponent <ModBlueprint>(prefab);

            if (modBlueprint != null)
            {
                Mapper.RegisterBlueprint(modBlueprint, sourcePath);
            }
        }
        private static void ProcessFile(string path)
        {
            string text = File.ReadAllText(path);

            try
            {
                ModBlueprint blueprint = FastJson.Deserialize <ModBlueprint>(text);
                Mapper.RegisterBlueprint(blueprint, path);
            }
            catch (Exception e)
            {
                throw new System.ArgumentException("Could not read blueprint from '" + path + "'.", e);
            }
        }
Exemplo n.º 5
0
        private static void ProcessText(string path, string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                PageManager.SetItemPackNotWorking(path, "Skipping because blueprint text contains no information");
                return;
            }

            try
            {
                ModBlueprint blueprint = MelonLoader.TinyJSON.JSON.Load(text).Make <ModBlueprint>();
                if (!(blueprint is null))
                {
                    BlueprintMapper.RegisterBlueprint(blueprint, path);
                }
                else
                {
                    PageManager.SetItemPackNotWorking(path, "Skipping because blueprint is null");
                }
            }
Exemplo n.º 6
0
        internal static void MapBlueprint(ModBlueprint modBlueprint)
        {
            BlueprintItem bpItem = GameManager.GetBlueprints().AddComponent <BlueprintItem>();

            if (bpItem is null)
            {
                throw new Exception("Error creating Blueprint");
            }

            bpItem.m_DurationMinutes = modBlueprint.DurationMinutes;
            bpItem.m_CraftingAudio   = modBlueprint.CraftingAudio;

            bpItem.m_RequiredCraftingLocation = ModComponentUtils.EnumUtils.TranslateEnumValue <CraftingLocation, ModComponentAPI.CraftingLocation>(modBlueprint.RequiredCraftingLocation);
            bpItem.m_RequiresLitFire          = modBlueprint.RequiresLitFire;
            bpItem.m_RequiresLight            = modBlueprint.RequiresLight;

            bpItem.m_Locked             = false;
            bpItem.m_AppearsInStoryOnly = false;

            bpItem.m_CraftedResultCount = modBlueprint.CraftedResultCount;
            bpItem.m_CraftedResult      = ModComponentUtils.ModUtils.GetItem <GearItem>(modBlueprint.CraftedResult);

            if (!string.IsNullOrEmpty(modBlueprint.RequiredTool))
            {
                bpItem.m_RequiredTool = ModComponentUtils.ModUtils.GetItem <ToolsItem>(modBlueprint.RequiredTool);
            }
            bpItem.m_OptionalTools = ModComponentUtils.ModUtils.NotNull(ModComponentUtils.ModUtils.GetMatchingItems <ToolsItem>(modBlueprint.OptionalTools));

            bpItem.m_RequiredGear           = ModComponentUtils.ModUtils.NotNull(ModComponentUtils.ModUtils.GetMatchingItems <GearItem>(modBlueprint.RequiredGear));
            bpItem.m_RequiredGearUnits      = modBlueprint.RequiredGearUnits;
            bpItem.m_KeroseneLitersRequired = modBlueprint.KeroseneLitersRequired;
            bpItem.m_GunpowderKGRequired    = modBlueprint.GunpowderKGRequired;

            bpItem.m_AppliedSkill  = ModComponentUtils.EnumUtils.TranslateEnumValue <SkillType, ModComponentAPI.SkillType>(modBlueprint.AppliedSkill);
            bpItem.m_ImprovedSkill = ModComponentUtils.EnumUtils.TranslateEnumValue <SkillType, ModComponentAPI.SkillType>(modBlueprint.ImprovedSkill);
        }
Exemplo n.º 7
0
        internal static void RegisterBlueprint(ModBlueprint modBlueprint, string sourcePath)
        {
            ValidateBlueprint(modBlueprint, sourcePath);

            blueprints.Add(modBlueprint);
        }