Esempio n. 1
0
        internal static bool PerformObjectDropInAction(Object __instance, Item dropInItem, bool probe, Farmer who, ref bool __result)
        {
            if (__instance.isTemporarilyInvisible || !(dropInItem is Object))
            {
                return(false);
            }
            Object input = (Object)dropInItem;

            if (ProducerController.GetProducerItem(__instance.name, input) is ProducerRule producerRule)
            {
                if (__instance.heldObject.Value != null && !__instance.name.Equals("Crystalarium") || (bool)((NetFieldBase <bool, NetBool>)input.bigCraftable))
                {
                    return(true);
                }
                if (ProducerRuleController.IsInputExcluded(producerRule, input))
                {
                    return(true);
                }

                if ((bool)((NetFieldBase <bool, NetBool>)__instance.bigCraftable) && !probe && (__instance.heldObject.Value == null))
                {
                    __instance.scale.X = 5f;
                }

                bool shouldDisplayMessages = !probe && who.IsLocalPlayer;

                if (ProducerRuleController.IsInputStackLessThanRequired(producerRule, input, shouldDisplayMessages))
                {
                    return(false);
                }

                if (ProducerRuleController.IsAnyFuelStackLessThanRequired(producerRule, who, shouldDisplayMessages))
                {
                    return(false);
                }

                Vector2      tileLocation = __instance.tileLocation.Value;
                Random       random       = ProducerRuleController.GetRandomForProducing(tileLocation);
                OutputConfig outputConfig = OutputConfigController.ChooseOutput(producerRule.OutputConfigs, random);

                Object output = OutputConfigController.CreateOutput(outputConfig, input, random);

                __instance.heldObject.Value = output;

                if (!probe)
                {
                    OutputConfigController.LoadOutputName(outputConfig, __instance.heldObject.Value, input, who);

                    GameLocation currentLocation = who.currentLocation;
                    PlaySound(producerRule.Sounds, currentLocation);
                    PlayDelayedSound(producerRule.DelayedSounds, currentLocation);

                    __instance.minutesUntilReady.Value = producerRule.MinutesUntilReady;

                    if (ProducerController.GetProducerConfig(__instance.Name) is ProducerConfig producerConfig)
                    {
                        __instance.showNextIndex.Value = producerConfig.AlternateFrameProducing;
                    }

                    if (producerRule.PlacingAnimation.HasValue)
                    {
                        AnimationController.DisplayAnimation(producerRule.PlacingAnimation.Value, producerRule.PlacingAnimationColor, currentLocation, tileLocation, new Vector2(producerRule.PlacingAnimationOffsetX, producerRule.PlacingAnimationOffsetY));
                    }

                    __instance.initializeLightSource(tileLocation, false);

                    foreach (var fuel in producerRule.FuelList)
                    {
                        RemoveItemsFromInventory(who, fuel.Item1, fuel.Item2);
                    }

                    producerRule.IncrementStatsOnInput.ForEach(s => StatsController.IncrementStardewStats(s, producerRule.InputStack));

                    input.Stack -= producerRule.InputStack;
                    __result     = input.Stack <= 0;
                }
                else
                {
                    __result = true;
                }
                return(false);
            }

            return(true);
        }