Fixed ignoring bounding boxes from letting you pick up items again.
This commit is contained in:
parent
c8a1ce8e86
commit
7eaaa44910
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using PyTK.CustomElementHandler;
|
||||
using StardewValley;
|
||||
using StardewValley.Objects;
|
||||
|
@ -113,5 +114,35 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
return base.canBePlacedHere(l, tile);
|
||||
}
|
||||
|
||||
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
||||
{
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
if (!this.isPlaceable())
|
||||
return;
|
||||
int x = Game1.getOldMouseX() + Game1.viewport.X + (int)((pair.Value as MultiTiledComponent).offsetKey.X * Game1.tileSize);
|
||||
int y = Game1.getOldMouseY() + Game1.viewport.Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y * Game1.tileSize);
|
||||
if ((double)Game1.mouseCursorTransparency == 0.0)
|
||||
{
|
||||
x = ((int)Game1.player.GetGrabTile().X + (int)((pair.Value as MultiTiledComponent).offsetKey.X)) * 64;
|
||||
y = ((int)Game1.player.GetGrabTile().Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y)) * 64;
|
||||
}
|
||||
if (Game1.player.GetGrabTile().Equals(Game1.player.getTileLocation()) && (double)Game1.mouseCursorTransparency == 0.0)
|
||||
{
|
||||
Vector2 translatedVector2 = Utility.getTranslatedVector2(Game1.player.GetGrabTile(), Game1.player.FacingDirection, 1f);
|
||||
translatedVector2 += (pair.Value as MultiTiledComponent).offsetKey;
|
||||
x = (int)translatedVector2.X * 64;
|
||||
y = (int)translatedVector2.Y * 64;
|
||||
}
|
||||
bool flag = (pair.Value as MultiTiledComponent).canBePlacedHere(location, new Vector2(x / Game1.tileSize, y / Game1.tileSize));
|
||||
spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f);
|
||||
|
||||
|
||||
(pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f);
|
||||
//break;
|
||||
//this.draw(spriteBatch, x / 64, y / 64, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using PyTK.CustomElementHandler;
|
||||
using Revitalize.Framework.Objects.InformationFiles.Furniture;
|
||||
using StardewValley;
|
||||
|
@ -147,5 +148,75 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>What happens when the object is drawn at a tile location.</summary>
|
||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||
{
|
||||
/*
|
||||
if (this.info.ignoreBoundingBox == true)
|
||||
{
|
||||
x *= -1;
|
||||
y *= -1;
|
||||
}
|
||||
*/
|
||||
|
||||
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);
|
||||
try
|
||||
{
|
||||
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 drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
|
||||
{
|
||||
if (objectPosition.X < 0) objectPosition.X *= -1;
|
||||
if (objectPosition.Y < 0) objectPosition.Y *= -1;
|
||||
base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,17 +37,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
/// </summary>
|
||||
public override void rotate()
|
||||
{
|
||||
Revitalize.ModCore.log("Rotate!");
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
(pair.Value as RugTileComponent).rotate();
|
||||
}
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
(pair.Value as RugTileComponent).checkForSpecialUpSittingAnimation();
|
||||
}
|
||||
|
||||
base.rotate();
|
||||
|
||||
}
|
||||
|
||||
public override Item getOne()
|
||||
|
|
|
@ -89,31 +89,16 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///Used to manage graphics for chairs that need to deal with special "layering" for transparent chair backs. Otherwise the player would be hidden.
|
||||
/// </summary>
|
||||
public void checkForSpecialUpSittingAnimation()
|
||||
{
|
||||
if (this.info.facingDirection == Enums.Direction.Up && Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject)
|
||||
{
|
||||
string animationKey = "Sitting_" + (int)Enums.Direction.Up;
|
||||
if (this.animationManager.animations.ContainsKey(animationKey))
|
||||
{
|
||||
this.animationManager.setAnimation(animationKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>What happens when the object is drawn at a tile location.</summary>
|
||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||
{
|
||||
/*
|
||||
if (this.info.ignoreBoundingBox == true)
|
||||
{
|
||||
x *= -1;
|
||||
y *= -1;
|
||||
}
|
||||
|
||||
*/
|
||||
if (this.info == null)
|
||||
{
|
||||
Revitalize.ModCore.log("info is null");
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using PyTK.CustomElementHandler;
|
||||
using StardewValley;
|
||||
|
||||
|
@ -98,5 +99,35 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
return base.canBePlacedHere(l, tile);
|
||||
}
|
||||
|
||||
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
||||
{
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
if (!this.isPlaceable())
|
||||
return;
|
||||
int x = Game1.getOldMouseX() + Game1.viewport.X + (int)((pair.Value as MultiTiledComponent).offsetKey.X * Game1.tileSize);
|
||||
int y = Game1.getOldMouseY() + Game1.viewport.Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y * Game1.tileSize);
|
||||
if ((double)Game1.mouseCursorTransparency == 0.0)
|
||||
{
|
||||
x = ((int)Game1.player.GetGrabTile().X + (int)((pair.Value as MultiTiledComponent).offsetKey.X)) * 64;
|
||||
y = ((int)Game1.player.GetGrabTile().Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y)) * 64;
|
||||
}
|
||||
if (Game1.player.GetGrabTile().Equals(Game1.player.getTileLocation()) && (double)Game1.mouseCursorTransparency == 0.0)
|
||||
{
|
||||
Vector2 translatedVector2 = Utility.getTranslatedVector2(Game1.player.GetGrabTile(), Game1.player.FacingDirection, 1f);
|
||||
translatedVector2 += (pair.Value as MultiTiledComponent).offsetKey;
|
||||
x = (int)translatedVector2.X * 64;
|
||||
y = (int)translatedVector2.Y * 64;
|
||||
}
|
||||
bool flag = (pair.Value as MultiTiledComponent).canBePlacedHere(location, new Vector2(x / Game1.tileSize, y / Game1.tileSize));
|
||||
spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f);
|
||||
|
||||
|
||||
(pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f);
|
||||
//break;
|
||||
//this.draw(spriteBatch, x / 64, y / 64, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using PyTK.CustomElementHandler;
|
||||
using Revitalize.Framework.Objects.InformationFiles.Furniture;
|
||||
using StardewValley;
|
||||
|
@ -103,5 +104,66 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
return saveData;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>What happens when the object is drawn at a tile location.</summary>
|
||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||
{
|
||||
/*
|
||||
if (this.info.ignoreBoundingBox == true)
|
||||
{
|
||||
x *= -1;
|
||||
y *= -1;
|
||||
}
|
||||
*/
|
||||
|
||||
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);
|
||||
try
|
||||
{
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,6 +196,7 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
/*
|
||||
if ((pair.Value as CustomObject).info.ignoreBoundingBox)
|
||||
{
|
||||
pair.Value.placementAction(location, -1 * (x + (int)pair.Key.X * Game1.tileSize), -1 * (y + (int)pair.Key.Y * Game1.tileSize), who);
|
||||
|
@ -203,7 +204,8 @@ namespace Revitalize.Framework.Objects
|
|||
else
|
||||
{
|
||||
pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who);
|
||||
}
|
||||
}*/
|
||||
pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who);
|
||||
//ModCore.log(pair.Value.TileLocation);
|
||||
}
|
||||
this.location = location;
|
||||
|
|
|
@ -22,14 +22,15 @@ namespace Revitalize
|
|||
{
|
||||
// TODO:
|
||||
//
|
||||
//
|
||||
// -Multiple Lights On Object
|
||||
// -Illumination Colors
|
||||
// Furniture:
|
||||
// -rugs
|
||||
// -rugs (WIP but buggy for clicking)
|
||||
// -tables
|
||||
// -lamps
|
||||
// -chairs (done)
|
||||
// -benches
|
||||
// -benches (done but needs factory info/sprite)
|
||||
// -dressers/other storage containers
|
||||
// -fun interactables
|
||||
// -More crafting tables
|
||||
|
|
Loading…
Reference in New Issue