Rewrite for missing Utility.getRandomItemFromSeason method
This commit is contained in:
parent
4e2291a59e
commit
b254fa95fa
|
@ -1,5 +1,9 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Reflection;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Locations;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Framework.RewriteFacades
|
namespace StardewModdingAPI.Framework.RewriteFacades
|
||||||
{
|
{
|
||||||
|
@ -18,9 +22,65 @@ namespace StardewModdingAPI.Framework.RewriteFacades
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Windows.")]
|
[SuppressMessage("ReSharper", "CS0109", Justification = "The 'new' modifier applies when compiled on Windows.")]
|
||||||
public static new int getRandomItemFromSeason(string season, int randomSeedAddition, bool forQuest, bool changeDaily = true)
|
public static int getRandomItemFromSeason(string season, int randomSeedAddition, bool forQuest, bool changeDaily = true)
|
||||||
{
|
{
|
||||||
return getRandomItemFromSeason(season, randomSeedAddition, forQuest);
|
Random random = new Random((int)Game1.uniqueIDForThisGame + (changeDaily ? (int)Game1.stats.DaysPlayed : 0) + randomSeedAddition);
|
||||||
|
List<int> source = new List<int>() { 68, 66, 78, 80, 86, 152, 167, 153, 420 };
|
||||||
|
List<string> stringList1 = new List<string>(Game1.player.craftingRecipes.Keys);
|
||||||
|
List<string> stringList2 = new List<string>(Game1.player.cookingRecipes.Keys);
|
||||||
|
if (forQuest)
|
||||||
|
{
|
||||||
|
stringList1 = Utility.GetAllPlayerUnlockedCraftingRecipes();
|
||||||
|
stringList2 = Utility.GetAllPlayerUnlockedCookingRecipes();
|
||||||
|
}
|
||||||
|
if (forQuest && (MineShaft.lowestLevelReached > 40 || Utility.GetAllPlayerDeepestMineLevel() >= 1) || !forQuest && (Game1.player.deepestMineLevel > 40 || Game1.player.timesReachedMineBottom >= 1))
|
||||||
|
source.AddRange(new int[5] { 62, 70, 72, 84, 422 });
|
||||||
|
if (forQuest && (MineShaft.lowestLevelReached > 80 || Utility.GetAllPlayerDeepestMineLevel() >= 1) || !forQuest && (Game1.player.deepestMineLevel > 80 || Game1.player.timesReachedMineBottom >= 1))
|
||||||
|
source.AddRange(new int[3] { 64, 60, 82 });
|
||||||
|
if (Utility.doesAnyFarmerHaveMail("ccVault"))
|
||||||
|
source.AddRange(new int[4] { 88, 90, 164, 165 });
|
||||||
|
if (stringList1.Contains("Furnace"))
|
||||||
|
source.AddRange(new int[4] { 334, 335, 336, 338 });
|
||||||
|
if (stringList1.Contains("Quartz Globe"))
|
||||||
|
source.Add(339);
|
||||||
|
if (season.Equals("spring"))
|
||||||
|
source.AddRange(new int[17] { 0x10, 0x12, 20, 0x16, 0x81, 0x83, 0x84, 0x88, 0x89, 0x8e, 0x8f, 0x91, 0x93, 0x94, 0x98, 0xa7, 0x10b });
|
||||||
|
else if (season.Equals("summer"))
|
||||||
|
source.AddRange(new int[] { 0x80, 130, 0x84, 0x88, 0x8a, 0x8e, 0x90, 0x91, 0x92, 0x95, 150, 0x9b, 0x18c, 0x18e, 0x192, 0x10b });
|
||||||
|
else if (season.Equals("fall"))
|
||||||
|
source.AddRange(new int[] { 0x194, 0x196, 0x198, 410, 0x81, 0x83, 0x84, 0x88, 0x89, 0x8b, 140, 0x8e, 0x8f, 0x94, 150, 0x9a, 0x9b, 0x10d });
|
||||||
|
else if (season.Equals("winter"))
|
||||||
|
source.AddRange(new int[] { 0x19c, 0x19e, 0x1a0, 0x1a2, 130, 0x83, 0x84, 0x88, 140, 0x8d, 0x90, 0x92, 0x93, 150, 0x97, 0x9a, 0x10d });
|
||||||
|
if (forQuest)
|
||||||
|
{
|
||||||
|
foreach (string key in stringList2)
|
||||||
|
{
|
||||||
|
if (random.NextDouble() >= 0.4)
|
||||||
|
{
|
||||||
|
List<int> intList = Utility.possibleCropsAtThisTime(Game1.currentSeason, Game1.dayOfMonth <= 7);
|
||||||
|
Dictionary<string, string> dictionary = Game1.content.Load<Dictionary<string, string>>("Data//CookingRecipes");
|
||||||
|
if (dictionary.ContainsKey(key))
|
||||||
|
{
|
||||||
|
string[] strArray = dictionary[key].Split('/')[0].Split(' ');
|
||||||
|
bool flag = true;
|
||||||
|
for (int index = 0; index < strArray.Length; ++index)
|
||||||
|
{
|
||||||
|
MethodInfo isCategoryIngredientAvailable = typeof(Utility).GetMethod("isCategoryIngredientAvailable", BindingFlags.NonPublic | BindingFlags.Static);
|
||||||
|
if (!source.Contains(Convert.ToInt32(strArray[index]))
|
||||||
|
&& !(bool)isCategoryIngredientAvailable.Invoke(null, new object[] { Convert.ToInt32(strArray[index]) })
|
||||||
|
&& (intList == null || !intList.Contains(Convert.ToInt32(strArray[index]))))
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag)
|
||||||
|
source.Add(Convert.ToInt32(dictionary[key].Split('/')[2]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source[random.Next(source.Count)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,10 @@
|
||||||
<HintPath>..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\0Harmony.dll</HintPath>
|
<HintPath>..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Google.Android.Vending.Expansion.Downloader">
|
<Reference Include="Google.Android.Vending.Expansion.Downloader">
|
||||||
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.130\assemblies\Google.Android.Vending.Expansion.Downloader.dll</HintPath>
|
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.131\assemblies\Google.Android.Vending.Expansion.Downloader.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Google.Android.Vending.Licensing">
|
<Reference Include="Google.Android.Vending.Licensing">
|
||||||
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.130\assemblies\Google.Android.Vending.Licensing.dll</HintPath>
|
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.131\assemblies\Google.Android.Vending.Licensing.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="Mono.Android" />
|
<Reference Include="Mono.Android" />
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
<HintPath>..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\Mono.Cecil.dll</HintPath>
|
<HintPath>..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\Mono.Cecil.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MonoGame.Framework">
|
<Reference Include="MonoGame.Framework">
|
||||||
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.130\assemblies\MonoGame.Framework.dll</HintPath>
|
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.131\assemblies\MonoGame.Framework.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MonoMod.RuntimeDetour">
|
<Reference Include="MonoMod.RuntimeDetour">
|
||||||
<HintPath>..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\MonoMod.RuntimeDetour.dll</HintPath>
|
<HintPath>..\..\..\..\..\AndroidStudioProjects\SMAPI Android Installer\app\src\main\assets\Stardew\MonoMod.RuntimeDetour.dll</HintPath>
|
||||||
|
@ -68,10 +68,10 @@
|
||||||
<HintPath>..\SMAPI.Toolkit\bin\Debug\net4.5\SMAPI.Toolkit.dll</HintPath>
|
<HintPath>..\SMAPI.Toolkit\bin\Debug\net4.5\SMAPI.Toolkit.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="StardewValley">
|
<Reference Include="StardewValley">
|
||||||
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.130\assemblies\StardewValley.dll</HintPath>
|
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.131\assemblies\StardewValley.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="StardewValley.GameData">
|
<Reference Include="StardewValley.GameData">
|
||||||
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.130\assemblies\StardewValley.GameData.dll</HintPath>
|
<HintPath>..\..\..\..\..\Downloads\StardewValleyAndroidStuff\base_1.4.4.131\assemblies\StardewValley.GameData.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -181,7 +181,6 @@
|
||||||
<Compile Include="Framework\GameVersion.cs" />
|
<Compile Include="Framework\GameVersion.cs" />
|
||||||
<Compile Include="Framework\IModMetadata.cs" />
|
<Compile Include="Framework\IModMetadata.cs" />
|
||||||
<Compile Include="Framework\Input\GamePadStateBuilder.cs" />
|
<Compile Include="Framework\Input\GamePadStateBuilder.cs" />
|
||||||
<Compile Include="Framework\Input\InputStatus.cs" />
|
|
||||||
<Compile Include="Framework\Input\SInputState.cs" />
|
<Compile Include="Framework\Input\SInputState.cs" />
|
||||||
<Compile Include="Framework\InternalExtensions.cs" />
|
<Compile Include="Framework\InternalExtensions.cs" />
|
||||||
<Compile Include="Framework\Logging\ConsoleInterceptionManager.cs" />
|
<Compile Include="Framework\Logging\ConsoleInterceptionManager.cs" />
|
||||||
|
@ -338,6 +337,7 @@
|
||||||
<Compile Include="IMultiplayerHelper.cs" />
|
<Compile Include="IMultiplayerHelper.cs" />
|
||||||
<Compile Include="IMultiplayerPeer.cs" />
|
<Compile Include="IMultiplayerPeer.cs" />
|
||||||
<Compile Include="IMultiplayerPeerMod.cs" />
|
<Compile Include="IMultiplayerPeerMod.cs" />
|
||||||
|
<Compile Include="InputStatus.cs" />
|
||||||
<Compile Include="IReflectedField.cs" />
|
<Compile Include="IReflectedField.cs" />
|
||||||
<Compile Include="IReflectedMethod.cs" />
|
<Compile Include="IReflectedMethod.cs" />
|
||||||
<Compile Include="IReflectedProperty.cs" />
|
<Compile Include="IReflectedProperty.cs" />
|
||||||
|
|
Loading…
Reference in New Issue