diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png
index 2662d05b..db85e09e 100644
Binary files a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png and b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Capacitor.png differ
diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamEngine.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamEngine.png
new file mode 100644
index 00000000..72ae0383
Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/SteamEngine.png differ
diff --git a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs
index 8e1bf4bc..8b350609 100644
--- a/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs
+++ b/GeneralMods/Revitalize/Framework/Configs/GlobalMachineConfig.cs
@@ -25,6 +25,8 @@ namespace Revitalize.Framework.Configs
public int steamBoilerV1_requiredWaterPerOperation;
public int steamBoilerV1_producedSteamPerOperation;
+ public int steamEngineV1_requiredSteamPerOperation;
+ public int steamEngineV1_powerGeneratedPerOperation;
public GlobalMachineConfig()
{
this.doMachinesConsumeEnergy = true;
@@ -38,6 +40,9 @@ namespace Revitalize.Framework.Configs
this.miningDrillTimeToMine = 60;
this.steamBoilerV1_requiredWaterPerOperation = 200;
this.steamBoilerV1_producedSteamPerOperation = 100;
+
+ this.steamEngineV1_requiredSteamPerOperation = 200;
+ this.steamEngineV1_powerGeneratedPerOperation = 10;
}
public static GlobalMachineConfig InitializeConfig()
diff --git a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs
index fd5de4e7..47b587f5 100644
--- a/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs
+++ b/GeneralMods/Revitalize/Framework/Managers/FluidManagerV2.cs
@@ -444,6 +444,7 @@ namespace Revitalize.Framework.Managers
int amount = 0;
amount += this.inputTank1.GetAmountOfFluidThisTankCanReceieve(L);
amount += this.inputTank2.GetAmountOfFluidThisTankCanReceieve(L);
+ return amount;
}
else
{
@@ -459,6 +460,30 @@ namespace Revitalize.Framework.Managers
return 0;
}
+ public int getAmountOfFluidInInputTanks(Fluid L)
+ {
+ if (this.allowDoubleInput)
+ {
+ int amount = 0;
+ amount += this.inputTank1.GetAmountOfFluidInThisTank(L);
+ amount += this.inputTank2.GetAmountOfFluidInThisTank(L);
+ return amount;
+ }
+ else
+ {
+ if (this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false)
+ {
+ return this.inputTank1.GetAmountOfFluidInThisTank(L);
+ }
+ if (this.inputTank1.CanRecieveThisFluid(L) && this.inputTank2.DoesTankContainThisFluid(L) == false)
+ {
+ return this.inputTank2.GetAmountOfFluidInThisTank(L);
+ }
+ }
+ return 0;
+
+ }
+
///
/// Checks to see if the input tanks on this Fluid manager have the capacity to take in this Fluid at all.
///
diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs
index 79f7a64d..3950c517 100644
--- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs
+++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs
@@ -75,7 +75,7 @@ namespace Revitalize.Framework.Menus.Machines
{
get
{
- return this.energy.maxEnergy != 0 || ModCore.Configs.machinesConfig.doMachinesConsumeEnergy==false;
+ return this.energy.maxEnergy != 0 && ModCore.Configs.machinesConfig.doMachinesConsumeEnergy==true;
}
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs
new file mode 100644
index 00000000..26d0d1ab
--- /dev/null
+++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs
@@ -0,0 +1,294 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using PyTK.CustomElementHandler;
+using Revitalize.Framework.Managers;
+using Revitalize.Framework.Objects.InformationFiles;
+using Revitalize.Framework.Utilities;
+using StardewValley;
+
+namespace Revitalize.Framework.Objects.Machines.EnergyGeneration
+{
+ public class SteamEngine:Machine
+ {
+
+ public SteamEngine() { }
+
+ public SteamEngine(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "",Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation=0) : base(PyTKData, info)
+ {
+ this.producedResources = ProducedResources ?? new List();
+ this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes;
+ this.timeToProduce = TimeToProduce;
+ this.updatesContainerObjectForProduction = UpdatesContainer;
+ this.MinutesUntilReady = TimeToProduce;
+ this.craftingRecipeBook = CraftingBook;
+ this.createStatusBubble();
+ this.requiredFluidForOperation = FluidRequiredForOperation;
+ this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation;
+ }
+
+ public SteamEngine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation = 0) : base(PyTKData, info, TileLocation)
+ {
+ this.containerObject = obj;
+ this.producedResources = ProducedResources ?? new List();
+ this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes;
+ this.timeToProduce = TimeToProduce;
+ this.updatesContainerObjectForProduction = UpdatesContainer;
+ this.MinutesUntilReady = TimeToProduce;
+ this.craftingRecipeBook = CraftingBook;
+ this.createStatusBubble();
+ this.requiredFluidForOperation = FluidRequiredForOperation;
+ this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation;
+ }
+
+ public SteamEngine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation = 0) : base(PyTKData, info, TileLocation)
+ {
+ this.offsetKey = offsetKey;
+ this.containerObject = obj;
+ this.producedResources = ProducedResources ?? new List();
+ this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes;
+ this.timeToProduce = TimeToProduce;
+ this.updatesContainerObjectForProduction = UpdatesContainer;
+ this.MinutesUntilReady = TimeToProduce;
+ this.craftingRecipeBook = CraftingBook;
+ this.createStatusBubble();
+ this.requiredFluidForOperation = FluidRequiredForOperation;
+ this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation;
+ }
+
+ public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
+ {
+ base.updateWhenCurrentLocation(time, environment);
+
+ this.animationManager.prepareForNextUpdateTick();
+ }
+
+
+ public override bool minutesElapsed(int minutes, GameLocation environment)
+ {
+ this.updateInfo();
+
+ /*
+ if (this.containerObject.MinutesUntilReady > 0)
+ {
+ this.animationManager.playAnimation("Working");
+ }
+ else
+ {
+ this.animationManager.playDefaultAnimation();
+ }
+ */
+ this.pullFluidFromNetworkOutputs(ModCore.ObjectManager.resources.getFluid("Steam"));
+
+ if (this.updatesContainerObjectForProduction)
+ {
+ int remaining = minutes;
+ while (remaining > 0)
+ {
+ if (this.GetEnergyManager().canReceieveEnergy == false) return false;
+ remaining -= 10;
+ int fluidAmount = this.GetFluidManager().getAmountOfFluidInInputTanks(this.requiredFluidForOperation);
+ if (this.GetFluidManager().doTheInputTanksHaveEnoughFluid(ModCore.ObjectManager.resources.getFluid(this.requiredFluidForOperation.name), this.amountOfFluidRequiredForOperation))
+ {
+ this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid(this.requiredFluidForOperation.name), this.amountOfFluidRequiredForOperation);
+ //this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamBoilerV1_producedSteamPerOperation);
+ this.produceEnergy();
+ this.storeEnergyToNetwork();
+ }
+ else if(fluidAmount>0)
+ {
+ //Try to always consume fluid if possible.
+ double ratio = (double)fluidAmount / (double)ModCore.Configs.machinesConfig.steamEngineV1_requiredSteamPerOperation;
+ int liquidToConsume = fluidAmount;
+ this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid(this.requiredFluidForOperation.name), liquidToConsume);
+ this.produceEnergy(ratio);
+ this.storeEnergyToNetwork();
+ }
+ }
+ return false;
+ }
+ else
+ {
+
+ if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces)
+ {
+ this.storeEnergyToNetwork();
+ }
+
+ return false;
+ }
+
+ //return base.minutesElapsed(minutes, environment);
+ }
+
+ public override bool rightClicked(Farmer who)
+ {
+ if (this.location == null)
+ this.location = Game1.player.currentLocation;
+ if (Game1.menuUp || Game1.currentMinigame != null) return false;
+
+ //ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero);
+ this.createMachineMenu();
+ return true;
+ }
+
+
+ public override Item getOne()
+ {
+ SteamEngine component = new SteamEngine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook,this.requiredFluidForOperation,this.amountOfFluidRequiredForOperation);
+ component.containerObject = this.containerObject;
+ component.offsetKey = this.offsetKey;
+ return component;
+ return component;
+ }
+
+ public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
+ {
+ Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ string GUID = additionalSaveData["GUID"];
+ SteamEngine self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
+ if (ModCore.IsNullOrDefault(self)) return null;
+ try
+ {
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ }
+ }
+ catch (Exception err)
+ {
+ ModCore.log(err);
+ }
+
+ return self;
+ }
+
+ public override void rebuild(Dictionary additionalSaveData, object replacement)
+ {
+ base.rebuild(additionalSaveData, replacement);
+ }
+
+ public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
+ {
+ this.updateInfo();
+
+ if (this.info == null)
+ {
+ Revitalize.ModCore.log("info is null");
+ if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
+ }
+ if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
+ if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
+
+ //The actual planter box being drawn.
+ if (this.animationManager == null)
+ {
+ if (this.animationManager.getExtendedTexture() == null)
+ ModCore.ModMonitor.Log("Tex Extended is null???");
+
+ spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.DrawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f));
+ // Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
+ }
+
+ else
+ {
+ //Log.AsyncC("Animation Manager is working!");
+ float addedDepth = 0;
+
+
+ if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up)
+ {
+ addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y));
+ if (this.info.ignoreBoundingBox) addedDepth += 1.5f;
+ }
+ else if (this.info.ignoreBoundingBox)
+ {
+ addedDepth += 1.0f;
+ }
+ this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.DrawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f);
+ this.drawStatusBubble(spriteBatch, x, y, alpha);
+
+ try
+ {
+ if (this.animationManager.canTickAnimation())
+ {
+ this.animationManager.tickAnimation();
+ }
+ // Log.AsyncC("Tick animation");
+ }
+ catch (Exception err)
+ {
+ ModCore.ModMonitor.Log(err.ToString());
+ }
+ }
+
+ // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
+
+ }
+
+ public override void produceEnergy()
+ {
+
+ if (this.GetEnergyManager().canReceieveEnergy)
+ {
+ this.GetEnergyManager().produceEnergy(this.energyRequiredPer10Minutes);
+ }
+
+ }
+
+ public virtual void processFluidLogic()
+ {
+ return;
+ if (this.GetFluidManager().doTheInputTanksHaveEnoughFluid(ModCore.ObjectManager.resources.getFluid("Water"), ModCore.Configs.machinesConfig.steamBoilerV1_requiredWaterPerOperation))
+ {
+ this.GetFluidManager().consumeFluid(ModCore.ObjectManager.resources.getFluid("Water"), ModCore.Configs.machinesConfig.steamBoilerV1_requiredWaterPerOperation);
+ this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Steam"), ModCore.Configs.machinesConfig.steamBoilerV1_producedSteamPerOperation);
+ this.containerObject.MinutesUntilReady -= 10;
+ }
+ }
+
+ public override void updateInfo()
+ {
+ return;
+ if (this.info == null || this.containerObject == null)
+ {
+ this.ItemInfo = this.text;
+ //ModCore.log("Updated item info!");
+ return;
+ }
+
+ if (this.requiresUpdate())
+ {
+ //this.ItemInfo = this.text;
+ this.text = this.ItemInfo;
+ this.info.cleanAfterUpdate();
+ //this.containerObject.updateInfo();
+ //ModCore.log("Force an update for machine: " + this.info.name);
+ MultiplayerUtilities.RequestUpdateSync(this.guid);
+ }
+ }
+
+ public override Dictionary getAdditionalSaveData()
+ {
+ Dictionary saveData = base.getAdditionalSaveData();
+ Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
+ this.containerObject.getAdditionalSaveData();
+ return saveData;
+
+ }
+ }
+}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs
index 0c381a04..31c849ba 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs
@@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics;
using Newtonsoft.Json;
using PyTK.CustomElementHandler;
using Revitalize.Framework.Crafting;
+using Revitalize.Framework.Managers;
using Revitalize.Framework.Menus;
using Revitalize.Framework.Menus.Machines;
using Revitalize.Framework.Objects.InformationFiles;
@@ -38,6 +39,8 @@ namespace Revitalize.Framework.Objects.Machines
string energyRequired = this.energyRequiredPer10Minutes.ToString();
string timeToProduce = this.timeToProduce.ToString();
string updatesContainer = this.updatesContainerObjectForProduction.ToString();
+ string fluidString = this.requiredFluidForOperation != null ? ModCore.Serializer.ToJSONString(this.amountOfFluidRequiredForOperation) : "";
+ string fluidAmountString = this.amountOfFluidRequiredForOperation.ToString();
StringBuilder b = new StringBuilder();
b.Append(info);
b.Append("<");
@@ -56,6 +59,10 @@ namespace Revitalize.Framework.Objects.Machines
b.Append(updatesContainer);
b.Append("<");
b.Append(this.craftingRecipeBook);
+ b.Append("<");
+ b.Append(fluidString);
+ b.Append("<");
+ b.Append(fluidAmountString);
//ModCore.log("Setting info: " + b.ToString());
return b.ToString();
}
@@ -72,12 +79,18 @@ namespace Revitalize.Framework.Objects.Machines
string time = data[6];
string updates = data[7];
this.craftingRecipeBook = data[8];
+ string fluid = data[9];
+ string fluidAmount = data[10];
this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation));
this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString(pyTKData);
this.energyRequiredPer10Minutes = Convert.ToInt32(energyRequired);
this.timeToProduce = Convert.ToInt32(time);
this.updatesContainerObjectForProduction = Convert.ToBoolean(updates);
-
+ if (string.IsNullOrEmpty(fluid) == false)
+ {
+ this.requiredFluidForOperation = ModCore.Serializer.DeserializeFromJSONString(fluid);
+ }
+ this.amountOfFluidRequiredForOperation= Convert.ToInt32(fluidAmount);
if (string.IsNullOrEmpty(offsetVec)) return;
if (string.IsNullOrEmpty(containerObject)) return;
this.offsetKey = ModCore.Serializer.DeserializeFromJSONString(offsetVec);
@@ -158,6 +171,9 @@ namespace Revitalize.Framework.Objects.Machines
}
}
+ public Fluid requiredFluidForOperation;
+ public int amountOfFluidRequiredForOperation;
+
[JsonIgnore]
public bool ConsumesEnergy
{
@@ -191,7 +207,7 @@ namespace Revitalize.Framework.Objects.Machines
public Machine() { }
- public Machine(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info)
+ public Machine(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation =0) : base(PyTKData, info)
{
this.producedResources = ProducedResources ?? new List();
this.energyRequiredPer10Minutes = EnergyRequiredPer10Minutes;
@@ -200,10 +216,11 @@ namespace Revitalize.Framework.Objects.Machines
this.MinutesUntilReady = TimeToProduce;
this.craftingRecipeBook = CraftingBook;
this.createStatusBubble();
-
+ this.requiredFluidForOperation = FluidRequiredForOperation;
+ this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation;
}
- public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null) : base(PyTKData, info, TileLocation)
+ public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation =0) : base(PyTKData, info, TileLocation)
{
this.containerObject = obj;
this.producedResources = ProducedResources ?? new List();
@@ -213,9 +230,11 @@ namespace Revitalize.Framework.Objects.Machines
this.MinutesUntilReady = TimeToProduce;
this.craftingRecipeBook = CraftingBook;
this.createStatusBubble();
+ this.requiredFluidForOperation = FluidRequiredForOperation;
+ this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation;
}
- public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null) : base(PyTKData, info, TileLocation)
+ public Machine(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Vector2 offsetKey, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "", MultiTiledObject obj = null, Fluid FluidRequiredForOperation = null, int FluidAmountRequiredPerOperation =0) : base(PyTKData, info, TileLocation)
{
this.offsetKey = offsetKey;
this.containerObject = obj;
@@ -226,6 +245,8 @@ namespace Revitalize.Framework.Objects.Machines
this.MinutesUntilReady = TimeToProduce;
this.craftingRecipeBook = CraftingBook;
this.createStatusBubble();
+ this.requiredFluidForOperation = FluidRequiredForOperation;
+ this.amountOfFluidRequiredForOperation = FluidAmountRequiredPerOperation;
}
protected virtual void createStatusBubble()
@@ -367,7 +388,7 @@ namespace Revitalize.Framework.Objects.Machines
public override Item getOne()
{
- Machine component = new Machine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook);
+ Machine component = new Machine(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook,this.requiredFluidForOperation,this.amountOfFluidRequiredForOperation);
component.containerObject = this.containerObject;
component.offsetKey = this.offsetKey;
return component;
@@ -491,6 +512,16 @@ namespace Revitalize.Framework.Objects.Machines
}
+ public virtual void produceEnergy(double ratio)
+ {
+
+ if (this.GetEnergyManager().canReceieveEnergy)
+ {
+ this.GetEnergyManager().produceEnergy((int)(this.energyRequiredPer10Minutes * ratio));
+ }
+
+ }
+
protected virtual void drawStatusBubble(SpriteBatch b, int x, int y, float Alpha)
{
if (this.updatesContainerObjectForProduction == false) return;
diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
index 095c0b76..2db112c2 100644
--- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -741,22 +742,44 @@ namespace Revitalize.Framework.Objects
protected virtual List FluidGraphSearchForFluidFromOutputTanks(Fluid L)
{
List fluidSources = new List();
- List searchedComponents = new List();
- List entitiesToSearch = new List();
- entitiesToSearch.AddRange(this.GetNeighboringFluidManagers());
- searchedComponents.Add(this);
+ HashSet searchedComponents = new HashSet();
+ Queue entitiesToSearch = new Queue();
+ HashSet searchedObjects = new HashSet();
+ foreach(MultiTiledComponent tile in this.GetNeighboringFluidManagers())
+ {
+ entitiesToSearch.Enqueue(tile);
+ }
+ //entitiesToSearch.AddRange(this.GetNeighboringFluidManagers());
+ searchedComponents.Add(this.guid);
while (entitiesToSearch.Count > 0)
{
- MultiTiledComponent searchComponent = entitiesToSearch[0];
- entitiesToSearch.Remove(searchComponent);
- if (searchedComponents.Contains(searchComponent))
+ MultiTiledComponent searchComponent = entitiesToSearch.Dequeue();
+ //entitiesToSearch.Remove(searchComponent);
+ if (searchedComponents.Contains(searchComponent.guid))
{
continue;
}
+ /*
+ else if (searchedObjects.Contains(searchComponent.containerObject))
+ {
+ continue;
+ }
+ */
else
{
- searchedComponents.Add(searchComponent);
- entitiesToSearch.AddRange(searchComponent.GetNeighboringFluidManagers());
+ searchedComponents.Add(searchComponent.guid);
+ searchedObjects.Add(searchComponent.containerObject.guid);
+
+ List neighbors = searchComponent.GetNeighboringFluidManagers();
+
+ foreach(MultiTiledComponent tile in neighbors)
+ {
+ if (searchedObjects.Contains(tile.containerObject.guid) || searchedComponents.Contains(tile.guid)) continue;
+ else
+ {
+ entitiesToSearch.Enqueue(tile);
+ }
+ }
if (searchComponent.containerObject.info.fluidManager.doesThisOutputTankContainThisFluid(L))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs
index 98091012..b623a78f 100644
--- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs
@@ -414,6 +414,13 @@ namespace Revitalize.Framework.Objects
steamBoilerV1.addComponent(new Vector2(1, 2), steamBoilerV1_1_2);
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);
+ steamEngineV1.addComponent(new Vector2(0, 0), steamEngineV1_0_0);
+ steamEngineV1.addComponent(new Vector2(1, 0), steamEngineV1_1_0);
+ this.AddItem("SteamEngineV1", steamEngineV1);
}
private void loadInConnectionComponents()
diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs
index 6b0a98aa..ecd11d81 100644
--- a/GeneralMods/Revitalize/ModCore.cs
+++ b/GeneralMods/Revitalize/ModCore.cs
@@ -602,7 +602,8 @@ namespace Revitalize
new StardewValley.Object((int)Enums.SDVObject.IronBar,100),
ModCore.ObjectManager.GetItem("WaterPumpV1"),
ModCore.ObjectManager.GetItem("SteamBoilerV1"),
- ModCore.ObjectManager.GetItem("IronPipe",10)
+ ModCore.ObjectManager.GetItem("IronPipe",100),
+ ModCore.ObjectManager.GetItem("SteamEngineV1")
});
}
diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj
index 9f73a218..aaf21f71 100644
--- a/GeneralMods/Revitalize/Revitalize.csproj
+++ b/GeneralMods/Revitalize/Revitalize.csproj
@@ -167,6 +167,7 @@
+
@@ -518,6 +519,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest