Upload from upload_mods.ps1
This commit is contained in:
143
Harmony/Harmony_XUiC_RecipeStack.cs
Normal file
143
Harmony/Harmony_XUiC_RecipeStack.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
namespace Harmony.XUiC_RecipeStackPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(TileEntityWorkstation))]
|
||||
[HarmonyPatch("HandleRecipeQueue")]
|
||||
public class UpdatePatch
|
||||
{
|
||||
public static MethodInfo cycleRecipeQueue = AccessTools.Method(typeof(TileEntityWorkstation), "cycleRecipeQueue", new Type[] { });
|
||||
public static MethodInfo hasRecipeInQueue = AccessTools.Method(typeof(TileEntityWorkstation), "hasRecipeInQueue", new Type[] { });
|
||||
|
||||
public static bool Prefix(TileEntityWorkstation __instance, float _timePassed,
|
||||
bool ___bUserAccessing,
|
||||
ref RecipeQueueItem[] ___queue,
|
||||
bool[] ___isModuleUsed,
|
||||
bool ___isBurning,
|
||||
ItemStack[] ___output
|
||||
)
|
||||
{
|
||||
if (___bUserAccessing)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (___queue.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (___isModuleUsed[3] && !___isBurning)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
RecipeQueueItem recipeQueueItem = ___queue[___queue.Length - 1];
|
||||
if (recipeQueueItem == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 1");
|
||||
|
||||
if (recipeQueueItem.CraftingTimeLeft >= 0f)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 2");
|
||||
recipeQueueItem.CraftingTimeLeft -= _timePassed;
|
||||
}
|
||||
while (recipeQueueItem.CraftingTimeLeft < 0f && (bool)hasRecipeInQueue.Invoke(__instance, new object[] { }))
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 3");
|
||||
if (recipeQueueItem.Multiplier > 0)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 4");
|
||||
ItemValue itemValue = new ItemValue(recipeQueueItem.Recipe.itemValueType, false);
|
||||
if (ItemClass.list[recipeQueueItem.Recipe.itemValueType] != null && ItemClass.list[recipeQueueItem.Recipe.itemValueType].HasQuality)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 5");
|
||||
itemValue = new ItemValue(recipeQueueItem.Recipe.itemValueType, (int)recipeQueueItem.Quality, (int)recipeQueueItem.Quality, false, null, 1f);
|
||||
}
|
||||
if (ItemStack.AddToItemStackArray(___output, new ItemStack(itemValue, recipeQueueItem.Recipe.count), -1) == -1)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 6");
|
||||
return false;
|
||||
}
|
||||
GameSparksCollector.IncrementCounter(GameSparksCollector.GSDataKey.CraftedItems, itemValue.ItemClass.Name, 1, true, GameSparksCollector.GSDataCollection.SessionUpdates);
|
||||
RecipeQueueItem recipeQueueItem2 = recipeQueueItem;
|
||||
recipeQueueItem2.Multiplier -= 1;
|
||||
recipeQueueItem.CraftingTimeLeft += recipeQueueItem.OneItemCraftTime;
|
||||
|
||||
// ADD OUTPUT ITEMS TO WORKSTATION
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 7");
|
||||
RebirthUtilities.AddOutputItems(recipeQueueItem.Recipe, ___output);
|
||||
}
|
||||
if (recipeQueueItem.Multiplier <= 0)
|
||||
{
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue 8");
|
||||
float craftingTimeLeft = recipeQueueItem.CraftingTimeLeft;
|
||||
cycleRecipeQueue.Invoke(__instance, new object[] { });
|
||||
|
||||
recipeQueueItem = ___queue[___queue.Length - 1];
|
||||
recipeQueueItem.CraftingTimeLeft += ((craftingTimeLeft < 0f) ? craftingTimeLeft : 0f);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RecipeStackPatches-HandleRecipeQueue END");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(XUiC_RecipeStack))]
|
||||
[HarmonyPatch("outputStack")]
|
||||
public class outputStackPatch
|
||||
{
|
||||
public static bool Prefix(XUiC_RecipeStack __instance, ref bool __result,
|
||||
Recipe ___recipe,
|
||||
ref ItemValue ___originalItem,
|
||||
ref ItemValue ___outputItemValue,
|
||||
int ___outputQuality,
|
||||
int ___startingEntityId,
|
||||
ref int ___amountToRepair,
|
||||
bool ___playSound,
|
||||
XUiWindowGroup ___windowGroup,
|
||||
int ___recipeCount,
|
||||
ref bool ___isCrafting,
|
||||
ref float ___craftingTimeLeft,
|
||||
float ___oneItemCraftTime,
|
||||
ref bool ___isInventoryFull,
|
||||
ref XUiController ___lockIcon,
|
||||
ref XUiController ___overlay,
|
||||
ref XUiController ___itemIcon,
|
||||
ref XUiController ___timer,
|
||||
ref XUiController ___count,
|
||||
ref XUiController ___cancel,
|
||||
bool ___isOver,
|
||||
XUiController ___background,
|
||||
float ___totalCraftTimeLeft
|
||||
)
|
||||
{
|
||||
__result = RebirthUtilities.outputStack(__instance,
|
||||
___recipe,
|
||||
ref ___originalItem,
|
||||
ref ___outputItemValue,
|
||||
___outputQuality,
|
||||
___startingEntityId,
|
||||
ref ___amountToRepair,
|
||||
___playSound,
|
||||
___windowGroup,
|
||||
___recipeCount,
|
||||
ref ___isCrafting,
|
||||
ref ___craftingTimeLeft,
|
||||
___oneItemCraftTime,
|
||||
ref ___isInventoryFull,
|
||||
ref ___lockIcon,
|
||||
ref ___overlay,
|
||||
ref ___itemIcon,
|
||||
ref ___timer,
|
||||
ref ___count,
|
||||
ref ___cancel,
|
||||
___isOver,
|
||||
___background,
|
||||
___totalCraftTimeLeft);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user