diff --git a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs index b64af045..1f464231 100644 --- a/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs +++ b/GeneralMods/Revitalize/Framework/Configs/ConfigManager.cs @@ -17,11 +17,13 @@ namespace Revitalize.Framework.Configs public VanillaMachineRecipeConfig vanillaMachineConfig; public Shops_BlacksmithConfig shops_blacksmithConfig; + public FurnitureConfig furnitureConfig; public ConfigManager() { this.vanillaMachineConfig = VanillaMachineRecipeConfig.InitializeConfig(); this.shops_blacksmithConfig = Shops_BlacksmithConfig.InitializeConfig(); + this.furnitureConfig = FurnitureConfig.InitializeConfig(); } } } diff --git a/GeneralMods/Revitalize/Framework/Configs/FurnitureConfig.cs b/GeneralMods/Revitalize/Framework/Configs/FurnitureConfig.cs new file mode 100644 index 00000000..f5263cd6 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Configs/FurnitureConfig.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Configs +{ + /// + /// Deals with config settings for furniture. + /// + public class FurnitureConfig + { + /// + /// How many draw frames should happen between rotating a furniture piece. + /// + public int furnitureFrameRotationDelay; + + /// + /// Constructor. + /// + public FurnitureConfig() + { + this.furnitureFrameRotationDelay = 20; + } + + /// + /// Initializes the config for furniture. + /// + /// + public static FurnitureConfig InitializeConfig() + { + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "FurnitureConfig.json"))) + return ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "FurnitureConfig.json")); + else + { + FurnitureConfig Config = new FurnitureConfig(); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "FurnitureConfig.json"), Config); + return Config; + } + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index b33561f6..387e4f8e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -299,13 +299,13 @@ namespace Revitalize.Framework.Objects MouseState mState = Mouse.GetState(); KeyboardState keyboardState = Game1.GetKeyboardState(); - if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift))) + if (mState.RightButton == ButtonState.Pressed && keyboardState.IsKeyDown(Keys.LeftShift)==false && keyboardState.IsKeyDown(Keys.RightShift)==false) { //ModCore.log("Right clicked!"); return this.rightClicked(who); } - if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))) + if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift)==true || keyboardState.IsKeyDown(Keys.RightShift)==true)) return this.shiftRightClicked(who); return base.checkForAction(who, justCheckingForActivity); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index a436d18d..c58afba3 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -21,8 +21,7 @@ namespace Revitalize.Framework.Objects.Furniture { public ChairInformation furnitureInfo; - - + [JsonIgnore] public override string ItemInfo { get @@ -139,10 +138,17 @@ namespace Revitalize.Framework.Objects.Furniture /// public override bool rightClicked(Farmer who) { - this.containerObject.rotate(); //Ensure that all of the chair pieces rotate at the same time. - - this.checkForSpecialUpSittingAnimation(); - return true; + if (this.framesUntilNextRotation <= 0) + { + this.containerObject.rotate(); //Ensure that all of the chair pieces rotate at the same time. + this.checkForSpecialUpSittingAnimation(); + this.framesUntilNextRotation = ModCore.Configs.furnitureConfig.furnitureFrameRotationDelay; + return true; + } + else + { + return true; + } //return base.rightClicked(who); } @@ -263,6 +269,10 @@ namespace Revitalize.Framework.Objects.Furniture 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?!?!?!?!"); + if (this.framesUntilNextRotation > 0) + this.framesUntilNextRotation--; + if (this.framesUntilNextRotation < 0) this.framesUntilNextRotation = 0; + } else @@ -281,6 +291,9 @@ namespace Revitalize.Framework.Objects.Furniture 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); + if (this.framesUntilNextRotation > 0) + this.framesUntilNextRotation--; + if (this.framesUntilNextRotation < 0) this.framesUntilNextRotation = 0; try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs index 3fd18a89..27665240 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles; using Revitalize.Framework.Objects.InformationFiles.Furniture; @@ -13,6 +14,8 @@ namespace Revitalize.Framework.Objects.Furniture public class FurnitureTileComponent:MultiTiledComponent { + [JsonIgnore] + public int framesUntilNextRotation = 0; public FurnitureTileComponent():base() { diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index 697d3f2b..142f1461 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -20,6 +20,7 @@ namespace Revitalize.Framework.Objects.Furniture public TableInformation furnitureInfo; + [JsonIgnore] public override string ItemInfo { get diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 2a2f7ece..86d946ef 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -450,7 +450,7 @@ namespace Revitalize // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); - //Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); + Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 471373d9..f610310d 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -53,6 +53,7 @@ +