From 89ef844ab3b1e9e25e6065b58bc1c7eeef72ece8 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 9 Oct 2019 00:18:45 -0700 Subject: [PATCH] Fixed crafting not working for player inventory. Fixed machine summary menu crashing when displaying empty tanks. Fixed animaation managers not copying over correctly. --- .../Menus/CraftingMenu/GoldButton.png | Bin 0 -> 244 bytes .../Framework/Crafting/CraftingRecipeBook.cs | 34 ++++++++++++---- .../Revitalize/Framework/Crafting/Recipe.cs | 22 +++++++--- .../Revitalize/Framework/Crafting/StatCost.cs | 8 ++-- .../Objects/Furniture/FurnitureFactory.cs | 3 ++ .../Framework/Managers/ColorManager.cs | 5 +++ .../Menus/CraftingInformationPage.cs | 38 +++++++++++++++--- .../Framework/Menus/CraftingMenuV1.cs | 3 +- .../Menus/Machines/MachineSummaryMenu.cs | 35 ++++++++++------ .../Framework/Objects/BasicItemInformation.cs | 2 +- .../Framework/Objects/CustomObject.cs | 4 +- .../Objects/Furniture/ChairTileComponent.cs | 4 +- .../Machines/EnergyGeneration/SteamBoiler.cs | 4 +- .../Machines/EnergyGeneration/SteamEngine.cs | 4 +- .../Machines/EnergyGeneration/Windmill.cs | 4 +- .../Framework/Objects/ObjectManager.cs | 2 + .../Framework/Utilities/InventoryManager.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 3 -- GeneralMods/Revitalize/Revitalize.csproj | 3 ++ .../Animations/AnimationManager.cs | 34 ++++++++++++++-- .../ComponentsV2/Buttons/AnimatedButton.cs | 2 +- 21 files changed, 161 insertions(+), 57 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/GoldButton.png diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/GoldButton.png b/GeneralMods/Revitalize/Content/Graphics/Menus/CraftingMenu/GoldButton.png new file mode 100644 index 0000000000000000000000000000000000000000..bf04da0ceed3c249b88676151f7e493236993824 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|)_J-(hFJ7o zov@Mjkb!`!JjZ(n-?v>|heA(@BuZ+9t1k&im5fPg5|LDJ-q6f_X@P=zx~o_7j&tST z@9)q5QTp~-Z+hyz>_yofliw}Sopa7mn{Tb>J*@*`4U?ZP5O$iqErh{O;@zf#&wCk4 zFWp|<@J{=i?-BE#9=}*mx$e8qRdDEWkpFcDDer!R-v@jJR~ZRKeJ(T)S;}{jac%() { //Inputs here new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)), true)); - - WorkbenchRecipes.addCraftingRecipe("Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), @@ -332,36 +332,30 @@ namespace Revitalize.Framework.Crafting { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone,20),20), }, new CraftingRecipeComponent(new StardewValley.Tools.WateringCan() { UpgradeLevel = 0 }, 1)), true)); - WorkbenchRecipes.addCraftingRecipe("Copper Wire", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,1),1), }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"),2),null,0),true)); - WorkbenchRecipes.addCraftingRecipe("Alloy Furnace", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Clay,20),10), new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AlloyFurnace"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Sand Box", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 25) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SandBox"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Battery Bin", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"),10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BatteryBin"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Capacitor", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,50),50), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar,10),10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1), null, 0), true)); - WorkbenchRecipes.addCraftingRecipe("Charging Station", new UnlockableCraftingRecipe("Default", new Recipe(new List() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), @@ -370,8 +364,21 @@ namespace Revitalize.Framework.Crafting new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ChargingStation"), 1), null, 0), true)); + WorkbenchRecipes.addCraftingRecipe("Oak Chair", new UnlockableCraftingRecipe("Furniture", new Recipe(new List(),new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Oak Chair"),1),new StatCost(0,0,100,0),0), true)); + if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { + foreach(KeyValuePair pair in WorkbenchRecipes.craftingMenuTabs) + { + if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key)) + { + + } + else + { + CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value); + } + } foreach(KeyValuePair recipe in WorkbenchRecipes.craftingRecipes) { if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) @@ -558,6 +565,17 @@ namespace Revitalize.Framework.Crafting if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { + foreach (KeyValuePair pair in AnvilRecipes.craftingMenuTabs) + { + if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key)) + { + + } + else + { + CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value); + } + } foreach (KeyValuePair recipe in AnvilRecipes.craftingRecipes) { if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index af8db6e5..4e636f29 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -58,7 +58,7 @@ namespace Revitalize.Framework.Crafting { output }; - this.statCost = StatCost ?? new StatCost(); + this.statCost = StatCost; this.timeToCraft = TimeToCraft; } @@ -68,7 +68,7 @@ namespace Revitalize.Framework.Crafting this.outputs = outputs; this.outputName = OutputName; this.outputDescription = OutputDescription; - this.statCost = StatCost ?? new StatCost(); + this.statCost = StatCost; this.timeToCraft = TimeToCraft; } @@ -87,6 +87,7 @@ namespace Revitalize.Framework.Crafting /// Checks if an inventory contains all items. public bool InventoryContainsAllIngredient(IList items) { + if (this.ingredients.Count == 0) return true; foreach (CraftingRecipeComponent pair in this.ingredients) if (!this.InventoryContainsIngredient(items, pair)) return false; return true; @@ -176,7 +177,7 @@ namespace Revitalize.Framework.Crafting /// Checks to see if the invventory is the player's public void craft(ref IList from, ref IList to, bool dropToGround = false, bool isPlayerInventory = false) { - InventoryManager manager = new InventoryManager(to); + InventoryManager manager = new InventoryManager(to,Game1.player.MaxItems); if (manager.ItemCount + this.outputs.Count >= manager.capacity) { if (isPlayerInventory) @@ -198,7 +199,11 @@ namespace Revitalize.Framework.Crafting Game1.player.Items = playerItems; //Set the items to be post consumption. foreach (Item I in outPutItems) - Game1.player.addItemToInventory(I); //Add all items produced. + { + Item copy = I.getOne(); + copy.Stack = I.Stack; + Game1.player.addItemToInventory(copy); //Add all items produced. + } this.statCost.payCost(); } @@ -209,7 +214,14 @@ namespace Revitalize.Framework.Crafting public bool CanCraft(IList items) { - return this.InventoryContainsAllIngredient(items); + if (this.statCost == null) + { + return this.InventoryContainsAllIngredient(items); + } + else + { + return this.InventoryContainsAllIngredient(items) && this.statCost.canSafelyAffordCost(); + } } } } diff --git a/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs b/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs index 4ab07ed6..8711b04c 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/StatCost.cs @@ -9,10 +9,10 @@ namespace Revitalize.Framework.Crafting { public class StatCost { - int health; - int stamina; - int magic; - int gold; + public int health; + public int stamina; + public int magic; + public int gold; public StatCost(int Stamina = 0, int Health = 0, int Gold = 0, int Magic = 0){ this.stamina = Stamina; diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs index 48dcb19e..d756cea4 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs @@ -325,6 +325,7 @@ namespace Revitalize.Framework.Factories.Objects foreach (var v in chairObjects) { ModCore.ObjectManager.chairs.Add(v.Value.info.id, v.Value); + ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value); } } } @@ -406,6 +407,7 @@ namespace Revitalize.Framework.Factories.Objects foreach (var v in chairObjects) { ModCore.ObjectManager.tables.Add(v.Value.info.id, v.Value); + ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value); } } } @@ -488,6 +490,7 @@ namespace Revitalize.Framework.Factories.Objects foreach (var v in chairObjects) { ModCore.ObjectManager.furnitureStorage.Add(v.Value.info.id, v.Value); + ModCore.ObjectManager.AddItem(v.Value.info.name, v.Value); } } } diff --git a/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs b/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs index e13265b4..e5de6a95 100644 --- a/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs +++ b/GeneralMods/Revitalize/Framework/Managers/ColorManager.cs @@ -98,5 +98,10 @@ namespace Revitalize.Framework.Managers return self; } + + public ColorManager Copy() + { + return new ColorManager(this._blendInfluence, this._colorMixMode); + } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 5ad31b26..7f4901a7 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -34,6 +34,7 @@ namespace Revitalize.Framework.Menus private Dictionary requiredItems; public AnimatedButton craftingButton; + public AnimatedButton goldButton; public bool isPlayerInventory; @@ -70,6 +71,14 @@ namespace Revitalize.Framework.Menus } this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f); this.outputInventory = this.inventory; + + if (this.infoButton.recipe.statCost != null) + { + if (this.infoButton.recipe.statCost.gold > 0) + { + this.goldButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("GoldButton", this.getMoneyRequiredOffset(), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "GoldButton"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + } } public CraftingInformationPage(int x, int y, int width, int height, Color BackgroundColor, CraftingRecipeButton ItemToDisplay, ref IList Inventory,ref IList OutputInventory ,bool IsPlayerInventory, Machine Machine) : base(x, y, width, height, false) @@ -92,6 +101,13 @@ namespace Revitalize.Framework.Menus { this.outputInventory = this.inventory; } + if (this.infoButton.recipe.statCost != null) + { + if (this.infoButton.recipe.statCost.gold > 0) + { + this.goldButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("GoldButton", this.getMoneyRequiredOffset(), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "GoldButton"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); + } + } this.outputInventory = OutputInventory; this.machine = Machine; } @@ -104,7 +120,15 @@ namespace Revitalize.Framework.Menus { Game1.soundBank.PlayCue("coin"); - this.infoButton.craftItem(this.inventory, this.outputInventory); + if (this.isPlayerInventory) + { + this.infoButton.craftItem(); + } + else + { + this.infoButton.craftItem(this.inventory, this.outputInventory); + + } if (this.machine != null) { if (this.infoButton.recipe.timeToCraft == 0) @@ -177,9 +201,13 @@ namespace Revitalize.Framework.Menus button.Key.draw(b); b.DrawString(Game1.smallFont, button.Key.item.DisplayName+ " x "+button.Value.ToString(), button.Key.Position + new Vector2(64, 16), this.getNameColor(button.Key.item, button.Value)); } + if (this.goldButton != null) + { + this.goldButton.draw(b); + b.DrawString(Game1.smallFont, this.infoButton.recipe.statCost.gold+" G", this.goldButton.Position +new Vector2(0,32),Color.Black); + } this.craftingButton.draw(b, this.getCraftableColor().A); - this.drawMouse(b); } @@ -264,11 +292,9 @@ namespace Revitalize.Framework.Menus /// Gets the height position for where to draw a required ingredient. /// /// - private Vector2 getIngredientHeightOffset() + private Vector2 getMoneyRequiredOffset() { - string parsedDescription = Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width); - Vector2 offset=Game1.smallFont.MeasureString(parsedDescription); - return this.getItemDescriptionOffset()+offset+ new Vector2(0,64*(this.requiredItems.Count)); + return new Vector2(this.xPositionOnScreen+64+this.width,this.yPositionOnScreen+128); } private float getCraftingButtonHeight() diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 0b43795a..390e3c29 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -263,7 +263,8 @@ namespace Revitalize.Framework.Menus } else { - Vector2 newPos = new Vector2(100 + (48), this.yPositionOnScreen + (24 * 4) * (count + 1)); + Vector2 newPos = new Vector2(100 + (48), (this.yPositionOnScreen+24) + ((24 * 4) * (count + 1))); + ModCore.log("newPos: " + newPos.ToString()); Button.Position = newPos; this.CraftingTabs.Add(name, Button); this.craftingItemsToDisplay.Add(name, new List()); diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs index ea6edb15..1f5893e6 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineSummaryMenu.cs @@ -144,30 +144,40 @@ namespace Revitalize.Framework.Menus.Machines if (this.objectSource.info.fluidManager.InteractsWithFluids) { - if (this.inputFluidTank1Button.containsPoint(x, y)) + if (this.inputFluidTank1Button != null) { - if (this.objectSource.info.fluidManager.inputTank1.capacity > 0) + if (this.inputFluidTank1Button.containsPoint(x, y)) { - this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(); - hovered = true; + if (this.objectSource.info.fluidManager.inputTank1.capacity > 0) + { + this.hoverText = "Input Tank 1: " + this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(); + hovered = true; + } } } - if (this.inputFluidTank2Button.containsPoint(x, y)) + if (this.inputFluidTank2Button != null) { - if (this.objectSource.info.fluidManager.inputTank2.capacity > 0) + if (this.inputFluidTank2Button.containsPoint(x, y)) { - this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(); - hovered = true; + if (this.objectSource.info.fluidManager.inputTank2.capacity > 0) + { + this.hoverText = "Input Tank 2: " + this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(); + hovered = true; + } } + } - if (this.outputFluidTankButton.containsPoint(x, y)) + if (this.outputFluidTankButton != null) { - if (this.objectSource.info.fluidManager.outputTank.capacity > 0) + if (this.outputFluidTankButton.containsPoint(x, y)) { - this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(); - hovered = true; + if (this.objectSource.info.fluidManager.outputTank.capacity > 0) + { + this.hoverText = "Output Tank: " + this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(); + hovered = true; + } } } } @@ -187,7 +197,6 @@ namespace Revitalize.Framework.Menus.Machines } else if (this.energy.producesEnergy) { - return "Produces " + EnergyAmount + " energy per 10 minutes."; } else return ""; diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 08e5f5b5..8de795e3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -451,7 +451,7 @@ namespace Revitalize.Framework.Objects /// public BasicItemInformation Copy() { - return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager,this.fluidManager.Copy()); + return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager.Copy(), this.DrawColor, this.ignoreBoundingBox, this.inventory.Copy(), this._lightManager.Copy(),this.EnergyManager.Copy(),this.AlwaysDrawAbovePlayer,this.DyedColor,this.ColorManager,this.fluidManager.Copy()); } public bool requiresSyncUpdate() diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index ecce4bb7..60a4f39b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -440,7 +440,8 @@ namespace Revitalize.Framework.Objects if (this.info.animationManager.animations.ContainsKey(this.generateRotationalAnimationKey())) { - this.info.animationManager.setAnimation(this.generateRotationalAnimationKey()); + this.info.animationManager.enabled = true; + this.info.animationManager.playAnimation(this.generateRotationalAnimationKey()); } else { @@ -451,6 +452,7 @@ namespace Revitalize.Framework.Objects public string generateRotationalAnimationKey() { + if (string.IsNullOrEmpty(this.info.animationManager.currentAnimationName)) return this.generateDefaultRotationalAnimationKey(); return (this.info.animationManager.currentAnimationName.Split('_')[0]) + "_" + (int)this.info.facingDirection; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index 93e2581e..217cb95b 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -180,8 +180,8 @@ namespace Revitalize.Framework.Objects.Furniture public override Item getOne() { ChairTileComponent component = new ChairTileComponent(this.data,this.info.Copy(), (ChairInformation)this.furnitureInfo); - component.containerObject = this.containerObject; - component.offsetKey = this.offsetKey; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs index c9ce4bfa..4e4ca65a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamBoiler.cs @@ -124,8 +124,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration public override Item getOne() { SteamBoiler component = new SteamBoiler(this.data, this.info.Copy(), this.producedResources, this.energyRequiredPer10Minutes, this.timeToProduce, this.updatesContainerObjectForProduction, this.craftingRecipeBook); - component.containerObject = this.containerObject; - component.offsetKey = this.offsetKey; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs index 26d0d1ab..1c553686 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/SteamEngine.cs @@ -140,8 +140,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration 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; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs index 1a1cbd6a..e9c2fb62 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/EnergyGeneration/Windmill.cs @@ -121,8 +121,8 @@ namespace Revitalize.Framework.Objects.Machines.EnergyGeneration 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; + //component.containerObject = this.containerObject; + //component.offsetKey = this.offsetKey; return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index f6ee11db..08072839 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Revitalize.Framework.Factories.Objects; using Revitalize.Framework.Illuminate; using Revitalize.Framework.Objects.CraftingTables; using Revitalize.Framework.Objects.Extras; @@ -116,6 +117,7 @@ namespace Revitalize.Framework.Objects this.loadInMachines(); this.loadInTools(); this.loadInAestheticsObjects(); + FurnitureFactory.LoadFurnitureFiles(); } private void loadInAestheticsObjects() diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index f8c9e128..5e2dc2d5 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -64,9 +64,9 @@ namespace Revitalize.Framework.Utilities this.displayColumns = DisplayColumns; } - public InventoryManager(IList items, int DisplayRows = 6, int DisplayColumns = 6) + public InventoryManager(IList items, int Capacity= int.MaxValue, int DisplayRows = 6, int DisplayColumns = 6) { - this.capacity = int.MaxValue; + this.capacity = Capacity; this.setMaxLimit(int.MaxValue); this.items = items; this.bufferItems = new List(); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index b47bed7f..922c5a9a 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -490,9 +490,6 @@ namespace Revitalize ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Rugs.RugTest", rug); - - FurnitureFactory.LoadFurnitureFiles(); - SeasideScramble sscGame = new SeasideScramble(); ArcadeCabinetTile ssc1 = new ArcadeCabinetTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), typeof(ArcadeCabinetTile), Color.White), new BasicItemInformation("Seaside Scramble Arcade Game", "Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", "A arcade to play Seaside Scramble!", "Arcades", Color.LimeGreen, -300, 0, false, 100, true, true, TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new Animation(new Rectangle(0, 0, 16, 16)), new Dictionary>() { diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b9ab7842..bc7a392e 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -412,6 +412,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index 5d220c48..5a37d561 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -29,6 +29,8 @@ namespace StardustCore.Animations public bool hasRecievedUpdateTick; + public string startingAnimationName; + /// /// Checks to see if there is an animation playing. /// @@ -57,6 +59,7 @@ namespace StardustCore.Animations this.currentAnimation = this.defaultDrawFrame; this.currentAnimationName = ""; this.animationDataString = ""; + this.startingAnimationName = ""; } public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, string animationString, string startingAnimationKey, int startingAnimationFrame = 0, bool EnabledByDefault = true) @@ -68,6 +71,7 @@ namespace StardustCore.Animations this.animationDataString = animationString; this.animations = parseAnimationsFromXNB(animationString); + this.startingAnimationName = startingAnimationKey; if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) this.setAnimation(startingAnimationKey, startingAnimationFrame); else @@ -85,12 +89,29 @@ namespace StardustCore.Animations this.enabled = EnabledByDefault; this.animations = animationString; - if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + this.startingAnimationName = startingAnimationKey; + if (this.animations != null) { - this.setAnimation(startingAnimationKey, startingAnimationFrame); - this.playAnimation(startingAnimationKey, true, startingAnimationFrame); - } + if (string.IsNullOrEmpty(startingAnimationKey) == false) + { + if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + { + this.setAnimation(startingAnimationKey, startingAnimationFrame); + this.playAnimation(startingAnimationKey, true, startingAnimationFrame); + } + else + { + this.currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + } + } + else + { + this.currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + } + } else { this.currentAnimation = this.defaultDrawFrame; @@ -485,5 +506,10 @@ namespace StardustCore.Animations { return this.objectTexture.getTexture(); } + + public AnimationManager Copy() + { + return new AnimationManager(this.objectTexture, this.defaultDrawFrame, this.animations, this.startingAnimationName, 0, this.enabled); + } } } diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs index a86159c7..ffd68198 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs @@ -17,7 +17,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// /// The default bounds for the button. /// - private Rectangle defaultBounds; + public Rectangle defaultBounds; /// /// The actual bounds for the button which takes scale into acount. ///