Created functionality for bag of holding. todo:art and stuff
This commit is contained in:
parent
d42d4dcb98
commit
0fbe85375b
|
@ -285,7 +285,7 @@ namespace Revitalize
|
|||
{
|
||||
// System.Threading.Thread.Sleep(1);
|
||||
|
||||
Game1.activeClickableMenu = new Revitalize.Menus.GameMenu();
|
||||
// Game1.activeClickableMenu = new Revitalize.Menus.GameMenu();
|
||||
}
|
||||
gametick = false;
|
||||
|
||||
|
@ -294,7 +294,12 @@ namespace Revitalize
|
|||
|
||||
private void ShopCall(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
||||
{
|
||||
// Game1.currentSeason = "spring";
|
||||
if (e.KeyPressed.ToString() == "J")
|
||||
{
|
||||
Log.AsyncC("Mouse Position " + Game1.getMousePosition());
|
||||
}
|
||||
|
||||
// Game1.currentSeason = "spring";
|
||||
Game1.player.money = 9999;
|
||||
// Log.AsyncG(Game1.tileSize);
|
||||
|
||||
|
@ -309,7 +314,7 @@ namespace Revitalize
|
|||
TextureDataNode font;
|
||||
Dictionaries.spriteFontList.TryGetValue("0", out font);
|
||||
objShopList.Add(new SpriteFontObject(0, Vector2.Zero, font.path, Color.White));
|
||||
|
||||
objShopList.Add(new Magic.Alchemy.Objects.BagofHolding(0, Vector2.Zero, new List<Item>(),3, Color.White));
|
||||
// objShopList.Add(new Spawner(3, Vector2.Zero, 9));
|
||||
objShopList.Add(new Light(0, Vector2.Zero, LightColors.Aquamarine,LightColors.Aquamarine,false));
|
||||
objShopList.Add(new Quarry(3, Vector2.Zero,9,"copper"));
|
||||
|
|
|
@ -0,0 +1,933 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Revitalize.Resources;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Locations;
|
||||
using StardewValley.Menus;
|
||||
using StardewValley.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Revitalize.Magic.Alchemy.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Original Stardew Furniture Class but rewritten to be placed anywhere.
|
||||
/// </summary>
|
||||
public class BagofHolding : CoreObject
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public new bool flipped;
|
||||
|
||||
[XmlIgnore]
|
||||
public bool flaggedForPickUp;
|
||||
|
||||
private bool lightGlowAdded;
|
||||
|
||||
public string texturePath;
|
||||
|
||||
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public BagofHolding()
|
||||
{
|
||||
this.updateDrawPosition();
|
||||
}
|
||||
|
||||
public BagofHolding(bool f)
|
||||
{
|
||||
//does nothng
|
||||
}
|
||||
|
||||
public BagofHolding(int which, Vector2 tile, List<Item> Inventory,int InventorySize, Color DrawColor)
|
||||
{
|
||||
which = 0;
|
||||
|
||||
this.drawColor = DrawColor;
|
||||
this.tileLocation = tile;
|
||||
this.inventory = new List<Item>();
|
||||
this.InitializeBasics(0, tile);
|
||||
|
||||
|
||||
this.inventory = Inventory;
|
||||
this.inventoryMaxSize = InventorySize;
|
||||
this.inventory.Capacity = inventoryMaxSize;
|
||||
if (TextureSheet == null)
|
||||
{
|
||||
TextureSheet = Game1.content.Load<Texture2D>(Path.Combine("Revitalize", "CropsNSeeds", "Graphics", "seeds"));
|
||||
texturePath = Path.Combine("Revitalize","CropsNSeeds","Graphics","seeds");
|
||||
}
|
||||
Dictionary<int, string> dictionary = Game1.content.Load<Dictionary<int, string>>("Data\\Furniture");
|
||||
string[] array = dictionary[which].Split(new char[]
|
||||
{
|
||||
'/'
|
||||
});
|
||||
this.name = array[0];
|
||||
this.Decoration_type = this.getTypeNumberFromName(array[1]);
|
||||
this.description = "A bag of holding that can store many objects!";
|
||||
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1);
|
||||
if (array[2].Equals("-1"))
|
||||
{
|
||||
this.sourceRect = this.getDefaultSourceRectForType(which, this.Decoration_type);
|
||||
this.defaultSourceRect = this.sourceRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[]
|
||||
{
|
||||
' '
|
||||
})[0]);
|
||||
this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[]
|
||||
{
|
||||
' '
|
||||
})[1]);
|
||||
this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
|
||||
this.defaultSourceRect = this.sourceRect;
|
||||
}
|
||||
this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1);
|
||||
if (array[3].Equals("-1"))
|
||||
{
|
||||
this.boundingBox = this.getDefaultBoundingBoxForType(this.Decoration_type);
|
||||
this.defaultBoundingBox = this.boundingBox;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[]
|
||||
{
|
||||
' '
|
||||
})[0]);
|
||||
this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[]
|
||||
{
|
||||
' '
|
||||
})[1]);
|
||||
this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
|
||||
this.defaultBoundingBox = this.boundingBox;
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
this.rotations = Convert.ToInt32(array[4]);
|
||||
this.price = Convert.ToInt32(array[5]);
|
||||
this.parentSheetIndex = which;
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public override bool performDropDownAction(Farmer who)
|
||||
{
|
||||
this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void hoverAction()
|
||||
{
|
||||
base.hoverAction();
|
||||
if (!Game1.player.isInventoryFull())
|
||||
{
|
||||
Game1.mouseCursor = 2;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
|
||||
{
|
||||
var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
|
||||
if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
|
||||
{
|
||||
// Game1.showRedMessage("YOOO");
|
||||
//do some stuff when the right button is down
|
||||
// Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(this.inventory);
|
||||
// rotate();
|
||||
this.openBag();
|
||||
Game1.playSound("coin");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Game1.showRedMessage("CRY");
|
||||
}
|
||||
|
||||
if (justCheckingForActivity)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.clicked(who);
|
||||
}
|
||||
|
||||
public override bool clicked(Farmer who)
|
||||
{
|
||||
|
||||
// Game1.showRedMessage("THIS IS CLICKED!!!");
|
||||
Game1.haltAfterCheck = false;
|
||||
if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null)
|
||||
{
|
||||
// Game1.showRedMessage("Why1?");
|
||||
return false;
|
||||
}
|
||||
if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is BagofHolding)))
|
||||
{
|
||||
if (Game1.player.currentLocation is FarmHouse)
|
||||
{
|
||||
// Game1.showRedMessage("Why2?");
|
||||
//this.heldObject = new BagofHolding(parentSheetIndex, Vector2.Zero);
|
||||
Util.addItemToInventoryAndCleanTrackedList(this);
|
||||
this.flaggedForPickUp = true;
|
||||
this.thisLocation = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// return true;
|
||||
|
||||
this.flaggedForPickUp = true;
|
||||
if (this is TV)
|
||||
{
|
||||
this.heldObject = new TV(parentSheetIndex, Vector2.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
// this.heldObject = new BagofHolding(parentSheetIndex, Vector2.Zero);
|
||||
Util.addItemToInventoryAndCleanTrackedList(this);
|
||||
// this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
|
||||
// this.heldObject = null;
|
||||
Game1.playSound("coin");
|
||||
this.thisLocation = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false))
|
||||
{
|
||||
// Game1.showRedMessage("Why3?");
|
||||
this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
|
||||
this.heldObject = null;
|
||||
Util.addItemToInventoryAndCleanTrackedList(this);
|
||||
Game1.playSound("coin");
|
||||
this.thisLocation = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void DayUpdate(GameLocation location)
|
||||
{
|
||||
base.DayUpdate(location);
|
||||
this.lightGlowAdded = false;
|
||||
if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining))
|
||||
{
|
||||
this.removeLights(location);
|
||||
return;
|
||||
}
|
||||
this.addLights(location);
|
||||
}
|
||||
|
||||
public void resetOnPlayerEntry(GameLocation environment)
|
||||
{
|
||||
this.removeLights(environment);
|
||||
if (Game1.isDarkOut())
|
||||
{
|
||||
this.addLights(environment);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, Farmer who)
|
||||
{
|
||||
if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is BagofHolding) || ((dropIn as BagofHolding).getTilesWide() == 1 && (dropIn as BagofHolding).getTilesHigh() == 1)))
|
||||
{
|
||||
this.heldObject = (StardewValley.Object)dropIn.getOne();
|
||||
this.heldObject.tileLocation = this.tileLocation;
|
||||
this.heldObject.boundingBox.X = this.boundingBox.X;
|
||||
this.heldObject.boundingBox.Y = this.boundingBox.Y;
|
||||
// Log.AsyncO(getDefaultBoundingBoxForType((dropIn as BagofHolding).Decoration_type));
|
||||
this.heldObject.performDropDownAction(who);
|
||||
if (!probe)
|
||||
{
|
||||
Game1.playSound("woodyStep");
|
||||
// Log.AsyncC("HUH?");
|
||||
if (who != null)
|
||||
{
|
||||
who.reduceActiveItemByOne();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addLights(GameLocation environment)
|
||||
{
|
||||
// this.lightSource.lightTexture = Game1.content.Load<Texture2D>("LooseSprites\\Lighting\\lantern");
|
||||
|
||||
if (this.Decoration_type == 7)
|
||||
{
|
||||
if (this.sourceIndexOffset == 0)
|
||||
{
|
||||
this.sourceRect = this.defaultSourceRect;
|
||||
this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width;
|
||||
}
|
||||
this.sourceIndexOffset = 1;
|
||||
if (this.lightSource == null)
|
||||
{
|
||||
Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, Color.Black, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
Game1.currentLightSources.Add(this.lightSource);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (this.Decoration_type == 13)
|
||||
{
|
||||
if (this.sourceIndexOffset == 0)
|
||||
{
|
||||
this.sourceRect = this.defaultSourceRect;
|
||||
this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width;
|
||||
}
|
||||
this.sourceIndexOffset = 1;
|
||||
if (this.lightGlowAdded)
|
||||
{
|
||||
environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)));
|
||||
this.lightGlowAdded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLights(GameLocation environment)
|
||||
{
|
||||
if (this.Decoration_type == 7)
|
||||
{
|
||||
if (this.sourceIndexOffset == 1)
|
||||
{
|
||||
this.sourceRect = this.defaultSourceRect;
|
||||
}
|
||||
this.sourceIndexOffset = 0;
|
||||
Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
this.lightSource = null;
|
||||
return;
|
||||
}
|
||||
if (this.Decoration_type == 13)
|
||||
{
|
||||
if (this.sourceIndexOffset == 1)
|
||||
{
|
||||
this.sourceRect = this.defaultSourceRect;
|
||||
}
|
||||
this.sourceIndexOffset = 0;
|
||||
if (Game1.isRaining)
|
||||
{
|
||||
this.sourceRect = this.defaultSourceRect;
|
||||
this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width;
|
||||
this.sourceIndexOffset = 1;
|
||||
return;
|
||||
}
|
||||
if (!this.lightGlowAdded && !environment.lightGlows.Contains(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))))
|
||||
{
|
||||
environment.lightGlows.Add(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)));
|
||||
}
|
||||
this.lightGlowAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool minutesElapsed(int minutes, GameLocation environment)
|
||||
{
|
||||
if (Game1.isDarkOut())
|
||||
{
|
||||
this.addLights(environment);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.removeLights(environment);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void performRemoveAction(Vector2 tileLocation, GameLocation environment)
|
||||
{
|
||||
this.removeLights(environment);
|
||||
if (this.Decoration_type == 13 && this.lightGlowAdded)
|
||||
{
|
||||
environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)));
|
||||
this.lightGlowAdded = false;
|
||||
}
|
||||
base.performRemoveAction(tileLocation, environment);
|
||||
}
|
||||
|
||||
|
||||
public override bool canBeGivenAsGift()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
||||
{
|
||||
if ((l is FarmHouse))
|
||||
{
|
||||
for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
|
||||
{
|
||||
for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
|
||||
{
|
||||
Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
|
||||
vector.X += (float)(Game1.tileSize / 2);
|
||||
vector.Y += (float)(Game1.tileSize / 2);
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> something in l.objects)
|
||||
{
|
||||
StardewValley.Object obj = something.Value;
|
||||
if ((obj.GetType()).ToString().Contains("BagofHolding"))
|
||||
{
|
||||
BagofHolding current = (BagofHolding)obj;
|
||||
if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
|
||||
{
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
|
||||
{
|
||||
bool result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.canBePlacedHere(l, tile);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Game1.showRedMessage("NOT FARMHOUSE");
|
||||
for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
|
||||
{
|
||||
for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
|
||||
{
|
||||
Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
|
||||
vector.X += (float)(Game1.tileSize / 2);
|
||||
vector.Y += (float)(Game1.tileSize / 2);
|
||||
/*
|
||||
foreach (BagofHolding current in (l as FarmHouse).BagofHolding)
|
||||
{
|
||||
if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
|
||||
{
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
|
||||
{
|
||||
bool result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
return base.canBePlacedHere(l, tile);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDrawPosition()
|
||||
{
|
||||
this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)));
|
||||
}
|
||||
|
||||
public int getTilesWide()
|
||||
{
|
||||
return this.boundingBox.Width / Game1.tileSize;
|
||||
}
|
||||
|
||||
public int getTilesHigh()
|
||||
{
|
||||
return this.boundingBox.Height / Game1.tileSize;
|
||||
}
|
||||
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
// Log.AsyncC(x);
|
||||
// Log.AsyncM(y);
|
||||
|
||||
return false;
|
||||
if (location is FarmHouse)
|
||||
{
|
||||
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
|
||||
List<Rectangle> walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel);
|
||||
this.tileLocation = new Vector2((float)point.X, (float)point.Y);
|
||||
bool flag = false;
|
||||
if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293)
|
||||
{
|
||||
int num = (this.parentSheetIndex == 1293) ? 3 : 0;
|
||||
bool flag2 = false;
|
||||
foreach (Rectangle current in walls)
|
||||
{
|
||||
if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num))
|
||||
{
|
||||
flag2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
Game1.showRedMessage("Must be placed on wall");
|
||||
return false;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
for (int i = point.X; i < point.X + this.getTilesWide(); i++)
|
||||
{
|
||||
for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
|
||||
{
|
||||
if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
|
||||
{
|
||||
Game1.showRedMessage("Furniture can't be placed here");
|
||||
return false;
|
||||
}
|
||||
if (!flag && Utility.pointInRectangles(walls, i, j))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on wall");
|
||||
return false;
|
||||
}
|
||||
if (location.getTileIndexAt(i, j, "Buildings") != -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> c in location.objects)
|
||||
{
|
||||
StardewValley.Object ehh = c.Value;
|
||||
if (((ehh.GetType()).ToString()).Contains("BagofHolding"))
|
||||
{
|
||||
BagofHolding current2 = (BagofHolding)ehh;
|
||||
if (current2.Decoration_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
|
||||
{
|
||||
current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Farmer current3 in location.getFarmers())
|
||||
{
|
||||
if (current3.GetBoundingBox().Intersects(this.boundingBox))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on top of a person.");
|
||||
bool result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
|
||||
for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++)
|
||||
{
|
||||
base.placementAction(location, x + 1, y, who);
|
||||
}
|
||||
for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++)
|
||||
{
|
||||
base.placementAction(location, x, y + 1, who);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
|
||||
// List<Rectangle> walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel);
|
||||
this.tileLocation = new Vector2((float)point.X, (float)point.Y);
|
||||
bool flag = false;
|
||||
if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293)
|
||||
{
|
||||
int num = (this.parentSheetIndex == 1293) ? 3 : 0;
|
||||
bool flag2 = false;
|
||||
/*
|
||||
foreach (Rectangle current in walls)
|
||||
{
|
||||
if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num))
|
||||
{
|
||||
flag2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (!flag2)
|
||||
{
|
||||
Game1.showRedMessage("Must be placed on wall");
|
||||
return false;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
for (int i = point.X; i < point.X + this.getTilesWide(); i++)
|
||||
{
|
||||
for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
|
||||
{
|
||||
if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
|
||||
{
|
||||
Game1.showRedMessage("Furniture can't be placed here");
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (!flag && Utility.pointInRectangles(walls, i, j))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on wall");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
if (location.getTileIndexAt(i, j, "Buildings") != -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
|
||||
/*
|
||||
foreach (Furniture current2 in (location as FarmHouse).furniture)
|
||||
{
|
||||
if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
|
||||
{
|
||||
current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
*/
|
||||
foreach (Farmer current3 in location.getFarmers())
|
||||
{
|
||||
if (current3.GetBoundingBox().Intersects(this.boundingBox))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on top of a person.");
|
||||
bool result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
this.thisLocation = Game1.player.currentLocation;
|
||||
return Util.placementAction(this, location, x, y, who);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override bool isPlaceable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Rectangle getBoundingBox(Vector2 tileLocation)
|
||||
{
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
private Rectangle getDefaultSourceRectForType(int tileIndex, int type)
|
||||
{
|
||||
int num;
|
||||
int num2;
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
num = 1;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 1:
|
||||
num = 2;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 2:
|
||||
num = 3;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 3:
|
||||
num = 2;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 4:
|
||||
num = 2;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 5:
|
||||
num = 5;
|
||||
num2 = 3;
|
||||
goto IL_94;
|
||||
case 6:
|
||||
num = 2;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 7:
|
||||
num = 1;
|
||||
num2 = 3;
|
||||
goto IL_94;
|
||||
case 8:
|
||||
num = 1;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 10:
|
||||
num = 2;
|
||||
num2 = 3;
|
||||
goto IL_94;
|
||||
case 11:
|
||||
num = 2;
|
||||
num2 = 3;
|
||||
goto IL_94;
|
||||
case 12:
|
||||
num = 3;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 13:
|
||||
num = 1;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
}
|
||||
num = 1;
|
||||
num2 = 2;
|
||||
IL_94:
|
||||
return new Rectangle(tileIndex * 16 % TextureSheet.Width, tileIndex * 16 / TextureSheet.Width * 16, num * 16, num2 * 16);
|
||||
}
|
||||
|
||||
private Rectangle getDefaultBoundingBoxForType(int type)
|
||||
{
|
||||
int num;
|
||||
int num2;
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
num = 1;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 1:
|
||||
num = 2;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 2:
|
||||
num = 3;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 3:
|
||||
num = 2;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 4:
|
||||
num = 2;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 5:
|
||||
num = 5;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 6:
|
||||
num = 2;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 7:
|
||||
num = 1;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 8:
|
||||
num = 1;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 10:
|
||||
num = 2;
|
||||
num2 = 1;
|
||||
goto IL_94;
|
||||
case 11:
|
||||
num = 2;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 12:
|
||||
num = 3;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
case 13:
|
||||
num = 1;
|
||||
num2 = 2;
|
||||
goto IL_94;
|
||||
}
|
||||
num = 1;
|
||||
num2 = 1;
|
||||
IL_94:
|
||||
return new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, num * Game1.tileSize, num2 * Game1.tileSize);
|
||||
}
|
||||
|
||||
private int getTypeNumberFromName(string typeName)
|
||||
{
|
||||
string key;
|
||||
switch (key = typeName.ToLower())
|
||||
{
|
||||
case "chair":
|
||||
return 0;
|
||||
case "bench":
|
||||
return 1;
|
||||
case "couch":
|
||||
return 2;
|
||||
case "armchair":
|
||||
return 3;
|
||||
case "dresser":
|
||||
return 4;
|
||||
case "long table":
|
||||
return 5;
|
||||
case "painting":
|
||||
return 6;
|
||||
case "lamp":
|
||||
return 7;
|
||||
case "decor":
|
||||
return 8;
|
||||
case "bookcase":
|
||||
return 10;
|
||||
case "table":
|
||||
return 11;
|
||||
case "rug":
|
||||
return 12;
|
||||
case "window":
|
||||
return 13;
|
||||
}
|
||||
return 9;
|
||||
}
|
||||
|
||||
public override int salePrice()
|
||||
{
|
||||
return this.price;
|
||||
}
|
||||
|
||||
public override int maximumStackSize()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override int getStack()
|
||||
{
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
public override int addToStack(int amount)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
private float getScaleSize()
|
||||
{
|
||||
int num = this.sourceRect.Width / 16;
|
||||
int num2 = this.sourceRect.Height / 16;
|
||||
if (num >= 5)
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
if (num2 >= 3)
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
if (num <= 2)
|
||||
{
|
||||
return 2f;
|
||||
}
|
||||
if (num <= 4)
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
return 0.1f;
|
||||
}
|
||||
|
||||
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
|
||||
{
|
||||
base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber)
|
||||
{
|
||||
spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), this.drawColor * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize, SpriteEffects.None, layerDepth);
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||
{
|
||||
if (x == -1)
|
||||
{
|
||||
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)))), new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
|
||||
}
|
||||
if (this.heldObject != null)
|
||||
{
|
||||
if (this.heldObject is BagofHolding)
|
||||
{
|
||||
(this.heldObject as BagofHolding).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as BagofHolding).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha);
|
||||
return;
|
||||
}
|
||||
spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), this.drawColor * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f);
|
||||
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f)
|
||||
{
|
||||
spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
|
||||
}
|
||||
|
||||
public override Item getOne()
|
||||
{
|
||||
BagofHolding BagofHolding = new BagofHolding(this.parentSheetIndex, this.tileLocation, this.inventory,this.inventoryMaxSize,this.drawColor);
|
||||
|
||||
/*
|
||||
drawPosition = this.drawPosition;
|
||||
defaultBoundingBox = this.defaultBoundingBox;
|
||||
boundingBox = this.boundingBox;
|
||||
currentRotation = this.currentRotation - 1;
|
||||
rotations = this.rotations;
|
||||
rotate();
|
||||
*/
|
||||
return BagofHolding;
|
||||
}
|
||||
|
||||
public override string getCategoryName()
|
||||
{
|
||||
return "Bag of Holding";
|
||||
// return base.getCategoryName();
|
||||
}
|
||||
|
||||
public override Color getCategoryColor()
|
||||
{
|
||||
return Util.invertColor(LightColors.Silver);
|
||||
}
|
||||
|
||||
public virtual void openBag()
|
||||
{
|
||||
Game1.activeClickableMenu = new Revitalize.Menus.ItemGrabMenu(this.inventory);
|
||||
this.itemReadyForHarvest = false;
|
||||
/*
|
||||
Log.AsyncC("DROPPING INVENTORY!");
|
||||
|
||||
Random random = new Random(inventory.Count);
|
||||
int i = random.Next();
|
||||
i = i % 4;
|
||||
Vector2 v2 = new Vector2(this.tileLocation.X * Game1.tileSize, this.tileLocation.Y * Game1.tileSize);
|
||||
foreach (var I in inventory)
|
||||
{
|
||||
Log.AsyncY(I.Name);
|
||||
Log.AsyncO(I.getStack());
|
||||
Log.AsyncM(I.Stack);
|
||||
Log.AsyncC("Dropping an item!");
|
||||
Game1.createItemDebris(I, v2, i);
|
||||
}
|
||||
inventory.Clear();
|
||||
*/
|
||||
}
|
||||
|
||||
public static void OpenBag()
|
||||
{
|
||||
if( (Game1.player.ActiveObject as BagofHolding!=null)) (Game1.player.ActiveObject as BagofHolding).openBag();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,633 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using StardewValley.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Revitalize.Menus
|
||||
{
|
||||
public class ItemGrabMenu : MenuWithInventory
|
||||
{
|
||||
public delegate void behaviorOnItemSelect(Item item, Farmer who);
|
||||
|
||||
public const int source_none = 0;
|
||||
|
||||
public const int source_chest = 1;
|
||||
|
||||
public const int source_gift = 2;
|
||||
|
||||
public const int source_fishingChest = 3;
|
||||
|
||||
private StardewValley.Menus.InventoryMenu ItemsToGrabMenu;
|
||||
|
||||
private TemporaryAnimatedSprite poof;
|
||||
|
||||
public bool reverseGrab;
|
||||
|
||||
public bool showReceivingMenu = true;
|
||||
|
||||
public bool drawBG = true;
|
||||
|
||||
public bool destroyItemOnClick;
|
||||
|
||||
public bool canExitOnKey;
|
||||
|
||||
public bool playRightClickSound;
|
||||
|
||||
public bool allowRightClick;
|
||||
|
||||
public bool shippingBin;
|
||||
|
||||
private string message;
|
||||
|
||||
private ItemGrabMenu.behaviorOnItemSelect behaviorFunction;
|
||||
|
||||
public ItemGrabMenu.behaviorOnItemSelect behaviorOnItemGrab;
|
||||
|
||||
private Item hoverItem;
|
||||
|
||||
private Item sourceItem;
|
||||
|
||||
private ClickableTextureComponent organizeButton;
|
||||
|
||||
private ClickableTextureComponent colorPickerToggleButton;
|
||||
|
||||
private ClickableTextureComponent lastShippedHolder;
|
||||
|
||||
public int source;
|
||||
|
||||
private bool snappedtoBottom;
|
||||
|
||||
private DiscreteColorPicker chestColorPicker;
|
||||
|
||||
public int capacity;
|
||||
|
||||
public ItemGrabMenu(List<Item> inventory) : base(null, true, true, 0, 0)
|
||||
{
|
||||
this.ItemsToGrabMenu = new StardewValley.Menus.InventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, inventory, null, inventory.Capacity, 3, 0, 0, true);
|
||||
capacity = inventory.Capacity;
|
||||
// Log.AsyncO("MAX LOAD"+this.capacity);
|
||||
this.reverseGrab = true;
|
||||
|
||||
this.organizeButton = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - Game1.tileSize, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize", new object[0]), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), (float)Game1.pixelZoom, false);
|
||||
|
||||
this.inventory.showGrayedOutSlots = true;
|
||||
}
|
||||
|
||||
public ItemGrabMenu(List<Item> inventory, bool reverseGrab, bool showReceivingMenu, InventoryMenu.highlightThisItem highlightFunction, ItemGrabMenu.behaviorOnItemSelect behaviorOnItemSelectFunction, string message, ItemGrabMenu.behaviorOnItemSelect behaviorOnItemGrab = null, bool snapToBottom = false, bool canBeExitedWithKey = false, bool playRightClickSound = true, bool allowRightClick = true, bool showOrganizeButton = false, int source = 0, Item sourceItem = null) : base(highlightFunction, true, true, 0, 0)
|
||||
{
|
||||
this.source = source;
|
||||
this.message = message;
|
||||
this.reverseGrab = reverseGrab;
|
||||
this.showReceivingMenu = showReceivingMenu;
|
||||
this.playRightClickSound = playRightClickSound;
|
||||
this.allowRightClick = allowRightClick;
|
||||
this.inventory.showGrayedOutSlots = true;
|
||||
this.sourceItem = sourceItem;
|
||||
if (source == 1 && sourceItem != null && sourceItem is Chest)
|
||||
{
|
||||
this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize - IClickableMenu.borderWidth * 2, 0, new Chest(true));
|
||||
this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((sourceItem as Chest).playerChoiceColor);
|
||||
(this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection);
|
||||
this.colorPickerToggleButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 5, 16 * Game1.pixelZoom, 16 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), (float)Game1.pixelZoom, false)
|
||||
{
|
||||
hoverText = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker", new object[0])
|
||||
};
|
||||
}
|
||||
if (snapToBottom)
|
||||
{
|
||||
base.movePosition(0, Game1.viewport.Height - (this.yPositionOnScreen + this.height - IClickableMenu.spaceToClearTopBorder));
|
||||
this.snappedtoBottom = true;
|
||||
}
|
||||
this.ItemsToGrabMenu = new InventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, inventory, highlightFunction, inventory.Capacity, 3, 0, 0, true);
|
||||
this.behaviorFunction = behaviorOnItemSelectFunction;
|
||||
this.behaviorOnItemGrab = behaviorOnItemGrab;
|
||||
this.canExitOnKey = canBeExitedWithKey;
|
||||
if (showOrganizeButton)
|
||||
{
|
||||
this.organizeButton = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - Game1.tileSize, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize", new object[0]), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), (float)Game1.pixelZoom, false);
|
||||
}
|
||||
if ((Game1.isAnyGamePadButtonBeingPressed() || !Game1.lastCursorMotionWasMouse) && this.ItemsToGrabMenu.actualInventory.Count > 0 && Game1.activeClickableMenu == null)
|
||||
{
|
||||
Game1.setMousePosition(this.inventory.inventory[0].bounds.Center);
|
||||
}
|
||||
}
|
||||
|
||||
public void initializeShippingBin()
|
||||
{
|
||||
this.shippingBin = true;
|
||||
this.lastShippedHolder = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height / 2 - 20 * Game1.pixelZoom - Game1.tileSize, 24 * Game1.pixelZoom, 24 * Game1.pixelZoom), "", Game1.content.LoadString("Strings\\UI:ShippingBin_LastItem", new object[0]), Game1.mouseCursors, new Rectangle(293, 360, 24, 24), (float)Game1.pixelZoom, false);
|
||||
}
|
||||
|
||||
public void setSourceItem(Item item)
|
||||
{
|
||||
this.sourceItem = item;
|
||||
this.chestColorPicker = null;
|
||||
this.colorPickerToggleButton = null;
|
||||
if (this.source == 1 && this.sourceItem != null && this.sourceItem is Chest)
|
||||
{
|
||||
this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize - IClickableMenu.borderWidth * 2, 0, new Chest(true));
|
||||
this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((this.sourceItem as Chest).playerChoiceColor);
|
||||
(this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection);
|
||||
this.colorPickerToggleButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 5, 16 * Game1.pixelZoom, 16 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), (float)Game1.pixelZoom, false)
|
||||
{
|
||||
hoverText = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker", new object[0])
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundTransparency(bool b)
|
||||
{
|
||||
this.drawBG = b;
|
||||
}
|
||||
|
||||
public void setDestroyItemOnClick(bool b)
|
||||
{
|
||||
this.destroyItemOnClick = b;
|
||||
}
|
||||
|
||||
public override void receiveRightClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
if (!this.allowRightClick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
base.receiveRightClick(x, y, playSound && this.playRightClickSound);
|
||||
if (this.heldItem == null && this.showReceivingMenu)
|
||||
{
|
||||
this.heldItem = this.ItemsToGrabMenu.rightClick(x, y, this.heldItem, false);
|
||||
if (this.heldItem != null && this.behaviorOnItemGrab != null)
|
||||
{
|
||||
this.behaviorOnItemGrab(this.heldItem, Game1.player);
|
||||
if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
|
||||
{
|
||||
(Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
|
||||
}
|
||||
}
|
||||
if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 326)
|
||||
{
|
||||
this.heldItem = null;
|
||||
Game1.player.canUnderstandDwarves = true;
|
||||
this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
|
||||
Game1.playSound("fireball");
|
||||
return;
|
||||
}
|
||||
if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
|
||||
{
|
||||
string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
|
||||
try
|
||||
{
|
||||
if ((this.heldItem as StardewValley.Object).category == -7)
|
||||
{
|
||||
Game1.player.cookingRecipes.Add(key, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.player.craftingRecipes.Add(key, 0);
|
||||
}
|
||||
this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
|
||||
Game1.playSound("newRecipe");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
this.heldItem = null;
|
||||
return;
|
||||
}
|
||||
if (Game1.player.addItemToInventoryBool(this.heldItem, false))
|
||||
{
|
||||
this.heldItem = null;
|
||||
Game1.playSound("coin");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (this.reverseGrab || this.behaviorFunction != null)
|
||||
{
|
||||
this.behaviorFunction(this.heldItem, Game1.player);
|
||||
if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
|
||||
{
|
||||
(Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
|
||||
}
|
||||
if (this.destroyItemOnClick)
|
||||
{
|
||||
this.heldItem = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds)
|
||||
{
|
||||
if (this.snappedtoBottom)
|
||||
{
|
||||
base.movePosition((newBounds.Width - oldBounds.Width) / 2, Game1.viewport.Height - (this.yPositionOnScreen + this.height - IClickableMenu.spaceToClearTopBorder));
|
||||
}
|
||||
if (this.ItemsToGrabMenu != null)
|
||||
{
|
||||
this.ItemsToGrabMenu.gameWindowSizeChanged(oldBounds, newBounds);
|
||||
}
|
||||
if (this.organizeButton != null)
|
||||
{
|
||||
this.organizeButton = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - Game1.tileSize, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize", new object[0]), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), (float)Game1.pixelZoom, false);
|
||||
}
|
||||
if (this.source == 1 && this.sourceItem != null && this.sourceItem is Chest)
|
||||
{
|
||||
this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize - IClickableMenu.borderWidth * 2, 0, null);
|
||||
this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((this.sourceItem as Chest).playerChoiceColor);
|
||||
}
|
||||
}
|
||||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
base.receiveLeftClick(x, y, !this.destroyItemOnClick);
|
||||
if (ItemsToGrabMenu.isWithinBounds(x, y) == false)
|
||||
{
|
||||
|
||||
//Log.AsyncC("AWESOME");
|
||||
bool f = Util.isInventoryFull(this.ItemsToGrabMenu.actualInventory);
|
||||
if (f == false)
|
||||
{
|
||||
this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
|
||||
Util.addItemToOtherInventory(this.ItemsToGrabMenu.actualInventory, this.heldItem);
|
||||
Log.AsyncG("not full");
|
||||
}
|
||||
else
|
||||
{
|
||||
// this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
|
||||
// Util.addItemToInventorySilently(this.heldItem);
|
||||
}
|
||||
// this.ItemsToGrabMenu.inventory.Add(new ClickableComponent(new Rectangle(ItemsToGrabMenu.xPositionOnScreen + ItemsToGrabMenu.actualInventory.Count-1 % (this.capacity / this.ItemsToGrabMenu.rows) * Game1.tileSize + this.ItemsToGrabMenu.horizontalGap * (ItemsToGrabMenu.actualInventory.Count-1 % (this.capacity / this.ItemsToGrabMenu.rows)), ItemsToGrabMenu.yPositionOnScreen + ItemsToGrabMenu.actualInventory.Count-1 / (this.capacity / this.ItemsToGrabMenu.rows) * (Game1.tileSize + this.ItemsToGrabMenu.verticalGap) + (ItemsToGrabMenu.actualInventory.Count-1 / (this.capacity / this.ItemsToGrabMenu.rows) - 1) * Game1.pixelZoom - (Game1.tileSize / 5), Game1.tileSize, Game1.tileSize), string.Concat(ItemsToGrabMenu.actualInventory.Count-1)));
|
||||
if (this.okButton.containsPoint(x, y) == false && this.organizeButton.containsPoint(x, y) == false && f == false)
|
||||
{
|
||||
//
|
||||
Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
|
||||
Game1.playSound("Ship");
|
||||
|
||||
}
|
||||
if (this.organizeButton.containsPoint(x, y))
|
||||
{
|
||||
ItemGrabMenu.organizeItemsInList(this.ItemsToGrabMenu.actualInventory);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (Util.isInventoryFull(this.ItemsToGrabMenu.actualInventory) == true)
|
||||
{
|
||||
Item i=new StardewValley.Object();
|
||||
Item j = new StardewValley.Object();
|
||||
j = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
|
||||
i = this.heldItem;
|
||||
|
||||
|
||||
Util.addItemToInventorySilently(j);
|
||||
// this.heldItem = null;
|
||||
|
||||
foreach (ClickableComponent current in ItemsToGrabMenu.inventory)
|
||||
{
|
||||
if (current.containsPoint(x, y))
|
||||
{
|
||||
int num = Convert.ToInt32(current.name);
|
||||
// Log.AsyncO(num);
|
||||
this.ItemsToGrabMenu.actualInventory.RemoveAt(num);
|
||||
// Log.AsyncO("Remaining " + ItemsToGrabMenu.actualInventory.Count);
|
||||
|
||||
}
|
||||
}
|
||||
// j= this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
|
||||
Util.addItemToOtherInventory(this.ItemsToGrabMenu.actualInventory, i);
|
||||
Log.AsyncG("item swap");
|
||||
Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
|
||||
Game1.playSound("Ship");
|
||||
this.heldItem = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
|
||||
Util.addItemToInventoryElseDrop(this.heldItem);
|
||||
this.heldItem = null;
|
||||
|
||||
foreach (ClickableComponent current in ItemsToGrabMenu.inventory)
|
||||
{
|
||||
if (current.containsPoint(x, y))
|
||||
{
|
||||
int num = Convert.ToInt32(current.name);
|
||||
// Log.AsyncO(num);
|
||||
this.ItemsToGrabMenu.actualInventory.RemoveAt(num);
|
||||
// Log.AsyncO("Remaining " + ItemsToGrabMenu.actualInventory.Count);
|
||||
|
||||
}
|
||||
}
|
||||
Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
|
||||
Game1.playSound("Ship");
|
||||
|
||||
}
|
||||
return;
|
||||
if (this.shippingBin && this.lastShippedHolder.containsPoint(x, y))
|
||||
{
|
||||
if (Game1.getFarm().lastItemShipped != null && Game1.player.addItemToInventoryBool(Game1.getFarm().lastItemShipped, false))
|
||||
{
|
||||
Game1.playSound("coin");
|
||||
Game1.getFarm().shippingBin.Remove(Game1.getFarm().lastItemShipped);
|
||||
Game1.getFarm().lastItemShipped = null;
|
||||
if (Game1.player.ActiveObject != null)
|
||||
{
|
||||
Game1.player.showCarrying();
|
||||
Game1.player.Halt();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.chestColorPicker != null)
|
||||
{
|
||||
this.chestColorPicker.receiveLeftClick(x, y, true);
|
||||
if (this.sourceItem != null && this.sourceItem is Chest)
|
||||
{
|
||||
(this.sourceItem as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection);
|
||||
}
|
||||
}
|
||||
if (this.colorPickerToggleButton != null && this.colorPickerToggleButton.containsPoint(x, y))
|
||||
{
|
||||
Game1.player.showChestColorPicker = !Game1.player.showChestColorPicker;
|
||||
this.chestColorPicker.visible = Game1.player.showChestColorPicker;
|
||||
Game1.soundBank.PlayCue("drumkit6");
|
||||
}
|
||||
if (this.heldItem == null && this.showReceivingMenu)
|
||||
{
|
||||
this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
|
||||
// Log.AsyncC("YAY");
|
||||
|
||||
|
||||
|
||||
|
||||
if (this.heldItem != null && this.behaviorOnItemGrab != null)
|
||||
{
|
||||
this.behaviorOnItemGrab(this.heldItem, Game1.player);
|
||||
if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
|
||||
{
|
||||
(Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
|
||||
}
|
||||
}
|
||||
if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 326)
|
||||
{
|
||||
this.heldItem = null;
|
||||
Game1.player.canUnderstandDwarves = true;
|
||||
this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
|
||||
Game1.playSound("fireball");
|
||||
}
|
||||
else if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 102)
|
||||
{
|
||||
this.heldItem = null;
|
||||
Game1.player.foundArtifact(102, 1);
|
||||
this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
|
||||
Game1.playSound("fireball");
|
||||
}
|
||||
else if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
|
||||
{
|
||||
string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
|
||||
try
|
||||
{
|
||||
if ((this.heldItem as StardewValley.Object).category == -7)
|
||||
{
|
||||
Game1.player.cookingRecipes.Add(key, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.player.craftingRecipes.Add(key, 0);
|
||||
}
|
||||
this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
|
||||
Game1.playSound("newRecipe");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
this.heldItem = null;
|
||||
}
|
||||
else if (Game1.player.addItemToInventoryBool(this.heldItem, false))
|
||||
{
|
||||
this.heldItem = null;
|
||||
Game1.playSound("coin");
|
||||
}
|
||||
}
|
||||
else if ((this.reverseGrab || this.behaviorFunction != null) && this.isWithinBounds(x, y))
|
||||
{
|
||||
this.behaviorFunction(this.heldItem, Game1.player);
|
||||
if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
|
||||
{
|
||||
(Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
|
||||
}
|
||||
if (this.destroyItemOnClick)
|
||||
{
|
||||
this.heldItem = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.organizeButton != null && this.organizeButton.containsPoint(x, y))
|
||||
{
|
||||
ItemGrabMenu.organizeItemsInList(this.ItemsToGrabMenu.actualInventory);
|
||||
Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
|
||||
Game1.playSound("Ship");
|
||||
return;
|
||||
}
|
||||
if (this.heldItem != null && !this.isWithinBounds(x, y) && this.heldItem.canBeTrashed())
|
||||
{
|
||||
Game1.playSound("throwDownITem");
|
||||
Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection);
|
||||
this.heldItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void organizeItemsInList(List<Item> items)
|
||||
{
|
||||
items.Sort();
|
||||
items.Reverse();
|
||||
}
|
||||
|
||||
public bool areAllItemsTaken()
|
||||
{
|
||||
for (int i = 0; i < this.ItemsToGrabMenu.actualInventory.Count; i++)
|
||||
{
|
||||
if (this.ItemsToGrabMenu.actualInventory[i] != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void receiveKeyPress(Keys key)
|
||||
{
|
||||
if ((this.canExitOnKey || this.areAllItemsTaken()) && Game1.options.doesInputListContain(Game1.options.menuButton, key) && this.readyToClose())
|
||||
{
|
||||
base.exitThisMenu(true);
|
||||
if (Game1.currentLocation.currentEvent != null)
|
||||
{
|
||||
Event expr_4C = Game1.currentLocation.currentEvent;
|
||||
int currentCommand = expr_4C.CurrentCommand;
|
||||
expr_4C.CurrentCommand = currentCommand + 1;
|
||||
}
|
||||
}
|
||||
else if (Game1.options.doesInputListContain(Game1.options.menuButton, key) && this.heldItem != null)
|
||||
{
|
||||
Game1.setMousePosition(this.trashCan.bounds.Center);
|
||||
}
|
||||
if (key == Keys.Delete && this.heldItem != null && this.heldItem.canBeTrashed())
|
||||
{
|
||||
if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex))
|
||||
{
|
||||
Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex);
|
||||
}
|
||||
this.heldItem = null;
|
||||
Game1.playSound("trashcan");
|
||||
}
|
||||
}
|
||||
|
||||
public override void update(GameTime time)
|
||||
{
|
||||
base.update(time);
|
||||
if (this.poof != null && this.poof.update(time))
|
||||
{
|
||||
this.poof = null;
|
||||
}
|
||||
if (this.chestColorPicker != null)
|
||||
{
|
||||
this.chestColorPicker.update(time);
|
||||
}
|
||||
}
|
||||
|
||||
public override void performHoverAction(int x, int y)
|
||||
{
|
||||
|
||||
if (this.colorPickerToggleButton != null)
|
||||
{
|
||||
this.colorPickerToggleButton.tryHover(x, y, 0.25f);
|
||||
if (this.colorPickerToggleButton.containsPoint(x, y))
|
||||
{
|
||||
this.hoverText = this.colorPickerToggleButton.hoverText;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.ItemsToGrabMenu.isWithinBounds(x, y) && this.showReceivingMenu)
|
||||
{
|
||||
if (ItemsToGrabMenu.actualInventory.Count == 0) return;
|
||||
this.hoveredItem = this.ItemsToGrabMenu.hover(x, y, this.heldItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.performHoverAction(x, y);
|
||||
}
|
||||
if (this.organizeButton != null)
|
||||
{
|
||||
this.hoverText = null;
|
||||
this.organizeButton.tryHover(x, y, 0.1f);
|
||||
if (this.organizeButton.containsPoint(x, y))
|
||||
{
|
||||
this.hoverText = this.organizeButton.hoverText;
|
||||
}
|
||||
}
|
||||
if (this.shippingBin)
|
||||
{
|
||||
this.hoverText = null;
|
||||
if (this.lastShippedHolder.containsPoint(x, y) && Game1.getFarm().lastItemShipped != null)
|
||||
{
|
||||
this.hoverText = this.lastShippedHolder.hoverText;
|
||||
}
|
||||
}
|
||||
if (this.chestColorPicker != null)
|
||||
{
|
||||
this.chestColorPicker.performHoverAction(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
if (this.drawBG)
|
||||
{
|
||||
b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * 0.5f);
|
||||
}
|
||||
base.draw(b, false, false);
|
||||
|
||||
if (this.showReceivingMenu)
|
||||
{
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 16 * Game1.pixelZoom), (float)(this.yPositionOnScreen + this.height / 2 + Game1.tileSize + Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(16, 368, 12, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 16 * Game1.pixelZoom), (float)(this.yPositionOnScreen + this.height / 2 + Game1.tileSize - Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(21, 368, 11, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 10 * Game1.pixelZoom), (float)(this.yPositionOnScreen + this.height / 2 + Game1.tileSize - Game1.pixelZoom * 11)), new Rectangle?(new Rectangle(4, 372, 8, 11)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
if (this.source != 0)
|
||||
{
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 18 * Game1.pixelZoom), (float)(this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(16, 368, 12, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 18 * Game1.pixelZoom), (float)(this.yPositionOnScreen + Game1.tileSize - Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(21, 368, 11, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
Rectangle value = new Rectangle(127, 412, 10, 11);
|
||||
int num = this.source;
|
||||
if (num != 2)
|
||||
{
|
||||
if (num == 3)
|
||||
{
|
||||
value.X += 10;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value.X += 20;
|
||||
}
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 13 * Game1.pixelZoom), (float)(this.yPositionOnScreen + Game1.tileSize - Game1.pixelZoom * 11)), new Rectangle?(value), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
}
|
||||
Game1.drawDialogueBox(this.ItemsToGrabMenu.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder, this.ItemsToGrabMenu.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder, this.ItemsToGrabMenu.width + IClickableMenu.borderWidth * 2 + IClickableMenu.spaceToClearSideBorder * 2, this.ItemsToGrabMenu.height + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth * 2, false, true, null, false);
|
||||
this.ItemsToGrabMenu.draw(b);
|
||||
}
|
||||
else if (this.message != null)
|
||||
{
|
||||
Game1.drawDialogueBox(Game1.viewport.Width / 2, this.ItemsToGrabMenu.yPositionOnScreen + this.ItemsToGrabMenu.height / 2, false, false, this.message);
|
||||
}
|
||||
if (this.poof != null)
|
||||
{
|
||||
this.poof.draw(b, true, 0, 0);
|
||||
}
|
||||
if (this.shippingBin && Game1.getFarm().lastItemShipped != null)
|
||||
{
|
||||
this.lastShippedHolder.draw(b);
|
||||
Game1.getFarm().lastItemShipped.drawInMenu(b, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * 4), (float)(this.lastShippedHolder.bounds.Y + Game1.pixelZoom * 4)), 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * -2), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 25)), new Rectangle?(new Rectangle(325, 448, 5, 14)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * 21), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 25)), new Rectangle?(new Rectangle(325, 448, 5, 14)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * -2), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 11)), new Rectangle?(new Rectangle(325, 452, 5, 13)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * 21), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 11)), new Rectangle?(new Rectangle(325, 452, 5, 13)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
|
||||
}
|
||||
if (this.colorPickerToggleButton != null)
|
||||
{
|
||||
this.colorPickerToggleButton.draw(b);
|
||||
}
|
||||
if (this.chestColorPicker != null)
|
||||
{
|
||||
this.chestColorPicker.draw(b);
|
||||
}
|
||||
if (this.organizeButton != null)
|
||||
{
|
||||
this.organizeButton.draw(b);
|
||||
}
|
||||
if (this.hoverText != null && (this.hoveredItem == null || this.hoveredItem == null || this.ItemsToGrabMenu == null))
|
||||
{
|
||||
IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, -1, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null);
|
||||
}
|
||||
if (this.hoveredItem != null)
|
||||
{
|
||||
IClickableMenu.drawToolTip(b, this.hoveredItem.getDescription(), this.hoveredItem.Name, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, null, -1);
|
||||
}
|
||||
else if (this.hoveredItem != null && this.ItemsToGrabMenu != null)
|
||||
{
|
||||
IClickableMenu.drawToolTip(b, this.ItemsToGrabMenu.descriptionText, this.ItemsToGrabMenu.descriptionTitle, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, null, -1);
|
||||
}
|
||||
if (this.heldItem != null)
|
||||
{
|
||||
this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + 8), (float)(Game1.getOldMouseY() + 8)), 1f);
|
||||
}
|
||||
Game1.mouseCursorTransparency = 1f;
|
||||
base.drawMouse(b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,229 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Revitalize.Menus
|
||||
{
|
||||
public class StorageContainer : MenuWithInventory
|
||||
{
|
||||
public delegate bool behaviorOnItemChange(Item i, int position, Item old, StorageContainer container, bool onRemoval = false);
|
||||
|
||||
public StardewValley.Menus.InventoryMenu ItemsToGrabMenu;
|
||||
|
||||
private TemporaryAnimatedSprite poof;
|
||||
|
||||
private StorageContainer.behaviorOnItemChange itemChangeBehavior;
|
||||
|
||||
public StorageContainer(List<Item> inventory, int capacity, int rows = 3, StorageContainer.behaviorOnItemChange itemChangeBehavior = null, StardewValley.Menus.InventoryMenu.highlightThisItem highlightMethod = null) : base(highlightMethod, true, true, 0, 0)
|
||||
{
|
||||
this.itemChangeBehavior = itemChangeBehavior;
|
||||
int num = Game1.tileSize * (capacity / rows);
|
||||
int arg_23_0 = Game1.tileSize;
|
||||
int arg_2B_0 = Game1.tileSize / 4;
|
||||
this.ItemsToGrabMenu = new StardewValley.Menus.InventoryMenu(Game1.viewport.Width / 2 - num / 2, this.yPositionOnScreen + Game1.tileSize, false, inventory, null, capacity, rows, 0, 0, true);
|
||||
}
|
||||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
Item heldItem = this.heldItem;
|
||||
int num = (heldItem != null) ? heldItem.Stack : -1;
|
||||
if (base.isWithinBounds(x, y))
|
||||
{
|
||||
base.receiveLeftClick(x, y, false);
|
||||
if (this.itemChangeBehavior == null && heldItem == null && this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
|
||||
{
|
||||
this.heldItem = this.ItemsToGrabMenu.tryToAddItem(this.heldItem, "Ship");
|
||||
}
|
||||
}
|
||||
bool flag = true;
|
||||
if (this.ItemsToGrabMenu.isWithinBounds(x, y))
|
||||
{
|
||||
this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
|
||||
if ((this.heldItem != null && heldItem == null) || (this.heldItem != null && heldItem != null && !this.heldItem.Equals(heldItem)))
|
||||
{
|
||||
if (this.itemChangeBehavior != null)
|
||||
{
|
||||
flag = this.itemChangeBehavior(this.heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), heldItem, this, true);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
Game1.playSound("dwop");
|
||||
}
|
||||
}
|
||||
if ((this.heldItem == null && heldItem != null) || (this.heldItem != null && heldItem != null && !this.heldItem.Equals(heldItem)))
|
||||
{
|
||||
Item item = this.heldItem;
|
||||
if (this.heldItem == null && this.ItemsToGrabMenu.getItemAt(x, y) != null && num < this.ItemsToGrabMenu.getItemAt(x, y).Stack)
|
||||
{
|
||||
item = heldItem.getOne();
|
||||
item.Stack = num;
|
||||
}
|
||||
if (this.itemChangeBehavior != null)
|
||||
{
|
||||
flag = this.itemChangeBehavior(heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), item, this, false);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
Game1.playSound("Ship");
|
||||
}
|
||||
}
|
||||
if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
|
||||
{
|
||||
string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
|
||||
try
|
||||
{
|
||||
if ((this.heldItem as StardewValley.Object).category == -7)
|
||||
{
|
||||
Game1.player.cookingRecipes.Add(key, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.player.craftingRecipes.Add(key, 0);
|
||||
}
|
||||
this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
|
||||
Game1.playSound("newRecipe");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
this.heldItem = null;
|
||||
}
|
||||
else if (Game1.oldKBState.IsKeyDown(Keys.LeftShift) && Game1.player.addItemToInventoryBool(this.heldItem, false))
|
||||
{
|
||||
this.heldItem = null;
|
||||
if (this.itemChangeBehavior != null)
|
||||
{
|
||||
flag = this.itemChangeBehavior(this.heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), heldItem, this, true);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
Game1.playSound("coin");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.okButton.containsPoint(x, y) && this.readyToClose())
|
||||
{
|
||||
Game1.playSound("bigDeSelect");
|
||||
Game1.exitActiveMenu();
|
||||
}
|
||||
if (this.trashCan.containsPoint(x, y) && this.heldItem != null && this.heldItem.canBeTrashed())
|
||||
{
|
||||
if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex))
|
||||
{
|
||||
Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex);
|
||||
}
|
||||
this.heldItem = null;
|
||||
Game1.playSound("trashcan");
|
||||
}
|
||||
}
|
||||
|
||||
public override void receiveRightClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
int num = (this.heldItem != null) ? this.heldItem.Stack : 0;
|
||||
Item heldItem = this.heldItem;
|
||||
if (base.isWithinBounds(x, y))
|
||||
{
|
||||
base.receiveRightClick(x, y, true);
|
||||
if (this.itemChangeBehavior == null && heldItem == null && this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
|
||||
{
|
||||
this.heldItem = this.ItemsToGrabMenu.tryToAddItem(this.heldItem, "Ship");
|
||||
}
|
||||
}
|
||||
if (this.ItemsToGrabMenu.isWithinBounds(x, y))
|
||||
{
|
||||
this.heldItem = this.ItemsToGrabMenu.rightClick(x, y, this.heldItem, false);
|
||||
if ((this.heldItem != null && heldItem == null) || (this.heldItem != null && heldItem != null && !this.heldItem.Equals(heldItem)) || (this.heldItem != null && heldItem != null && this.heldItem.Equals(heldItem) && this.heldItem.Stack != num))
|
||||
{
|
||||
if (this.itemChangeBehavior != null)
|
||||
{
|
||||
this.itemChangeBehavior(this.heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), heldItem, this, true);
|
||||
}
|
||||
Game1.playSound("dwop");
|
||||
}
|
||||
if ((this.heldItem == null && heldItem != null) || (this.heldItem != null && heldItem != null && !this.heldItem.Equals(heldItem)))
|
||||
{
|
||||
if (this.itemChangeBehavior != null)
|
||||
{
|
||||
this.itemChangeBehavior(heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), this.heldItem, this, false);
|
||||
}
|
||||
Game1.playSound("Ship");
|
||||
}
|
||||
if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
|
||||
{
|
||||
string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
|
||||
try
|
||||
{
|
||||
if ((this.heldItem as StardewValley.Object).category == -7)
|
||||
{
|
||||
Game1.player.cookingRecipes.Add(key, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game1.player.craftingRecipes.Add(key, 0);
|
||||
}
|
||||
this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
|
||||
Game1.playSound("newRecipe");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
this.heldItem = null;
|
||||
return;
|
||||
}
|
||||
if (Game1.oldKBState.IsKeyDown(Keys.LeftShift) && Game1.player.addItemToInventoryBool(this.heldItem, false))
|
||||
{
|
||||
this.heldItem = null;
|
||||
Game1.playSound("coin");
|
||||
if (this.itemChangeBehavior != null)
|
||||
{
|
||||
this.itemChangeBehavior(this.heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), heldItem, this, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void update(GameTime time)
|
||||
{
|
||||
base.update(time);
|
||||
if (this.poof != null && this.poof.update(time))
|
||||
{
|
||||
this.poof = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void performHoverAction(int x, int y)
|
||||
{
|
||||
base.performHoverAction(x, y);
|
||||
this.ItemsToGrabMenu.hover(x, y, this.heldItem);
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * 0.5f);
|
||||
base.draw(b, false, false);
|
||||
Game1.drawDialogueBox(this.ItemsToGrabMenu.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder, this.ItemsToGrabMenu.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder, this.ItemsToGrabMenu.width + IClickableMenu.borderWidth * 2 + IClickableMenu.spaceToClearSideBorder * 2, this.ItemsToGrabMenu.height + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth * 2, false, true, null, false);
|
||||
this.ItemsToGrabMenu.draw(b);
|
||||
if (this.poof != null)
|
||||
{
|
||||
this.poof.draw(b, true, 0, 0);
|
||||
}
|
||||
if (!this.hoverText.Equals(""))
|
||||
{
|
||||
IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, -1, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null);
|
||||
}
|
||||
if (this.heldItem != null)
|
||||
{
|
||||
this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + Game1.pixelZoom * 4), (float)(Game1.getOldMouseY() + Game1.pixelZoom * 4)), 1f);
|
||||
}
|
||||
base.drawMouse(b);
|
||||
if (this.ItemsToGrabMenu.descriptionTitle != null && this.ItemsToGrabMenu.descriptionTitle.Length > 1)
|
||||
{
|
||||
IClickableMenu.drawHoverText(b, this.ItemsToGrabMenu.descriptionTitle, Game1.smallFont, Game1.tileSize / 2 + ((this.heldItem != null) ? (Game1.tileSize / 4) : (-Game1.tileSize / 3)), Game1.tileSize / 2 + ((this.heldItem != null) ? (Game1.tileSize / 4) : (-Game1.tileSize / 3)), -1, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,7 +67,8 @@ namespace Revitalize.Resources
|
|||
acceptedTypes.Add("Revitalize.Objects.GiftPackage", new SerializerDataNode(new ser(Serialize.serializeGiftPackage), new par(Serialize.parseGiftPackage),null));
|
||||
acceptedTypes.Add("Revitalize.Objects.ExtraSeeds", new SerializerDataNode(new ser(Serialize.serializeExtraSeeds), new par(Serialize.parseExtraSeeds),null));
|
||||
acceptedTypes.Add("Revitalize.Objects.Spell", new SerializerDataNode(new ser(Serialize.serializeSpell), new par(Serialize.parseSpell), null));
|
||||
}
|
||||
acceptedTypes.Add("Revitalize.Magic.Alchemy.Objects.BagofHolding", new SerializerDataNode(new ser(Serialize.serializeBagOfHolding), new par(Serialize.parseBagOfHolding), null));
|
||||
}
|
||||
|
||||
public static void addAllInteractionTypes()
|
||||
{
|
||||
|
@ -75,7 +76,7 @@ namespace Revitalize.Resources
|
|||
interactionTypes.Add("Seeds", Util.plantExtraCropHere); //for modded stardew seeds
|
||||
interactionTypes.Add("Gift Package", Util.getGiftPackageContents);
|
||||
interactionTypes.Add("Spell", Magic.MagicMonitor.castMagic);
|
||||
|
||||
interactionTypes.Add("Bag of Holding", Revitalize.Magic.Alchemy.Objects.BagofHolding.OpenBag);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Aesthetics\WeatherDebris\WeatherDebrisPlus.cs" />
|
||||
<Compile Include="Aesthetics\WeatherDebris\WeatherDebrisSystem.cs" />
|
||||
<Compile Include="Magic\Alchemy\Objects\BagofHolding.cs" />
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="CoreObject.cs" />
|
||||
<Compile Include="Aesthetics\Draw\ThingsToDraw.cs" />
|
||||
|
@ -64,7 +65,9 @@
|
|||
<Compile Include="Menus\FarmOptionsMenu.cs" />
|
||||
<Compile Include="Menus\GameMenu.cs" />
|
||||
<Compile Include="Menus\InventoryPage.cs" />
|
||||
<Compile Include="Menus\ItemGrabMenu.cs" />
|
||||
<Compile Include="Menus\SpriteKeyboard.cs" />
|
||||
<Compile Include="Menus\StorageContainer.cs" />
|
||||
<Compile Include="Objects\Decoration.cs" />
|
||||
<Compile Include="Objects\ExtraSeeds.cs" />
|
||||
<Compile Include="Objects\GiftPackage.cs" />
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Revitalize.Magic.Alchemy;
|
||||
using Revitalize.Magic.Alchemy.Objects;
|
||||
using Revitalize.Objects;
|
||||
using Revitalize.Objects.Machines;
|
||||
using Revitalize.Persistance;
|
||||
|
@ -992,6 +994,105 @@ namespace Revitalize
|
|||
Serialize.WriteToJsonFile(Path.Combine(objectsInWorldPath, d.thisLocation.name, d.Name + ".json"), (SpriteFontObject)d);
|
||||
}
|
||||
|
||||
public static BagofHolding parseBagOfHolding(string data)
|
||||
{
|
||||
|
||||
dynamic obj = JObject.Parse(data);
|
||||
|
||||
// Log.AsyncC(data);
|
||||
|
||||
// Log.AsyncC(obj.thisType);
|
||||
|
||||
|
||||
BagofHolding d = new BagofHolding();
|
||||
|
||||
d.price = obj.price;
|
||||
d.Decoration_type = obj.Decoration_type;
|
||||
d.rotations = obj.rotations;
|
||||
d.currentRotation = obj.currentRotation;
|
||||
string s1 = Convert.ToString(obj.sourceRect);
|
||||
d.sourceRect = Util.parseRectFromJson(s1);
|
||||
string s2 = Convert.ToString(obj.defaultSourceRect);
|
||||
d.defaultSourceRect = Util.parseRectFromJson(s2);
|
||||
string s3 = Convert.ToString(obj.defaultBoundingBox);
|
||||
d.defaultBoundingBox = Util.parseRectFromJson(s3);
|
||||
d.description = obj.description;
|
||||
d.flipped = obj.flipped;
|
||||
d.flaggedForPickUp = obj.flaggedForPickUp;
|
||||
d.tileLocation = obj.tileLocation;
|
||||
d.parentSheetIndex = obj.parentSheetIndex;
|
||||
d.owner = obj.owner;
|
||||
d.name = obj.name;
|
||||
d.type = obj.type;
|
||||
d.canBeSetDown = obj.canBeSetDown;
|
||||
d.canBeGrabbed = obj.canBeGrabbed;
|
||||
d.isHoedirt = obj.isHoedirt;
|
||||
d.isSpawnedObject = obj.isSpawnedObject;
|
||||
d.questItem = obj.questItem;
|
||||
d.isOn = obj.isOn;
|
||||
d.fragility = obj.fragility;
|
||||
d.edibility = obj.edibility;
|
||||
d.stack = obj.stack;
|
||||
d.quality = obj.quality;
|
||||
d.bigCraftable = obj.bigCraftable;
|
||||
d.setOutdoors = obj.setOutdoors;
|
||||
d.setIndoors = obj.setIndoors;
|
||||
d.readyForHarvest = obj.readyForHarvest;
|
||||
d.showNextIndex = obj.showNextIndex;
|
||||
d.hasBeenPickedUpByFarmer = obj.hasBeenPickedUpByFarmer;
|
||||
d.isRecipe = obj.isRecipe;
|
||||
d.isLamp = obj.isLamp;
|
||||
d.heldObject = obj.heldObject;
|
||||
d.minutesUntilReady = obj.minutesUntilReady;
|
||||
string s4 = Convert.ToString(obj.boundingBox);
|
||||
d.boundingBox = Util.parseRectFromJson(s4);
|
||||
d.scale = obj.scale;
|
||||
d.lightSource = obj.lightSource;
|
||||
d.shakeTimer = obj.shakeTimer;
|
||||
d.internalSound = obj.internalSound;
|
||||
d.specialVariable = obj.specialVariable;
|
||||
d.category = obj.category;
|
||||
d.specialItem = obj.specialItem;
|
||||
d.hasBeenInInventory = obj.hasBeenInInventory;
|
||||
string t = obj.texturePath;
|
||||
|
||||
// Log.AsyncC(t);
|
||||
|
||||
d.TextureSheet = Game1.content.Load<Texture2D>(t);
|
||||
d.texturePath = t;
|
||||
JArray array = obj.inventory;
|
||||
d.inventory = array.ToObject<List<Item>>();
|
||||
d.inventoryMaxSize = obj.inventoryMaxSize;
|
||||
d.itemReadyForHarvest = obj.itemReadyForHarvest;
|
||||
d.lightsOn = obj.lightsOn;
|
||||
// d.thisLocation = Game1.getLocationFromName(loc);
|
||||
// d.thisLocation = obj.thisLocation;
|
||||
Log.AsyncC(d.thisLocation);
|
||||
d.lightColor = obj.lightColor;
|
||||
d.thisType = obj.thisType;
|
||||
d.removable = obj.removable;
|
||||
d.locationsName = obj.locationsName;
|
||||
|
||||
d.drawColor = obj.drawColor;
|
||||
|
||||
try
|
||||
{
|
||||
return d;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.AsyncM(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public static void serializeBagOfHolding(Item d)
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (BagofHolding)d);
|
||||
}
|
||||
|
||||
public static Quarry parseQuarry(string data)
|
||||
{
|
||||
|
|
|
@ -53,8 +53,62 @@ namespace Revitalize
|
|||
return new Microsoft.Xna.Framework.Rectangle(Convert.ToInt32(parsed[2]), Convert.ToInt32(parsed[4]), Convert.ToInt32(parsed[6]), Convert.ToInt32(parsed[8]));
|
||||
}
|
||||
|
||||
public static bool addItemToOtherInventory(List<Item> inventory, Item I)
|
||||
{
|
||||
if (I == null) return false;
|
||||
if (isInventoryFull(inventory) == false)
|
||||
{
|
||||
|
||||
for (int i=0; i<inventory.Capacity;i++)
|
||||
{
|
||||
|
||||
if (inventory == null)
|
||||
{
|
||||
Log.AsyncC("WHY NULL???");
|
||||
}
|
||||
if (inventory.Count == 0)
|
||||
{
|
||||
inventory.Add(I);
|
||||
return true;
|
||||
}
|
||||
if (inventory[i] == null)
|
||||
{
|
||||
inventory[i] = I;
|
||||
continue;
|
||||
}
|
||||
if (inventory.ElementAt(i).canStackWith(I))
|
||||
{
|
||||
I.addToStack(I.getStack());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory.Add(I);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inventory.Add(I);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static bool isInventoryFull(List<Item> inventory)
|
||||
{
|
||||
// Log.AsyncG("size "+inventory.Count);
|
||||
// Log.AsyncG("max "+inventory.Capacity);
|
||||
if (inventory.Count == inventory.Capacity) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool addItemToInventoryElseDrop(Item I)
|
||||
{
|
||||
if (I == null) return false;
|
||||
if (Game1.player.isInventoryFull() == false)
|
||||
{
|
||||
Game1.player.addItemToInventoryBool(I, false);
|
||||
|
@ -70,6 +124,27 @@ namespace Revitalize
|
|||
}
|
||||
}
|
||||
|
||||
public static bool addItemToInventorySilently(Item I)
|
||||
{
|
||||
if (I == null) return false;
|
||||
if (Game1.player.isInventoryFull() == false)
|
||||
{
|
||||
Game1.player.addItemToInventory(I);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Random random = new Random(129);
|
||||
int i = random.Next();
|
||||
i = i % 4;
|
||||
Vector2 v2 = new Vector2(Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
|
||||
Game1.createItemDebris(I, v2, i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool addItemToInventoryAndCleanTrackedList(CoreObject I)
|
||||
{
|
||||
if (Game1.player.isInventoryFull() == false)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue