Files
7d2dXG/Mods/zzz_REBIRTH__Utils/Harmony/Harmony_XUiC_WorkstationFuelGrid.cs
Nathaniel Cosford 062dfab2cd Patched
2025-05-30 01:04:40 +09:30

100 lines
3.3 KiB
C#

using Audio;
namespace Harmony.XUiC_WorkstationFuelGridPatches
{
/*[HarmonyPatch(typeof(XUiC_WorkstationFuelGrid))]
[HarmonyPatch("AddItem")]
[HarmonyPatch(new[] { typeof(ItemClass), typeof(ItemStack) })]
public class AddItemPatch
{
public static bool Prefix(XUiC_WorkstationFuelGrid __instance, ref bool __result, ItemClass _itemClass, ItemStack _itemStack)
{
Log.Out("XUiC_WorkstationFuelGridPatches-AddItem START");
string value = "";
Log.Out("XUiC_WorkstationFuelGridPatches-AddItem START");
if (__instance.GetBindingValue(ref value, "required_fuels"))
{
Log.Out("XUiC_WorkstationFuelGridPatches-AddItem value: " + value);
}
return true;
}
}*/
[HarmonyPatch(typeof(XUiC_WorkstationFuelGrid))]
[HarmonyPatch("TurnOn")]
public class TurnOnPatch
{
public static bool Prefix(XUiC_WorkstationFuelGrid __instance)
{
//Log.Out("XUiC_WorkstationFuelGridPatches-TurnOn START");
bool skipSound = false;
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
{
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values["HasAnim"] == "skipBurningSound")
{
skipSound = true;
}
}
if (!__instance.isOn && !skipSound)
{
Manager.PlayInsidePlayerHead("forge_burn_fuel", -1, 0f, false);
}
__instance.isOn = true;
__instance.WorkstationData.SetIsBurning(__instance.isOn);
((XUiV_Label)__instance.onOffLabel.ViewComponent).Text = __instance.turnOff;
if (__instance.flameIcon != null)
{
((XUiV_Sprite)__instance.flameIcon.ViewComponent).Color = __instance.flameOnColor;
}
return false;
}
}
[HarmonyPatch(typeof(XUiC_WorkstationFuelGrid))]
[HarmonyPatch("TurnOff")]
public class TurnOffPatch
{
public static bool Prefix(XUiC_WorkstationFuelGrid __instance)
{
//Log.Out("XUiC_WorkstationFuelGridPatches-TurnOff START");
bool skipSound = false;
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values.ContainsKey("HasAnim"))
{
if (__instance.WorkstationData.TileEntity.blockValue.Block.Properties.Values["HasAnim"] == "skipBurningSound")
{
skipSound = true;
}
}
if (__instance.isOn && !skipSound)
{
Manager.PlayInsidePlayerHead("forge_fire_die", -1, 0f, false);
}
__instance.isOn = false;
__instance.WorkstationData.SetIsBurning(__instance.isOn);
((XUiV_Label)__instance.onOffLabel.ViewComponent).Text = __instance.turnOn;
XUiC_ItemStack xuiC_ItemStack = (XUiC_ItemStack)__instance.itemControllers[0];
if (xuiC_ItemStack != null)
{
xuiC_ItemStack.UnlockStack();
}
if (__instance.flameIcon != null)
{
((XUiV_Sprite)__instance.flameIcon.ViewComponent).Color = __instance.flameOffColor;
}
return false;
}
}
}