示例#1
0
        private static void ConfigureRepairable(ModComponent modComponent)
        {
            ModRepairableComponent modRepairableComponent = modComponent.GetComponent <ModRepairableComponent>();

            if (modRepairableComponent == null)
            {
                return;
            }

            Repairable repairable = ModUtils.GetOrCreateComponent <Repairable>(modRepairableComponent);

            repairable.m_RepairAudio       = modRepairableComponent.Audio;
            repairable.m_DurationMinutes   = modRepairableComponent.Minutes;
            repairable.m_ConditionIncrease = modRepairableComponent.Condition;

            if (modRepairableComponent.MaterialNames.Length != modRepairableComponent.MaterialCounts.Length)
            {
                throw new ArgumentException("MaterialNames and MaterialCounts do not have the same length on gear item '" + modRepairableComponent.name + "'.");
            }

            repairable.m_RequiredGear      = ModUtils.GetItems <GearItem>(modRepairableComponent.MaterialNames, modRepairableComponent.name);
            repairable.m_RequiredGearUnits = modRepairableComponent.MaterialCounts;

            repairable.m_RepairToolChoices    = ModUtils.GetItems <ToolsItem>(modRepairableComponent.RequiredTools, modRepairableComponent.name);
            repairable.m_RequiresToolToRepair = repairable.m_RepairToolChoices.Length > 0;
        }
示例#2
0
        private static void ConfigureHarvestable(ModComponent modComponent)
        {
            ModHarvestableComponent modHarvestableComponent = ModUtils.GetComponent <ModHarvestableComponent>(modComponent);

            if (modHarvestableComponent == null)
            {
                return;
            }

            Harvest harvest = ModUtils.GetOrCreateComponent <Harvest>(modHarvestableComponent);

            harvest.m_Audio           = modHarvestableComponent.Audio;
            harvest.m_DurationMinutes = modHarvestableComponent.Minutes;

            if (modHarvestableComponent.YieldNames.Length != modHarvestableComponent.YieldCounts.Length)
            {
                throw new ArgumentException("YieldNames and YieldCounts do not have the same length on gear item '" + modHarvestableComponent.name + "'.");
            }

            harvest.m_YieldGear      = ModUtils.GetItems <GearItem>(modHarvestableComponent.YieldNames, modHarvestableComponent.name);
            harvest.m_YieldGearUnits = modHarvestableComponent.YieldCounts;
        }