From 70518a1d38561a817c943566668536d1dcde6567 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 8 Oct 2019 11:44:43 -0700 Subject: [PATCH] Updated machine summary menu to hide fluid tanks with no relevance to that machine. --- .../Framework/Managers/FluidManagerV2.cs | 49 +++++++++++++++++-- .../Menus/Machines/MachineSummaryMenu.cs | 34 ++++++++++++- .../Framework/Objects/ObjectManager.cs | 20 ++++---- 3 files changed, 86 insertions(+), 17 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs index 47b587f5..d0908e37 100644 --- a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs +++ b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs @@ -271,6 +271,9 @@ namespace Revitalize.Framework.Managers public bool allowDoubleInput; public bool onlyOutput; + + private bool onlyInput; + private int numberOfInputTanks; /// /// The capacity for the fluid tanks. /// @@ -301,7 +304,7 @@ namespace Revitalize.Framework.Managers /// /// /// Can both input tanks store the same Fluid? - public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput = false) + public FluidManagerV2(int Capacity, bool OnlyOutput, Enums.FluidInteractionType LiquidInteractionType, bool AllowDoubleInput = false,bool OnlyInput=false, int NumberOfInputTanks=2) { if (OnlyOutput) { @@ -310,18 +313,49 @@ namespace Revitalize.Framework.Managers this.inputTank2 = new MachineFluidTank(0); } + else if (OnlyInput) + { + if (this.allowDoubleInput) + { + this.outputTank = new MachineFluidTank(0); + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(Capacity); + } + if (NumberOfInputTanks >= 2) + { + this.outputTank = new MachineFluidTank(0); + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(Capacity); + } + else if (NumberOfInputTanks == 1) + { + this.outputTank = new MachineFluidTank(0); + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(0); + } + } else { this.outputTank = new MachineFluidTank(Capacity); - this.inputTank1 = new MachineFluidTank(Capacity); - this.inputTank2 = new MachineFluidTank(Capacity); + if (NumberOfInputTanks == 1) + { + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(0); + } + else if(NumberOfInputTanks >=2) + { + this.inputTank1 = new MachineFluidTank(Capacity); + this.inputTank2 = new MachineFluidTank(Capacity); + } } this.onlyOutput = OnlyOutput; this.allowDoubleInput = AllowDoubleInput; this.requiresUpdate = false; this.fluidInteractionType = LiquidInteractionType; - } + this.onlyInput = OnlyInput; + this.numberOfInputTanks = NumberOfInputTanks; + } /// /// Produces a given amount of Fluid and puts it into the output tank for this Fluid manager. /// @@ -460,6 +494,11 @@ namespace Revitalize.Framework.Managers return 0; } + /// + /// Gets the amount of fluid that are in the input tanks. + /// + /// The type of fluid to check to the input tanks. + /// The total amount of fluid of the same type of fluid passed in. public int getAmountOfFluidInInputTanks(Fluid L) { if (this.allowDoubleInput) @@ -542,7 +581,7 @@ namespace Revitalize.Framework.Managers public FluidManagerV2 Copy() { - return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput, this.fluidInteractionType, this.allowDoubleInput); + return new FluidManagerV2(this.outputTank.capacity, this.onlyOutput, this.fluidInteractionType, this.allowDoubleInput,this.onlyInput,this.numberOfInputTanks); } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index 3950c517..5cf591d6 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -134,9 +134,39 @@ namespace Revitalize.Framework.Menus.Machines hovered = true; } - if (hovered == false) + if (this.objectSource.info.fluidManager.InteractsWithFluids) { - this.hoverText = ""; + if (this.inputFluidTank1Button.containsPoint(x, y)) + { + if (this.objectSource.info.fluidManager.inputTank1.capacity > 0) + { + this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(); + hovered = true; + } + } + + if (this.inputFluidTank2Button.containsPoint(x, y)) + { + if (this.objectSource.info.fluidManager.inputTank2.capacity > 0) + { + this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(); + hovered = true; + } + } + + if (this.outputFluidTankButton.containsPoint(x, y)) + { + if (this.objectSource.info.fluidManager.outputTank.capacity > 0) + { + this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(); + hovered = true; + } + } + + if (hovered == false) + { + this.hoverText = ""; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index b623a78f..6658452e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -339,7 +339,7 @@ namespace Revitalize.Framework.Objects waterPumpV1.addComponent(new Vector2(0, 1), waterPumpV1_0_1); this.AddItem("WaterPumpV1", waterPumpV1); - MultiTiledObject steamBoilerV1= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false))); + MultiTiledObject steamBoilerV1= new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false,false,1))); SteamBoiler steamBoilerV1_0_0 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 0, 16, 16),new Dictionary>() { {"Default",new List(){ @@ -349,7 +349,7 @@ namespace Revitalize.Framework.Objects new Animation(32,0,16,16) } }, - },"Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, true, ""); + },"Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, true, ""); SteamBoiler steamBoilerV1_1_0 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 0, 16, 16), new Dictionary>() { @@ -360,7 +360,7 @@ namespace Revitalize.Framework.Objects new Animation(48,0,16,16) } }, - }, "Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, true, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_0_1 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 16, 16, 16), new Dictionary>() { @@ -371,7 +371,7 @@ namespace Revitalize.Framework.Objects new Animation(32,16,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_1_1 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 16, 16, 16), new Dictionary>() { @@ -382,7 +382,7 @@ namespace Revitalize.Framework.Objects new Animation(48,16,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_0_2 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(0, 32, 16, 16), new Dictionary>() { @@ -393,7 +393,7 @@ namespace Revitalize.Framework.Objects new Animation(32,32,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); SteamBoiler steamBoilerV1_1_2 = new SteamBoiler(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamBoiler", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), typeof(SteamBoiler), Color.White, true), new BasicItemInformation("Steam Boiler", "Omegasis.Revitalize.Objects.Machines.SteamBoiler", "Burns coal and wood. Consumes water to produce steam which can be used in a steam generator.", "Machine", Color.SteelBlue, -300, 0, false, 1000, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamBoiler"), new Animation(16, 32, 16, 16), new Dictionary>() { @@ -404,7 +404,7 @@ namespace Revitalize.Framework.Objects new Animation(48,32,16,16) } }, - }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false)), null, 0, 0, false, ""); + }, "Default"), Color.White, false, new InventoryManager(9, 3, 3), null, null, false, null, null, new Managers.FluidManagerV2(4000, false, Enums.FluidInteractionType.Machine, false, false, 1)), null, 0, 0, false, ""); steamBoilerV1.addComponent(new Vector2(0, 0), steamBoilerV1_0_0); steamBoilerV1.addComponent(new Vector2(1, 0), steamBoilerV1_1_0); @@ -415,9 +415,9 @@ namespace Revitalize.Framework.Objects this.AddItem("SteamBoilerV1", steamBoilerV1); - MultiTiledObject steamEngineV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false))); - SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); - SteamEngine steamEngineV1_1_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + MultiTiledObject steamEngineV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false,true,1))); + SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); + SteamEngine steamEngineV1_1_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Steam Engine", "Omegasis.Revitalize.Objects.Machines.SteamEngine", "Consumes steam in order to produce power.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "SteamEngine"), new Animation(16, 0, 16, 16)), Color.White, false, new InventoryManager(9, 3, 3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, new Managers.FluidManagerV2(2000, false, Enums.FluidInteractionType.Machine, false, true, 1)), null, ModCore.Configs.machinesConfig.steamEngineV1_powerGeneratedPerOperation, 0, true, "", ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation); steamEngineV1.addComponent(new Vector2(0, 0), steamEngineV1_0_0); steamEngineV1.addComponent(new Vector2(1, 0), steamEngineV1_1_0); this.AddItem("SteamEngineV1", steamEngineV1);