Added in steam engine. Updated fluid graph search from output tanks for better optimization.

This commit is contained in:
JoshuaNavarro 2019-10-03 23:42:16 -07:00
parent 09c32bf96f
commit 6c7f0e8099
11 changed files with 407 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

View File

@ -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()

View File

@ -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;
}
/// <summary>
/// Checks to see if the input tanks on this Fluid manager have the capacity to take in this Fluid at all.
/// </summary>

View File

@ -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;
}
}

View File

@ -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<ResourceInformation> 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<ResourceInformation>();
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<ResourceInformation> 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<ResourceInformation>();
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<ResourceInformation> 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<ResourceInformation>();
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<string, string> 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<SteamEngine>(additionalSaveData["GUID"]);
if (ModCore.IsNullOrDefault<Machine>(self)) return null;
try
{
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
{
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledObject>(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<string, string> 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<string, string> getAdditionalSaveData()
{
Dictionary<string, string> saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
this.containerObject.getAdditionalSaveData();
return saveData;
}
}
}

View File

@ -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<CustomObjectData>(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>(fluid);
}
this.amountOfFluidRequiredForOperation= Convert.ToInt32(fluidAmount);
if (string.IsNullOrEmpty(offsetVec)) return;
if (string.IsNullOrEmpty(containerObject)) return;
this.offsetKey = ModCore.Serializer.DeserializeFromJSONString<Vector2>(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<ResourceInformation> ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : base(PyTKData, info)
public Machine(CustomObjectData PyTKData, BasicItemInformation info, List<ResourceInformation> 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<ResourceInformation>();
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<ResourceInformation> 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<ResourceInformation> 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<ResourceInformation>();
@ -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<ResourceInformation> 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<ResourceInformation> 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;

View File

@ -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<MultiTiledObject> FluidGraphSearchForFluidFromOutputTanks(Fluid L)
{
List<MultiTiledObject> fluidSources = new List<MultiTiledObject>();
List<MultiTiledComponent> searchedComponents = new List<MultiTiledComponent>();
List<MultiTiledComponent> entitiesToSearch = new List<MultiTiledComponent>();
entitiesToSearch.AddRange(this.GetNeighboringFluidManagers());
searchedComponents.Add(this);
HashSet<Guid> searchedComponents = new HashSet<Guid>();
Queue<MultiTiledComponent> entitiesToSearch = new Queue<MultiTiledComponent>();
HashSet<Guid> searchedObjects = new HashSet<Guid>();
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<MultiTiledComponent> 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))
{

View File

@ -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()

View File

@ -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")
});
}

View File

@ -167,6 +167,7 @@
<Compile Include="Framework\Objects\Machines\ChargingStation.cs" />
<Compile Include="Framework\Objects\Machines\EnergyGeneration\SolarPanel.cs" />
<Compile Include="Framework\Objects\Machines\EnergyGeneration\SteamBoiler.cs" />
<Compile Include="Framework\Objects\Machines\EnergyGeneration\SteamEngine.cs" />
<Compile Include="Framework\Objects\Machines\Grinder.cs" />
<Compile Include="Framework\Objects\Machines\Machine.cs" />
<Compile Include="Framework\Objects\Machines\Pipe.cs" />
@ -518,6 +519,9 @@
<Content Include="Content\Graphics\Objects\Machines\SteamBoiler.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Objects\Machines\SteamEngine.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Objects\Machines\WaterPump.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>