public static void ResumeUICrafting(XUiC_WorkstationWindowGroup workstationWindowGroup) { }
public static bool IsHydroponicFarmPowered(TileEntityWorkstation tew) { Vector3i powerBlockPos = tew.ToWorldPos(); powerBlockPos.y -= 1; BlockValue powerBlockValue = GameManager.Instance.World.GetBlock(powerBlockPos); Block powerBlock = Block.list[powerBlockValue.type]; bool isPowered = false; if (powerBlock.GetBlockName() == "hydroponicFarmPower") { // Is Power block powered Chunk chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(powerBlockPos); isPowered = BlockHydroponicFarmPower.IsBlockPoweredUp(powerBlockPos, chunk.ClrIdx); // Halt crafting UI EntityPlayerLocal player = GameManager.Instance.World.GetPrimaryPlayer(); LocalPlayerUI playerUI = player.PlayerUI; BlockValue block = GameManager.Instance.World.GetBlock(tew.ToWorldPos()); string text = string.Format("workstation_{0}", Block.list[block.type].GetBlockName()); if (playerUI.windowManager.Contains(text)) { XUiC_WorkstationWindowGroup workstationWindowGroup = ((XUiC_WorkstationWindowGroup)((XUiWindowGroup)playerUI.windowManager.GetWindow(text)).Controller); if (workstationWindowGroup.WorkstationData != null && workstationWindowGroup.WorkstationData.TileEntity == tew) { // The name of the XUiC_CraftingQueue field of XUiC_WorkstationWindowGroup is obfuscated so we find it by type to call it. XUiC_CraftingQueue craftingQueue = null; var listOfFieldNames = typeof(XUiC_WorkstationWindowGroup).GetFields(); foreach (FieldInfo fieldInfo in listOfFieldNames) { FieldInfo field = null; if (fieldInfo.FieldType == typeof(XUiC_CraftingQueue)) { field = fieldInfo; } if (field != null) { craftingQueue = (XUiC_CraftingQueue)field.GetValue(workstationWindowGroup); } } if (craftingQueue != null) { if (!isPowered) { //workstationWindowGroup.FNW.HaltCrafting(); craftingQueue.HaltCrafting(); } else { //workstationWindowGroup.FNW.ResumeCrafting(); craftingQueue.ResumeCrafting(); } } } } TileEntityWorkstationPatchFunctions.ChangePlantIfNeeded(tew); return(isPowered); } return(true); }
public static void HaltUICrafting(XUiC_WorkstationWindowGroup workstationWindowGroup) { }