Fixed chairs rotating too fast and allowed them to use shift-left click instead for sitting.

This commit is contained in:
JoshuaNavarro 2019-08-31 12:08:52 -07:00
parent 2dab29c6ba
commit 5be5222b19
8 changed files with 74 additions and 9 deletions

View File

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

View File

@ -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
{
/// <summary>
/// Deals with config settings for furniture.
/// </summary>
public class FurnitureConfig
{
/// <summary>
/// How many draw frames should happen between rotating a furniture piece.
/// </summary>
public int furnitureFrameRotationDelay;
/// <summary>
/// Constructor.
/// </summary>
public FurnitureConfig()
{
this.furnitureFrameRotationDelay = 20;
}
/// <summary>
/// Initializes the config for furniture.
/// </summary>
/// <returns></returns>
public static FurnitureConfig InitializeConfig()
{
if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "FurnitureConfig.json")))
return ModCore.ModHelper.Data.ReadJsonFile<FurnitureConfig>(Path.Combine("Configs", "FurnitureConfig.json"));
else
{
FurnitureConfig Config = new FurnitureConfig();
ModCore.ModHelper.Data.WriteJsonFile<FurnitureConfig>(Path.Combine("Configs", "FurnitureConfig.json"), Config);
return Config;
}
}
}
}

View File

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

View File

@ -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
/// <returns></returns>
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();

View File

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

View File

@ -20,6 +20,7 @@ namespace Revitalize.Framework.Objects.Furniture
public TableInformation furnitureInfo;
[JsonIgnore]
public override string ItemInfo
{
get

View File

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

View File

@ -53,6 +53,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Framework\Configs\ConfigManager.cs" />
<Compile Include="Framework\Configs\FurnitureConfig.cs" />
<Compile Include="Framework\Configs\Shops_BlacksmithConfig.cs" />
<Compile Include="Framework\Configs\VanillaMachineRecipeConfig.cs" />
<Compile Include="Framework\Crafting\Recipe.cs" />