コード例 #1
0
        private static void OnReadyForHarvest(SObject Machine)
        {
            if (Context.IsMainPlayer)
            {
                try
                {
                    if (Machine.heldObject.Value != null && ModEntry.UserConfig.ShouldModifyInputsAndOutputs(Machine) &&
                        Machine.TryGetCombinedQuantity(out int CombinedQuantity) && !Machine.HasModifiedOutput())
                    {
                        int PreviousOutputStack = Machine.heldObject.Value.Stack;

                        double OutputEffect    = ModEntry.UserConfig.ComputeProcessingPower(CombinedQuantity);
                        double DesiredNewValue = PreviousOutputStack * OutputEffect;
                        int    NewOutputStack  = RNGHelpers.WeightedRound(DesiredNewValue);

                        Machine.heldObject.Value.Stack = NewOutputStack;
                        ModEntry.LogTrace(CombinedQuantity, Machine, Machine.TileLocation, "HeldObject.Stack", PreviousOutputStack, DesiredNewValue, NewOutputStack, OutputEffect);
                    }
                }
                finally { Machine.SetHasModifiedOutput(false); }
            }
        }