From 106b7a94741e8d5f6b66218ecd4f8a174ccc8142 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 8 Oct 2019 13:01:58 -0700 Subject: [PATCH] Added in windmills. Also fixed machine summary menu crashing when fluid manager doesn't set fluid tanks on initialization. --- .../Objects/Machines/ClothWindmill.png | Bin 0 -> 490 bytes .../Graphics/Objects/Machines/Windmill.png | Bin 0 -> 430 bytes .../Framework/Configs/GlobalMachineConfig.cs | 7 + .../Framework/Managers/FluidManagerV2.cs | 7 +- .../Menus/Machines/MachineSummaryMenu.cs | 28 +- .../Machines/EnergyGeneration/Windmill.cs | 272 ++++++++++++++++++ .../Framework/Objects/ObjectManager.cs | 64 ++++- .../Framework/Utilities/WeatherUtilities.cs | 5 + GeneralMods/Revitalize/ModCore.cs | 7 +- GeneralMods/Revitalize/Revitalize.csproj | 7 + 10 files changed, 380 insertions(+), 17 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ClothWindmill.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Windmill.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ClothWindmill.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/ClothWindmill.png new file mode 100644 index 0000000000000000000000000000000000000000..14a1a3f73769681eeaaf7f1f6969787ba0694105 GIT binary patch literal 490 zcmVPx$q)9|UR9J=WR=rNcFc3bYEES^ah8WT@Qb5C~;F25@_}FSZ+KS@KDhV&8rDZ@U5xi1{=}{k>Q#!RaKNavLE=hw4_V z1eneCVE6;(di!0&H(^6Z|^|Ye|--aLrACp_2UyR(~Ir;ar0ux zLxwd%0k;~NO)@+`J2e7&czTX5e=OfQh7{>&Xc*WRF??qRjty@G^Z<5648Lzd--5mc zeGC4*1#AUolMDgAOQ?TzKZJew&g*2qVm3mr;=X*N1+z(p^gjTHpKOo|q6^=dfn)TY g!U>?uar+Jb3r@pgiNe1azW@LL07*qoM6N<$f;e%|q5uE@ literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Windmill.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/Windmill.png new file mode 100644 index 0000000000000000000000000000000000000000..6166dda5b805ed8c81ffad615d147782249ba240 GIT binary patch literal 430 zcmV;f0a5;mP)Px$Xh}ptR9J=WRzXU{FceK?Rt_U>WN^`yP!PHi#)YToE%X4M!vi?C@D#IfU^c>l z;Hsa6mh(Ejx0zr3HHHdFtI`@0)W_v_6rL+{LD2q64h5)h^iQvgY?WehXfD=*D$A{ZK_VoPf zO)g93;&ZGwyUZ$qOmcCxf^h_LjoZ%oXdDXQtNHxc!Z-ri&28s=H12FQx#42>Kvfoc zxtRCQP1~uLw|9$YIDnGp=V!fYSBv@()djBPNJJ=xx?m;)L}=R1h&OGgmW%nQbHK+j z1n}BcWua;1Bp{~$3DFMxCFBC41=L^PlLUnDy#hj3FqIDvqGKYJAeA7MAeA7M06I{W zg;wg 0) + { + this.inputFluidTank1Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 1 fluid:", this.fluidDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.inputTank1.fluid != null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank1.fluid != null ? this.objectSource.info.fluidManager.inputTank1.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + if (this.objectSource.GetFluidManager().inputTank2.capacity > 0) + { + this.inputFluidTank2Button = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Input 2 fluid:", this.fluidDisplayLocation + new Vector2(0, 64), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.inputTank2.fluid != null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.inputTank2.fluid != null ? this.objectSource.info.fluidManager.inputTank2.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + //ModCore.log(this.objectSource.info.fluidManager.outputTank.fluid != null ? "Color of fluid:" + this.objectSource.info.fluidManager.outputTank.fluid.color.ToString() : "Color is null!"); + if (this.objectSource.GetFluidManager().outputTank.capacity > 0) + { + this.outputFluidTankButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Output fluid:", this.fluidDisplayLocation + new Vector2(0, 128), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", this.objectSource.info.fluidManager.outputTank.fluid != null ? "DropletColored" : "DropletOutline"), new StardustCore.Animations.Animation(0, 0, 16, 16)), this.objectSource.info.fluidManager.outputTank.fluid != null ? this.objectSource.info.fluidManager.outputTank.fluid.color : Color.White), new Rectangle(0, 0, 16, 16), 2f); + } this.requiredEnergyPer10Min = RequiredEnergyPer10Min; } @@ -162,11 +170,11 @@ namespace Revitalize.Framework.Menus.Machines hovered = true; } } + } - if (hovered == false) - { - this.hoverText = ""; - } + if (hovered == false) + { + this.hoverText = ""; } } @@ -180,7 +188,7 @@ namespace Revitalize.Framework.Menus.Machines else if (this.energy.producesEnergy) { - return "Produces " + EnergyAmount + " per 10 minutes."; + return "Produces " + EnergyAmount + " energy per 10 minutes."; } else return ""; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs new file mode 100644 index 00000000..1a1cbd6a --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs @@ -0,0 +1,272 @@ +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 Newtonsoft.Json; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Managers; +using Revitalize.Framework.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardustCore.Animations; + +namespace Revitalize.Framework.Objects.Machines.EnergyGeneration +{ + public class Windmill:Machine + { + + public Windmill() { } + + public Windmill(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 Windmill(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 Windmill(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(); + //ModCore.log(this.info.animationManager.currentAnimationName); + this.info.animationManager.playAnimation("Working"); + if (this.updatesContainerObjectForProduction) + { + int remaining = minutes; + + if (this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Produces) + { + while (remaining > 0) + { + remaining -= 10; + this.produceEnergy(); + 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() + { + Windmill component = new Windmill(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; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + string GUID = additionalSaveData["GUID"]; + Windmill 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.location != null) + { + if (this.location.IsOutdoors == false) return; + } + if (this.GetEnergyManager().canReceieveEnergy) + { + if (WeatherUtilities.IsWeatherGoodForWindmills()) + { + this.GetEnergyManager().produceEnergy((int)(this.energyRequiredPer10Minutes*ModCore.Configs.machinesConfig.windmill_windyDayPowerMultiplier)); + } + else + { + this.GetEnergyManager().produceEnergy(this.energyRequiredPer10Minutes); + } + } + + } + + public override void updateInfo() + { + 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/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 6658452e..f6ee11db 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -416,11 +416,71 @@ 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,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); + SteamEngine steamEngineV1_0_0 = new SteamEngine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.SteamEngineV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "SteamEngine"), typeof(SteamEngine), 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(SteamEngine), 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); + + + MultiTiledObject windMillV1 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV1", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Windmill"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null)); + Windmill windMillV1_0_0 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV1", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Windmill"), new Animation(0, 0, 16, 16),new Dictionary>() { + + {"Default",new List() + { + new Animation(0,0,16,16) + } }, + {"Working",new List() + { + new Animation(0,0,16,16,20), + new Animation(16,0,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV1_basePowerProduction, 0, true, "", null, 0); + Windmill windMillV1_0_1 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV1", TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV1", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "Windmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "Windmill"), new Animation(0, 0, 16, 16), new Dictionary>() { + + {"Default",new List() + { + new Animation(0,16,16,16) + } }, + {"Working",new List() + { + new Animation(0,16,16,16,20), + new Animation(16,16,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV1_basePowerProduction, 0, false, "", null, 0); + windMillV1.addComponent(new Vector2(0, 0), windMillV1_0_0); + windMillV1.addComponent(new Vector2(0, 1), windMillV1_0_1); + this.AddItem("WindmillV1", windMillV1); + + + MultiTiledObject windMillV2 = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV2", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Improved Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV2", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 700, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new Animation(0, 0, 16, 16)), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null)); + Windmill windMillV2_0_0 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV2", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), typeof(Windmill), Color.White, true), new BasicItemInformation("Improved Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV2", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 700, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new Animation(0, 0, 16, 16), new Dictionary>() { + + {"Default",new List() + { + new Animation(0,0,16,16) + } }, + {"Working",new List() + { + new Animation(0,0,16,16,20), + new Animation(16,0,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV2_basePowerProduction, 0, true, "", null, 0); + Windmill windMillV2_0_1 = new Windmill(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.WindmillV2", TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), typeof(Windmill), Color.White, true), new BasicItemInformation("Improved Windmill", "Omegasis.Revitalize.Objects.Machines.WindmillV2", "Generates power from the wind.", "Machine", Color.SteelBlue, -300, 0, false, 700, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "ClothWindmill"), new Animation(0, 0, 16, 16), new Dictionary>() { + + {"Default",new List() + { + new Animation(0,16,16,16) + } }, + {"Working",new List() + { + new Animation(0,16,16,16,20), + new Animation(16,16,16,16,20) + } } + },"Working"), Color.White, false, null, null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Produces), false, null, null, null), null, ModCore.Configs.machinesConfig.windmillV2_basePowerProduction, 0, false, "", null, 0); + windMillV2.addComponent(new Vector2(0, 0), windMillV2_0_0); + windMillV2.addComponent(new Vector2(0, 1), windMillV2_0_1); + this.AddItem("WindmillV2", windMillV2); } private void loadInConnectionComponents() diff --git a/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs index 55aef69c..61389693 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/WeatherUtilities.cs @@ -67,5 +67,10 @@ namespace Revitalize.Framework.Utilities return IsItRaining() || IsItSnowing() || IsStorm(); } + public static bool IsWeatherGoodForWindmills() + { + return IsWindyDay() || IsStorm(); + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index ecd11d81..b47bed7f 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -588,14 +588,11 @@ namespace Revitalize ModCore.ObjectManager.GetItem("SolarPanelTier1",1), ModCore.ObjectManager.GetItem("SolarArrayTier1",1), new StardewValley.Object(Vector2.Zero,(int)Enums.SDVBigCraftable.Furnace,false), - ModCore.ObjectManager.GetItem("Lighthouse",1), ModCore.ObjectManager.GetItem("CopperWire",10), batteryBin, ModCore.ObjectManager.GetItem("Capacitor",1), ModCore.ObjectManager.GetItem("ChargingStation",1), - ModCore.ObjectManager.GetItem("Grinder",1), new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), - ModCore.ObjectManager.GetTool("MiningDrillV1"), ModCore.ObjectManager.GetTool("ChainsawV1"), ModCore.ObjectManager.GetItem("MiningDrillMachineV1"), ModCore.ObjectManager.GetItem("AlloyFurnace"), @@ -603,7 +600,9 @@ namespace Revitalize ModCore.ObjectManager.GetItem("WaterPumpV1"), ModCore.ObjectManager.GetItem("SteamBoilerV1"), ModCore.ObjectManager.GetItem("IronPipe",100), - ModCore.ObjectManager.GetItem("SteamEngineV1") + ModCore.ObjectManager.GetItem("SteamEngineV1"), + ModCore.ObjectManager.GetItem("WindmillV1"), + ModCore.ObjectManager.GetItem("WindmillV2") }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index aaf21f71..b9ab7842 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -168,6 +168,7 @@ + @@ -498,6 +499,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -525,6 +529,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest