Beispiel #1
0
 // Configures a given machine with a given configuration.
 // Be sure to check that the second parameter is a machine before passing it to this function.
 private void configureMachine(MachineConfig cfg, StardewValley.Object obj)
 {
     if (obj.MinutesUntilReady > 0 && obj.MinutesUntilReady % 10 == 0)
     {
         obj.MinutesUntilReady = cfg.Minutes;
     }
     if (obj is Cask)
     {
         ((Cask)obj).daysToMature.Value = cfg.Minutes / 1440;
     }
 }
        // Configures a given machine with a given configuration.
        // Be sure to check that the second parameter is a machine before passing it to this function.
        private void configureMachine(MachineConfig cfg, StardewValley.Object obj)
        {
            // If machine hasn't been configured yet.
            if (obj is Cask c && obj.heldObject.Value != null)
            {
                float agingRate = 1f;
                switch (c.heldObject.Value.ParentSheetIndex)
                {
                case 426:
                    agingRate = 4f;
                    break;

                case 424:
                    agingRate = 4f;
                    break;

                case 459:
                    agingRate = 2f;
                    break;

                case 303:
                    agingRate = 1.66f;
                    break;

                case 346:
                    agingRate = 2f;
                    break;
                }
                // Configure casks
                if (cfg.UsePercent && Math.Abs(cfg.Time - 100f) > EPSILON && (int)Math.Round(c.agingRate.Value * 1000) % 10 != 1)
                {
                    // By percentage
                    c.agingRate.Value  = agingRate * 100 / cfg.Time;
                    c.agingRate.Value  = (float)Math.Round(c.agingRate.Value, 2);
                    c.agingRate.Value += 0.001f;
                }
                else if (!cfg.UsePercent && (int)Math.Round(c.agingRate.Value * 1000) % 10 != 1)
                {
                    // By minutes
                    c.agingRate.Value  = (c.daysToMature.Value / agingRate * 1440) / cfg.Time;
                    c.agingRate.Value  = (float)Math.Round(c.agingRate.Value, 2);
                    c.agingRate.Value += 0.001f;
                }
            }