From caa7653b32e2b4db88bc3e5ca7dcbe3272685590 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 22 Sep 2019 11:12:07 -0700 Subject: [PATCH] Finally added in the alloy furnace. I think all machines should serialize now. --- .../Objects/Machines/AlloyFurnace.png | Bin 0 -> 718 bytes .../Objects/Machines/MiningDrillMachine.png | Bin 829 -> 845 bytes .../Framework/Crafting/CraftingRecipeBook.cs | 48 ++++ .../Framework/Crafting/VanillaRecipeBook.cs | 3 +- .../Menus/CraftingInformationPage.cs | 2 +- .../Objects/Machines/AlloyFurnace.cs | 262 ++++++++++++++++++ .../Objects/Machines/ChargingStation.cs | 14 + .../Machines/EnergyGeneration/SolarPanel.cs | 16 ++ .../Framework/Objects/Machines/Machine.cs | 6 +- .../Framework/Objects/Machines/Wire.cs | 14 + .../Objects/Machines/WireMultiTiledObject.cs | 4 + .../Framework/Objects/ObjectManager.cs | 35 +++ .../Utilities/Serialization/Serialization.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 4 +- GeneralMods/Revitalize/Revitalize.csproj | 1 + 15 files changed, 404 insertions(+), 9 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Objects/Machines/AlloyFurnace.png create mode 100644 GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/AlloyFurnace.png b/GeneralMods/Revitalize/Content/Graphics/Objects/Machines/AlloyFurnace.png new file mode 100644 index 0000000000000000000000000000000000000000..0c8e5dfe548aaaf1a0d4cf7c04aba5fab6760a34 GIT binary patch literal 718 zcmV;<0x|uGP)Px%h)G02RA_gW=abO; zfJ&9_SxcfHP0Q-d`h7!m?(@}^kdf7cw3Dlff>lKc;v%%1cJk8qg)yb74#YZOT2_z8 zWpp4k(L8z56Tn6JBm{qfX<5BrCnp8~)G=T2rSFGg0C-xj{~k;xBtBMOu0Glc3dIVD-n{51AymM*=aDDKTEL*Gs>bH_3jn}qc#KA?of_|K z9bzzfTU>PxJ@I-D&9N5YqYDu6i8JuQeGb-{`vTuH z_yaOLsXrjY^BEZM6-d4ZqXb>q&3 zo5V#n{(y=F7lM$j+k)UisF*(x$RcevUGxXErASM#e$b+&Ndu8g7p5AlwvG!kkD2Mb z$)s;GLm+4MCUfsOxo7TsH)J?Ch`V=gDR$!4Ha0mYby@U%tbYVXB&TMmdC`!FmDMHc zeJ}KV#vqmgtPl-}sL9oiac=9MGoV`n722owW^vIp=E?j#iS2e9^h%!?;6wrA(imC4 zt)+GM9!Hl+%t7VQu>x52bsfM`K>G_RS3(h8yb%YLL+T#(LZ2AmL;+gR3ZTI&ed-y| zZ2?Af8}F4q)qj9~DS%bqu?{fKaI1JbQ@|~K(<#smffni^rk>VjurmeR)Hj_17b(Da zh&6p#jGQh20OE2PyP+fidsDzo{YzQ`EpgMACF{6cCTlyVaMPE?a6&@UmqlDIBOPt% zILzRcJ~uZzNm_45;gOu0Aq2nPS1?n5gmkolB} z)$|FdKV_}*-PRwP7O%dT5d8=Tczpc+7t@K``2AxAKjj2QP8V?GkD&4Gm=NrJ`HXwg zFv0;Ia`QitntvlOgwoar!lB~GA0gryiAOlVo926=PqqL6WF#Idt4oN6MB*L*oqHLH zH+A30VShw7xo+xnbF-7mgy_eoYKwfRwxSls*3;$~^8w&kyr#RpT;11QTjjf{ubTq7 z^=)#vj7wv>v9z|a$*r~5+H-@JkM(UOl}aHdUB|1}F9Cquvy<h($ delta 794 zcmV+#1Lge92E7K5Fn~=O;0(qx_{pP)WZ@!rc8x9WQ=8bD@D|O|KP0mSO7JUyZfqx#!xfFF?Bp5|$eUzBEcwXabVNJar2ht&R54)jH0&v2B8Z-kmxTQ}$1MC{m z!*0D>`qTgh#eV>+zGEGrzr)Syt=t0r(l@*X>=3A-9Ae68Z3HW~KtJ^jZ-I*#&>vz= zPX^B*3BT&|F@l~cIs$zUuYpy|mVE?1C_G&CGW za7&+CT$m-Tx83$4IhP^?zurqo)$b!6X<)4u!fr5$%74~d%y1`$WZP{o?%ckMnp`zp z0p+Kx+5CR%kIqLgKb?;H5b}HR@!KEFC$8i7j}m^$35=gEv|A>_NSN)?XZhase3XXhXB7RTsBINfP&UZtfTU?lJPe*;E__cIGQdC1tpkSxk zA}^qf)qg9ghJNMLbKKM?hoC|*!vUrB)pG<&>+Dqjr>;l#%{#I;r-Vt(sb1dLEJ~aSFv_(+_00bri=zokYeeH2lKQIvh08@Qh0IUW$b=!5u zc0PbuHo&S+3&0Tr3fv0NihkD)=te-nzyvt#09FDD1}4B^2e1-QFfaiQJAjpdf`JLJ zR~-NV;CUWWec$dh$MmK8K6suttug&;jKKf^aM^5DS+xuO8*Ie@tG-zP%mx_d^-cdT YqZ1Y5IQFW)WB>pF07*qoM6N<$f~#Y2@Bjb+ diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index d0e7b8b1..ca5c95af 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -477,6 +477,54 @@ namespace Revitalize.Framework.Crafting CraftingRecipesByGroup.Add("Anvil", AnvilRecipes); } + //~~~~~~~~~~~~~~~~~~~~~~~// + // Alloy Furnace Recipes // + //~~~~~~~~~~~~~~~~~~~~~~~// + CraftingRecipeBook AlloyFurnaceRecipes = new CraftingRecipeBook("AlloyFurnace"); + AlloyFurnaceRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), true); + + + AlloyFurnaceRecipes.addCraftingRecipe("BrassIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AluminumIngot"),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + },new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BrassIngot"), 1),null, TimeUtilities.GetMinutesFromTime(0, 3, 0)), true)); + + AlloyFurnaceRecipes.addCraftingRecipe("BronzeIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TinIngot"),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 4, 0)), true)); + + AlloyFurnaceRecipes.addCraftingRecipe("SteelIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,1),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 6, 0)), true)); + + AlloyFurnaceRecipes.addCraftingRecipe("ElectrumIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List() { + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.GoldBar,1),1), + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SilverIngot"),1), + new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,5),1) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 4, 0)), true)); + + if (CraftingRecipesByGroup.ContainsKey(AlloyFurnaceRecipes.craftingGroup)) + { + foreach (KeyValuePair recipe in AlloyFurnaceRecipes.craftingRecipes) + { + if (CraftingRecipesByGroup[AlloyFurnaceRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) + { + + } + else + { + CraftingRecipesByGroup[AlloyFurnaceRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book. + } + } + } + else + { + CraftingRecipesByGroup.Add("AlloyFurnace", AlloyFurnaceRecipes); + } } #endregion diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs index 856ac7f2..22905a3c 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipeBook.cs @@ -168,8 +168,7 @@ namespace Revitalize.Framework.Crafting }, new KeyValuePair(ModCore.ObjectManager.resources.getResource("Glass"),1), TimeUtilities.GetMinutesFromTime(0, 1, 0), new StatCost(), false); this.recipesByObjectName["Furnace"].Add("Sand", furnace_glass); - ///Sand recipes here.... - /// + ///Sand recipes here. VanillaRecipe furnace_bauxiteSand = new VanillaRecipe(new Dictionary() { {new StardewValley.Object((int)Enums.SDVObject.Coal,5),1}, diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 248d74f9..9c981377 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -114,7 +114,7 @@ namespace Revitalize.Framework.Menus } else { - this.machine.MinutesUntilReady = this.infoButton.recipe.timeToCraft; + this.machine.containerObject.MinutesUntilReady = this.infoButton.recipe.timeToCraft; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs new file mode 100644 index 00000000..c0156019 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/AlloyFurnace.cs @@ -0,0 +1,262 @@ +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.Objects.InformationFiles; +using Revitalize.Framework.Utilities; +using StardewValley; + +namespace Revitalize.Framework.Objects.Machines +{ + public class AlloyFurnace:Machine + { + + public AlloyFurnace() { } + + public AlloyFurnace(CustomObjectData PyTKData, BasicItemInformation info, List ProducedResources = null, int EnergyRequiredPer10Minutes = 0, int TimeToProduce = 0, bool UpdatesContainer = false, string CraftingBook = "") : 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(); + + } + + public AlloyFurnace(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) + { + 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(); + } + + public AlloyFurnace(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) + { + 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(); + } + + 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); + + if (this.updatesContainerObjectForProduction) + { + //ModCore.log("Update container object for production!"); + //this.MinutesUntilReady -= minutes; + int remaining = minutes; + //ModCore.log("Minutes elapsed: " + remaining); + List energySources = new List(); + if (this.ConsumesEnergy || this.GetEnergyManager().energyInteractionType == Enums.EnergyInteractionType.Storage) + { + //ModCore.log("This machine drains energy: " + this.info.name); + energySources = this.EnergyGraphSearchSources(); //Only grab the network once. + } + if (this.containerObject.MinutesUntilReady > 0) + { + this.containerObject.MinutesUntilReady = Math.Max(0, this.containerObject.MinutesUntilReady - minutes); + + if (this.GetInventoryManager().hasItemsInBuffer && this.containerObject.MinutesUntilReady == 0) + { + this.GetInventoryManager().dumpBufferToItems(); + } + + this.animationManager.playAnimation("Working"); + } + else + { + this.animationManager.playDefaultAnimation(); + } + + 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() + { + AlloyFurnace component = new AlloyFurnace(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); + 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"]; + AlloyFurnace 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"); + + + 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 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/ChargingStation.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs index 6f077f42..9c48e6e1 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/ChargingStation.cs @@ -137,6 +137,20 @@ namespace Revitalize.Framework.Objects.Machines return (ICustomObject)self; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { this.updateInfo(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs index 34b34f28..09a08ca7 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SolarPanel.cs @@ -78,6 +78,22 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration return (ICustomObject)self; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + + + public override void produceEnergy() { if (this.GetEnergyManager().canReceieveEnergy) diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 91f110b5..001e3163 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -306,9 +306,9 @@ namespace Revitalize.Framework.Objects.Machines this.storeEnergyToNetwork(); } } - if (this.MinutesUntilReady > 0) + if (this.containerObject.MinutesUntilReady > 0) { - this.MinutesUntilReady = Math.Max(0, this.MinutesUntilReady - minutes); + this.containerObject.MinutesUntilReady = Math.Max(0, this.MinutesUntilReady - minutes); if (this.GetInventoryManager().hasItemsInBuffer && this.MinutesUntilReady == 0) { @@ -362,7 +362,7 @@ namespace Revitalize.Framework.Objects.Machines if (string.IsNullOrEmpty(this.craftingRecipeBook) == false) { - CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.GetInventoryManager().items, ref this.GetInventoryManager().items, this); + CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.GetInventoryManager().items, ref this.GetInventoryManager().bufferItems, this); machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, false); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs index b5c42139..3cc3ed59 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Wire.cs @@ -87,6 +87,20 @@ namespace Revitalize.Framework.Objects.Machines return (ICustomObject)self; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + this.containerObject.getAdditionalSaveData(); + return saveData; + + } + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { this.updateInfo(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs index 2905a779..f3b4503c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/WireMultiTiledObject.cs @@ -97,6 +97,10 @@ namespace Revitalize.Framework.Objects.Machines return saveData; } + public override void rebuild(Dictionary additionalSaveData, object replacement) + { + base.rebuild(additionalSaveData, replacement); + } public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index 5d83e347..a0a591d8 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -296,6 +296,41 @@ namespace Revitalize.Framework.Objects miningDrillMachine_0_1.animationManager.playAnimation("Mining"); this.AddItem("MiningDrillMachineV1",miningDrillMachine); + MultiTiledObject alloyFurnace = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.AlloyFurnace", TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Alloy Furnace", "Omegasis.Revitalize.Objects.Machines.AlloyFurnace", "Smelts bars into ingots. Works twice as fast as a traditional furnace.", "Machine", Color.SteelBlue, -300, 0, false, 250, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(6, 3, 6), null,null)); + AlloyFurnace alloyFurnace_0_0 = new AlloyFurnace(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.AlloyFurnace", TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), typeof(AlloyFurnace), Color.White, true), new BasicItemInformation("Alloy Furnace", "Omegasis.Revitalize.Objects.Machines.AlloyFurnace", "Smelts bars into ingots. Works twice as fast as a traditional furnace.", "Machine", Color.SteelBlue, -300, 0, false, 250, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new Animation(0, 0, 16, 16), new Dictionary>() + { + {"Default",new List() + { + new Animation(0,0,16,16) + } + }, + {"Working",new List() + { + new Animation(0,32,16,16,30), + new Animation(16,32,16,16,30) + } + } + + },"Default"), Color.White, true, new InventoryManager(6, 3, 6), null, null), null, 0, 0, true, "AlloyFurnace"); + AlloyFurnace alloyFurnace_0_1 = new AlloyFurnace(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.AlloyFurnace", TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), typeof(Machine), Color.White, true), new BasicItemInformation("Alloy Furnace", "Omegasis.Revitalize.Objects.Machines.AlloyFurnace", "Smelts bars into ingots. Works twice as fast as a traditional furnace.", "Machine", Color.SteelBlue, -300, 0, false, 250, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "AlloyFurnace"), new Animation(0, 16, 16, 16), new Dictionary>() + { + {"Default",new List() + { + new Animation(0,16,16,16) + } + }, + {"Working",new List() + { + new Animation(0,48,16,16,30), + new Animation(16,48,16,16,30) + } + } + + }, "Default"), Color.White, false, new InventoryManager(6, 3, 6), null, null), null, 0, 0, false, "AlloyFurnace"); + alloyFurnace.addComponent(new Vector2(0, 0), alloyFurnace_0_0); + alloyFurnace.addComponent(new Vector2(0, 1), alloyFurnace_0_1); + this.AddItem("AlloyFurnace", alloyFurnace); + } private void loadInWires() diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index dd688853..01b0effb 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -145,7 +145,7 @@ namespace Revitalize.Framework.Utilities /// public void restoreModObjects() { - ModCore.log("Restore all mod objects!"); + //ModCore.log("Restore all mod objects!"); //Replace all items in the world. List objsToRestore = new List(); foreach (var v in ModCore.ObjectGroups) @@ -164,7 +164,7 @@ namespace Revitalize.Framework.Utilities //Replace all held items or items in inventories. foreach (GameLocation loc in LocationUtilities.GetAllLocations()) { - ModCore.log("Looking at location: " + loc); + //ModCore.log("Looking at location: " + loc); foreach (StardewValley.Object c in loc.Objects.Values) { if (c is Chest) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index b75b5d4e..ec8c98f2 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -574,7 +574,9 @@ namespace Revitalize new StardewValley.Object((int)Enums.SDVObject.CopperOre,10), ModCore.ObjectManager.GetTool("MiningDrillV1"), ModCore.ObjectManager.GetTool("ChainsawV1"), - ModCore.ObjectManager.GetItem("MiningDrillMachineV1") + ModCore.ObjectManager.GetItem("MiningDrillMachineV1"), + ModCore.ObjectManager.GetItem("AlloyFurnace"), + new StardewValley.Object((int)Enums.SDVObject.IronBar,100), }); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e096132a..2fa41e63 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -162,6 +162,7 @@ +