Exemplo n.º 1
0
        /// <summary>
        /// Defines all mass production machines.
        /// </summary>
        /// <param name="settings">Specifies the kinds of machines being set up.</param>
        /// <returns>All mass production machine definitions.</returns>
        public static List <MassProductionMachineDefinition> Setup(Dictionary <string, MPMSettings> settings)
        {
            List <MassProductionMachineDefinition> mpms = new List <MassProductionMachineDefinition>();

            //PFM integration
            List <ProducerRule> allProducerRules = ProducerController.GetProducerRules();
            List <string>       baseProducers    = new List <string>();

            foreach (ProducerRule rule in allProducerRules)
            {
                if (ProducerController.GetProducerConfig(rule.ProducerName) != null && !baseProducers.Contains(rule.ProducerName))
                {
                    baseProducers.Add(rule.ProducerName);
                }
            }

            foreach (string baseProducerName in baseProducers)
            {
                ProducerConfig config = ProducerController.GetProducerConfig(baseProducerName);

                foreach (MPMSettings setting in settings.Values)
                {
                    if (config == null ||
                        (config.NoInputStartMode.HasValue && setting.InputRequirementEnum == InputRequirement.InputRequired) ||
                        (!config.NoInputStartMode.HasValue && setting.InputRequirementEnum == InputRequirement.NoInputsOnly))
                    {
                        continue;
                    }

                    mpms.Add(new MassProductionMachineDefinition(baseProducerName, setting));
                }
            }

            //Other vanilla machines
            foreach (string vanillaMachineName in StaticValues.SUPPORTED_VANILLA_MACHINES.Keys)
            {
                if (!baseProducers.Contains(vanillaMachineName))
                {
                    InputRequirement inputRequirement = StaticValues.SUPPORTED_VANILLA_MACHINES[vanillaMachineName];

                    foreach (MPMSettings setting in settings.Values)
                    {
                        if (setting.InputRequirementEnum == inputRequirement || setting.InputRequirementEnum == InputRequirement.NoRequirements)
                        {
                            mpms.Add(new MassProductionMachineDefinition(vanillaMachineName, setting));
                        }
                    }
                }
            }

            return(mpms);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adapted from https://github.com/Digus/StardewValleyMods/blob/master/ProducerFrameworkMod/ProducerRuleController.cs
        /// </summary>
        /// <param name="producer"></param>
        /// <param name="location"></param>
        /// <param name="who"></param>
        public static void PrepareOutput(SObject producer, GameLocation location, Farmer who)
        {
            if (string.IsNullOrEmpty(producer.GetMassProducerKey()))
            {
                return;
            }

            MassProductionMachineDefinition mpm = ModEntry.GetMPMMachine(producer.name, producer.GetMassProducerKey());

            if (mpm == null)
            {
                return;
            }

            foreach (ProducerRule producerRule in ProducerController.GetProducerRules(mpm.BaseProducerName))
            {
                if (producerRule.LookForInputWhenReady is InputSearchConfig inputSearchConfig)
                {
                    if (producerRule.OutputConfigs.Find(o => o.OutputIndex == producer.heldObject.Value.ParentSheetIndex) is OutputConfig outputConfig)
                    {
                        SObject          input     = SearchInput(location, producer.tileLocation, inputSearchConfig);
                        List <InputInfo> inputInfo = InputInfo.ConvertPFMInputs(producerRule, input);
                        SObject          output    = OutputConfigController.CreateOutput(outputConfig, input, ProducerRuleController.GetRandomForProducing(producer.tileLocation));

                        output.Stack = mpm.Settings.CalculateOutputProduced(output.stack, inputInfo.ToArray());

                        if (mpm.Settings.Quality.HasValue)
                        {
                            if (mpm.Settings.Quality == QualitySetting.KeepInput)
                            {
                                output.Quality = input.Quality;
                            }
                            else
                            {
                                output.Quality = mpm.Settings.GetOutputQuality();
                            }
                        }

                        producer.heldObject.Value = output;
                        OutputConfigController.LoadOutputName(outputConfig, producer.heldObject.Value, input, who);
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public List <Dictionary <string, object> > GetRecipes(string producerName)
        {
            List <ProducerRule> producerRules = ProducerController.GetProducerRules(producerName);

            return(GetRecipes(producerRules));
        }
Exemplo n.º 4
0
 public List <ProducerRule> GetProducerRules(string producerName)
 {
     return(ProducerController.GetProducerRules(producerName));
 }