/// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { IllnessConfig = helper.ReadConfig <IllnessConfig>(); Dice = new Xoshiro.PRNG64.XoShiRo256starstar(); StaminaMngr = new StaminaDrain(IllnessConfig, Helper.Translation, Monitor); TicksOutside = TicksTotal = 0; helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle; helper.Events.GameLoop.DayStarted += OnDayStarted; helper.Events.GameLoop.UpdateTicked += OnUpdateTicked; helper.Events.GameLoop.TimeChanged += OnTimeChanged; helper.Events.GameLoop.GameLaunched += OnGameLaunched; SpaceEvents.TouchActionActivated += TouchActionActivated; SpaceEvents.OnItemEaten += OnItemEaten; Helper.ConsoleCommands.Add("debug_forceillness", "Force an illness.", ForceIllness); }
private static Dictionary <ISalable, int[]> generateLocalTravelingMerchantStock(int seed) { Random Dice = new Xoshiro.PRNG64.XoShiRo256starstar(); Dictionary <ISalable, int[]> stock1 = new Dictionary <ISalable, int[]>(); HashSet <int> stockIndices1 = new HashSet <int>(); int numStock = (CustomizableCartRedux.OurConfig.AmountOfItems <= 4 ? 5 : CustomizableCartRedux.OurConfig.AmountOfItems); int maxItemID = CustomizableCartRedux.OurConfig.UseVanillaMax ? 790 : Game1.objectInformation.Keys.Max(); var itemsToBeAdded = new List <int>(); bool add_guaranteed_item = false; if (Game1.netWorldState.Value.VisitsUntilY1Guarantee == 0) { add_guaranteed_item = true; } for (int index1 = 0; index1 < (numStock - 3); ++index1) { Dictionary <ISalable, int[]> stock2; HashSet <int> stockIndices2; StardewValley.Object objectToAdd; int[] listing; do { int index2 = GetItem(Dice, maxItemID); while (!CanSellItem(index2)) { index2 = GetItem(Dice, maxItemID); } while (itemsToBeAdded.Contains(index2) || !CanSellItem(index2)) { index2 = GetItem(Dice, maxItemID); } if (index2 == 266 || index2 == 485) { add_guaranteed_item = false; } var strArray = Game1.objectInformation[index2].Split('/'); stock2 = stock1; stockIndices2 = stockIndices1; objectToAdd = new StardewValley.Object(index2, 1, false, -1, 0); listing = new int[2] { (CustomizableCartRedux.OurConfig.UseCheaperPricing ? (int)Math.Max(Dice.Next(1, 6) * 81, Math.Round(Dice.RollInRange(1.87, 5.95) * Convert.ToInt32(strArray[1]))) : Math.Max(Dice.Next(1, 11) * 100, Convert.ToInt32(strArray[1]) * Dice.Next(3, 6))), Dice.NextDouble() < 0.1 ? 5 : 1 }; }while (!addToStock(stock2, stockIndices2, objectToAdd, listing)); if (add_guaranteed_item) { string[] split2 = Game1.objectInformation[485].Split('/'); addToStock(stock1, stockIndices1, new StardewValley.Object(485, 1), new int[2] { Math.Max(Dice.Next(1, 11) * 100, Convert.ToInt32(split2[1]) * Dice.Next(3, 6)), (!(Dice.NextDouble() < 0.1)) ? 1 : 5 }); } } addToStock(stock1, stockIndices1, getRandomFurniture(Dice, null, 0, 1613), new int[2] { CustomizableCartRedux.OurConfig.UseCheaperPricing ? (int)Math.Floor(Dice.RollInRange(.55, 8.52) * 250.0) : Dice.Next(1, 11) * 250, 1 }); if (Utility.getSeasonNumber(Game1.currentSeason) < 2) { addToStock(stock1, stockIndices1, new StardewValley.Object(347, 1, false, -1, 0), new int[2] { CustomizableCartRedux.OurConfig.UseCheaperPricing ? 800 : 1000, Dice.NextDouble() < 0.1 ? 5 : 1 }); } else if (Dice.NextDouble() < 0.4) { addToStock(stock1, stockIndices1, new StardewValley.Object(Vector2.Zero, 136, false), new int[2] { CustomizableCartRedux.OurConfig.UseCheaperPricing ? 3600 : 4000, 1 }); } if (Dice.NextDouble() < 0.25) { addToStock(stock1, stockIndices1, new StardewValley.Object(433, 1, false, -1, 0), new int[2] { CustomizableCartRedux.OurConfig.UseCheaperPricing ? 2200 : 2500, 1 }); } //add items from API call foreach (var v in CustomizableCartRedux.APIItemsToBeAdded) { addToStock(stock1, stockIndices1, v.Key, new int[2] { v.Value[0], v.Value[1] }); } stockIndices1.Clear(); //clear this. return(stock1); }