Created a TestMachine, a machine inventory UI, and made it so you can serialize objects in the world using XML.

This commit is contained in:
2017-06-08 17:34:52 -07:00
parent d05198cd56
commit cf57035e0a
11 changed files with 1942 additions and 672 deletions

View File

@ -323,6 +323,7 @@ namespace Revitalize
TextureDataNode font;
Dictionaries.spriteFontList.TryGetValue("0", out font);
objShopList.Add(new TestMachine(3, Vector2.Zero, Util.invertColor(LightColors.White), LightColors.White, false, 9, true));
objShopList.Add(new SpriteFontObject(0, Vector2.Zero, font.path, Color.White));
objShopList.Add(new Magic.Alchemy.Objects.BagofHolding(0, Vector2.Zero, new List<List<Item>>()
{
@ -343,6 +344,7 @@ namespace Revitalize
objShopList.Add(new Light(0, Vector2.Zero, LightColors.Aquamarine,LightColors.Aquamarine,false));
objShopList.Add(new Quarry(3, Vector2.Zero,9,"copper"));
objShopList.Add(new Quarry(3, Vector2.Zero, 9, "iron"));
objShopList.Add(new Spawner(3, Vector2.Zero, 9));
// objShopList.Add(new StardewValley.Tools.Raft());
objShopList.Add(new Decoration(3, Vector2.Zero));
objShopList.Add(new StardewValley.Object(495, 1));
@ -412,6 +414,11 @@ namespace Revitalize
newDebris();
}
if (e.KeyPressed.ToString() == "U")
{
Serialize.cleanUpWorld();
}
if (e.KeyPressed.ToString() == "G")
{
WeatherDebrisSystem.speedUpWindAndClear(0.001f);

View File

@ -0,0 +1,825 @@
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;
using Revitalize.Objects.Generic;
using Revitalize.Resources;
using Revitalize.Resources.DataNodes;
using System.IO;
using Revitalize.Objects;
namespace Revitalize.Menus.Machines
{
public class MachineInventory : MenuWithInventory
{
public delegate void behaviorOnItemSelect(Item item, StardewValley.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 inputInventory;
private StardewValley.Menus.InventoryMenu outputInventory;
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 MachineInventory.behaviorOnItemSelect behaviorFunction;
public MachineInventory.behaviorOnItemSelect behaviorOnItemGrab;
private Item hoverItem;
private Item sourceItem;
private ClickableTextureComponent organizeButton;
private ClickableTextureComponent LeftButton;
private ClickableTextureComponent RightButton;
private ClickableTextureComponent colorPickerToggleButton;
private ClickableTextureComponent lastShippedHolder;
public int source;
private bool snappedtoBottom;
private DiscreteColorPicker chestColorPicker;
public int capacity;
public int Rows;
public Revitalize.Objects.Machines.Machine machine;
public MachineInventory(Revitalize.Objects.Machines.Machine Machine, List<Item> InputInventory,List<Item> OutputInventory, int rows) : base(null, true, true, 0, 0)
{
machine = Machine;
Rows = rows;
Log.AsyncC(InputInventory.Capacity);
this.inputInventory = new StardewValley.Menus.InventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, InputInventory, null, 9, 3, 0, 0, true);
this.outputInventory = new StardewValley.Menus.InventoryMenu(this.xPositionOnScreen + Game1.tileSize *8, this.yPositionOnScreen, false, OutputInventory, null, 9, 3, 0, 0, true);
Log.AsyncM(this.inputInventory.actualInventory.Capacity);
this.inputInventory.capacity = 9;
this.outputInventory.capacity = 9;
this.inputInventory.actualInventory.Capacity = 9;
this.outputInventory.actualInventory.Capacity = 9;
// 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);
TextureDataNode d;
Dictionaries.spriteFontList.TryGetValue("leftArrow", out d);
TextureDataNode f;
Dictionaries.spriteFontList.TryGetValue("rightArrow", out f);
this.LeftButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 3, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), d.texture, new Rectangle(0, 0, 16, 16), 4f, false);
this.RightButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), f.texture, new Rectangle(0, 0, 16, 16), 4f, false);
this.inventory.showGrayedOutSlots = true;
}
public MachineInventory(Revitalize.Objects.Machines.Machine Machine, List<Item> InputInventory,List<Item> OutputInventory, int rows, bool reverseGrab, bool showReceivingMenu, InventoryMenu.highlightThisItem highlightFunction, MachineInventory.behaviorOnItemSelect behaviorOnItemSelectFunction, string message, MachineInventory.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.machine = Machine;
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;
this.Rows = rows;
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.inputInventory = new InventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, InputInventory, highlightFunction, 9, 3, 0, 0, true);
this.outputInventory = new StardewValley.Menus.InventoryMenu(this.xPositionOnScreen + Game1.tileSize * 8, this.yPositionOnScreen, false, OutputInventory, null, 9, 3, 0, 0, true);
Log.AsyncM(this.inputInventory.actualInventory.Capacity);
this.inputInventory.capacity = 9;
this.inputInventory.capacity = 9;
this.inputInventory.actualInventory.Capacity = 9;
this.outputInventory.actualInventory.Capacity = 9;
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.inputInventory.actualInventory.Count > 0 && Game1.activeClickableMenu == null)
{
Game1.setMousePosition(this.inventory.inventory[0].bounds.Center);
}
TextureDataNode d;
Dictionaries.spriteFontList.TryGetValue("leftArrow", out d);
TextureDataNode f;
Dictionaries.spriteFontList.TryGetValue("rightArrow", out f);
this.LeftButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 3, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), d.texture, new Rectangle(0, 0, 16, 16), 4f, false);
this.RightButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), f.texture, new Rectangle(0, 0, 16, 16), 4f, false);
}
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.inputInventory.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 MachineInventory)
{
(Game1.activeClickableMenu as MachineInventory).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 MachineInventory)
{
(Game1.activeClickableMenu as MachineInventory).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.inputInventory != null)
{
this.inputInventory.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);
// Item test= this.inputInventory.leftClick(x, y, this.heldItem, false);
Item test = this.heldItem;
/*
if (test == machine)
{
if ((test as ExpandableInventoryObject).inventory == expandableObject.inventory)
{
if (this.inputInventory.isWithinBounds(x, y) == false)
{
//if this is within my inventory return. Don't want to shove a bag into itself.
return;
}
}
}
*/
if (this.organizeButton.containsPoint(x, y))
{
MachineInventory.organizeItemsInList(this.inputInventory.actualInventory);
}
if (this.organizeButton.containsPoint(x, y))
{
MachineInventory.organizeItemsInList(this.outputInventory.actualInventory);
}
if (inventory.isWithinBounds(x, y) == true)
{
if (this.inputInventory.actualInventory == null)
{
Log.AsyncG("WTF HOW IS THIS NULL!?!?!?!?!");
}
bool f = Util.isInventoryFull(this.inputInventory.actualInventory,true);
if (f == false)
{
this.heldItem = this.inputInventory.leftClick(x, y, this.heldItem, false);
if (this.heldItem != null)
{
//if (Serialize.WriteToXMLFileSafetyCheck(Path.Combine(Serialize.PlayerDataPath, ""), i, false) == false)
//{
// return;
// }
Util.addItemToOtherInventory(this.inputInventory.actualInventory, this.heldItem);
// Log.AsyncG("item swap");
if (this.machine == null) Log.AsyncC("OK MY MACHINE IS NULL");
if (this.inputInventory == null) Log.AsyncG("Input is null");
if (this.outputInventory == null) Log.AsyncO("output is null");
//Game1.activeClickableMenu = new MachineInventory(this.machine, this.inputInventory.actualInventory,this.outputInventory.actualInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
Game1.activeClickableMenu = new Revitalize.Menus.Machines.MachineInventory(this.machine, this.inputInventory.actualInventory, this.outputInventory.actualInventory, 3);
// Game1.playSound("Ship");
this.heldItem = null;
return;
// Log.AsyncG("not full");
}
}
else
{
Log.AsyncO("Inventory is full?????");
return;
}
// this.inputInventory.inventory.Add(new ClickableComponent(new Rectangle(inputInventory.xPositionOnScreen + inputInventory.actualInventory.Count-1 % (this.capacity / this.inputInventory.rows) * Game1.tileSize + this.inputInventory.horizontalGap * (inputInventory.actualInventory.Count-1 % (this.capacity / this.inputInventory.rows)), inputInventory.yPositionOnScreen + inputInventory.actualInventory.Count-1 / (this.capacity / this.inputInventory.rows) * (Game1.tileSize + this.inputInventory.verticalGap) + (inputInventory.actualInventory.Count-1 / (this.capacity / this.inputInventory.rows) - 1) * Game1.pixelZoom - (Game1.tileSize / 5), Game1.tileSize, Game1.tileSize), string.Concat(inputInventory.actualInventory.Count-1)));
if (this.okButton.containsPoint(x, y) == false && this.organizeButton.containsPoint(x, y) == false && f == false && this.LeftButton.containsPoint(x, y) == false && this.RightButton.containsPoint(x, y) == false)
{
//
Game1.activeClickableMenu = new Revitalize.Menus.Machines.MachineInventory(this.machine, this.inputInventory.actualInventory, this.outputInventory.actualInventory, 3);
//Game1.activeClickableMenu = new MachineInventory(this.machine, machine.inputInventory,machine.outputInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
// Game1.playSound("Ship");
}
}
else if (outputInventory.isWithinBounds(x, y) == true)
{
//outputInventory.actualInventory.Add(new Decoration(3, Vector2.Zero));
if (this.outputInventory.actualInventory == null)
{
Log.AsyncG("WTF HOW IS THIS NULL!?!?!?!?!");
}
this.heldItem = this.outputInventory.leftClick(x, y, this.heldItem, false);
if (this.heldItem != null)
{
// if (Serialize.WriteToXMLFileSafetyCheck(Path.Combine(Serialize.PlayerDataPath, ""), this.heldItem, false) == false)
// {
// return;
// }
foreach (ClickableComponent current in outputInventory.inventory)
{
if (current.containsPoint(x, y))
{
int num = Convert.ToInt32(current.name);
// Log.AsyncO(num);
this.outputInventory.actualInventory.RemoveAt(num);
// Log.AsyncO("Remaining " + inputInventory.actualInventory.Count);
}
}
// j= this.inputInventory.leftClick(x, y, this.heldItem, false);
Util.addItemToInventoryElseDrop(this.heldItem);
this.heldItem = null;
return;
}
//Util.addItemToOtherInventory(this.inputInventory.actualInventory, this.heldItem);
// Log.AsyncG("not full");
// this.inputInventory.inventory.Add(new ClickableComponent(new Rectangle(inputInventory.xPositionOnScreen + inputInventory.actualInventory.Count-1 % (this.capacity / this.inputInventory.rows) * Game1.tileSize + this.inputInventory.horizontalGap * (inputInventory.actualInventory.Count-1 % (this.capacity / this.inputInventory.rows)), inputInventory.yPositionOnScreen + inputInventory.actualInventory.Count-1 / (this.capacity / this.inputInventory.rows) * (Game1.tileSize + this.inputInventory.verticalGap) + (inputInventory.actualInventory.Count-1 / (this.capacity / this.inputInventory.rows) - 1) * Game1.pixelZoom - (Game1.tileSize / 5), Game1.tileSize, Game1.tileSize), string.Concat(inputInventory.actualInventory.Count-1)));
if (this.okButton.containsPoint(x, y) == false && this.organizeButton.containsPoint(x, y) == false && this.LeftButton.containsPoint(x, y) == false && this.RightButton.containsPoint(x, y) == false)
{
//
Game1.activeClickableMenu = new Revitalize.Menus.Machines.MachineInventory(this.machine, this.inputInventory.actualInventory, this.outputInventory.actualInventory, 3);
//Game1.activeClickableMenu = new MachineInventory(this.machine, machine.inputInventory,machine.outputInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
// Game1.playSound("Ship");
}
}
else if(inputInventory.isWithinBounds(x,y)==true)
{
if (Game1.player.isInventoryFull() == true)
{
Item i = new StardewValley.Object();
Item j = new StardewValley.Object();
j = this.inputInventory.leftClick(x, y, this.heldItem, false);
i = this.heldItem;
if (i != null)
{
//if (Serialize.WriteToXMLFileSafetyCheck(Path.Combine(Serialize.PlayerDataPath, ""), i, false) == false)
//{
// return;
// }
}
Util.addItemToInventoryElseDrop(this.heldItem);
// this.heldItem = null;
foreach (ClickableComponent current in inputInventory.inventory)
{
if (current.containsPoint(x, y))
{
int num = Convert.ToInt32(current.name);
// Log.AsyncO(num);
this.inputInventory.actualInventory.RemoveAt(num);
// Log.AsyncO("Remaining " + inputInventory.actualInventory.Count);
}
}
// j= this.inputInventory.leftClick(x, y, this.heldItem, false);
// Util.addItemToOtherInventory(this.inputInventory.actualInventory, i);
// Log.AsyncG("item swap");
if (this.machine == null) Log.AsyncC("OK MY MACHINE IS NULL");
if (this.inputInventory == null) Log.AsyncG("Input is null");
if (this.outputInventory == null) Log.AsyncO("output is null");
//Game1.activeClickableMenu = new MachineInventory(this.machine, this.inputInventory.actualInventory,this.outputInventory.actualInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
Game1.activeClickableMenu = new Revitalize.Menus.Machines.MachineInventory(this.machine, this.inputInventory.actualInventory, this.outputInventory.actualInventory, 3);
// Game1.playSound("Ship");
this.heldItem = null;
return;
}
this.heldItem = this.inputInventory.leftClick(x, y, this.heldItem, false);
Util.addItemToInventoryElseDrop(this.heldItem);
this.heldItem = null;
foreach (ClickableComponent current in inputInventory.inventory)
{
if (current.containsPoint(x, y))
{
int num = Convert.ToInt32(current.name);
// Log.AsyncO(num);
this.inputInventory.actualInventory.RemoveAt(num);
// Log.AsyncO("Remaining " + inputInventory.actualInventory.Count);
}
}
Game1.activeClickableMenu = new MachineInventory(this.machine, this.inputInventory.actualInventory,this.outputInventory.actualInventory ,this.Rows, 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.inputInventory.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 MachineInventory)
{
(Game1.activeClickableMenu as MachineInventory).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 MachineInventory)
{
(Game1.activeClickableMenu as MachineInventory).setSourceItem(this.sourceItem);
}
if (this.destroyItemOnClick)
{
this.heldItem = null;
return;
}
}
if (this.organizeButton != null && this.organizeButton.containsPoint(x, y))
{
MachineInventory.organizeItemsInList(this.inputInventory.actualInventory);
Game1.activeClickableMenu = new MachineInventory(this.machine, this.inputInventory.actualInventory,this.outputInventory.actualInventory, this.Rows, 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.inputInventory.actualInventory.Count; i++)
{
if (this.inputInventory.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.inputInventory.isWithinBounds(x, y) && this.showReceivingMenu)
{
if (inputInventory.actualInventory.Count == 0) return;
this.hoveredItem = this.inputInventory.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)
{
// Game1.drawDialogueBox(this.inputInventory.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder, this.inputInventory.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder, this.inputInventory.width + IClickableMenu.borderWidth * 2 + IClickableMenu.spaceToClearSideBorder * 2, this.inputInventory.height + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth * 2, false, true, null, false);
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.inputInventory.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder, this.inputInventory.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder, this.inputInventory.width + IClickableMenu.borderWidth * 2 + IClickableMenu.spaceToClearSideBorder * 2, this.inputInventory.height + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth * 2, false, true, null, false);
Game1.drawDialogueBox(this.outputInventory.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder, this.outputInventory.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder, this.outputInventory.width + IClickableMenu.borderWidth * 2 + IClickableMenu.spaceToClearSideBorder * 2, this.outputInventory.height + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth * 2, false, true, null, false);
this.inputInventory.draw(b);
this.outputInventory.draw(b);
}
else if (this.message != null)
{
Game1.drawDialogueBox(Game1.viewport.Width / 2, this.inputInventory.yPositionOnScreen + this.inputInventory.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.inputInventory == 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.inputInventory != null)
{
IClickableMenu.drawToolTip(b, this.inputInventory.descriptionText, this.inputInventory.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;
//this.LeftButton.draw(b);
//this.RightButton.draw(b);
base.drawMouse(b);
}
/*
public void getNextInventory(bool getPrevious)
{
if (getPrevious == false)
{
if (expandableObject.inventoryIndex < expandableObject.allInventories.Count - 1)
{
expandableObject.inventoryIndex++;
expandableObject.inventory = expandableObject.allInventories[expandableObject.inventoryIndex];
Game1.activeClickableMenu = new MachineInventory(this.expandableObject, expandableObject.inventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
return;
}
else
{
return;
}
}
else
{
if (expandableObject.inventoryIndex > 0)
{
expandableObject.inventoryIndex--;
expandableObject.inventory = expandableObject.allInventories[expandableObject.inventoryIndex];
Game1.activeClickableMenu = new MachineInventory(this.expandableObject, expandableObject.inventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
return;
}
else
{
return;
}
}
}
*/
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Revitalize.Menus
{
class SpriteKeyboard
{
}
}

View File

@ -18,7 +18,7 @@ namespace Revitalize
/// Revitalize CoreObject Class. This is a core class and should only be extended upon.
/// </summary>
///
[XmlInclude(typeof(Revitalize.Objects.Light)),XmlInclude(typeof(Revitalize.Objects.SpriteFontObject))]
[XmlInclude(typeof(Revitalize.Objects.Light)),XmlInclude(typeof(Revitalize.Objects.SpriteFontObject)), XmlInclude(typeof(Revitalize.Objects.Machines.Machine)), XmlInclude(typeof(Revitalize.Objects.Machines.TestMachine))]
public class CoreObject : StardewValley.Object
{
public const int chair = 0;
@ -101,6 +101,8 @@ namespace Revitalize
public Color drawColor;
public bool useXML;
public override string Name
{
get
@ -1454,7 +1456,7 @@ public override bool isPlaceable()
public virtual void spillInventoryEverywhere()
{
Game1.activeClickableMenu = new StorageContainer(this.inventory, this.inventoryMaxSize, 3);
Game1.activeClickableMenu = new StorageContainer(this.inventory, 3, 3);
this.itemReadyForHarvest = false;
/*
Log.AsyncC("DROPPING INVENTORY!");

File diff suppressed because it is too large Load Diff

View File

@ -340,7 +340,7 @@ namespace Revitalize.Objects.Machines
this.thisLocation = null;
return true;
}
this.showUI();
// this.showUI();
return false;
}

View File

@ -0,0 +1,880 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Revitalize.Resources;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Locations;
using StardewValley.Menus;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
namespace Revitalize.Objects.Machines
{
/// <summary>
/// Machine Core class. Only extend off of this.
/// </summary>
///
public class TestMachine : Revitalize.Objects.Machines.Machine
{
public List<Item> inputInventory;
public List<Item> outputInventory;
public bool areLightAndDrawColorsDifferent;
public override string Name
{
get
{
return this.name;
}
}
public override void InitializeBasics(int InvMaxSize, Vector2 tile)
{
this.inventory = new List<Item>();
this.inputInventory = new List<Item>();
this.inventory = this.inputInventory;
this.outputInventory = new List<Item>();
this.inventoryMaxSize = InvMaxSize;
this.tileLocation = tile;
lightsOn = false;
lightColor = Color.Black;
thisType = this.GetType().ToString();
this.inventory.Capacity = inventoryMaxSize;
this.inputInventory.Capacity = inventoryMaxSize;
this.outputInventory.Capacity = inventoryMaxSize;
}
public TestMachine()
{
this.updateDrawPosition();
}
public TestMachine(bool f)
{
//does nothng
}
public TestMachine(int which, Vector2 Tile, Color LightColor, Color DrawColor, bool differentColors = true, int InventoryMaxSize = 0, bool isRemovable = true)
{
this.useXML = true;
removable = isRemovable;
this.InitializeBasics(InventoryMaxSize, Tile);
this.lightColor = LightColor;
this.drawColor = DrawColor;
this.minutesUntilReady = 10;
areLightAndDrawColorsDifferent = differentColors;
TextureSheet = Game1.content.Load<Texture2D>(Path.Combine("Revitalize", "Lights", "AdjustableLights", "Graphics", "AdjustableLights"));
texturePath = Path.Combine("Revitalize", "Lights", "AdjustableLights", "Graphics", "AdjustableLights");
Dictionary<int, string> dictionary = Game1.content.Load<Dictionary<int, string>>(Path.Combine("Revitalize", "Lights", "AdjustableLights", "Data", "AdjustableLights"));
string[] array = dictionary[which].Split(new char[]
{
'/'
});
this.name = array[0];
this.Decoration_type = 1;
try
{
this.description = array[6];
}
catch (Exception err)
{
this.description = "A light thats color can be adjusted.";
}
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(StardewValley.Farmer who)
{
this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation);
return false;
}
public override void resetOnPlayerEntry(GameLocation environment)
{
if (Game1.isDarkOut() || Game1.timeOfDay <= 500)
{
this.addLights(thisLocation);
}
base.resetOnPlayerEntry(environment);
}
public override void hoverAction()
{
base.hoverAction();
if (!Game1.player.isInventoryFull())
{
Game1.mouseCursor = 2;
}
}
public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false)
{
var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
{
return this.RightClicked(who);
// Game1.showRedMessage("YOOO");
//do some stuff when the right button is down
// rotate();
if (this.heldObject != null)
{
// Game1.player.addItemByMenuIfNecessary(this.heldObject);
// this.heldObject = null;
}
else
{
// this.heldObject = Game1.player.ActiveObject;
// Game1.player.removeItemFromInventory(heldObject);
}
//this.minutesUntilReady = 30;
}
else
{
//Game1.showRedMessage("CRY");
}
if (justCheckingForActivity)
{
return true;
}
return this.clicked(who);
}
//DONT USE THIS BASE IT IS TERRIBLE
public override bool clicked(StardewValley.Farmer who)
{
// Game1.showRedMessage("THIS IS CLICKED!!!");
//var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
if (removable == false) return false;
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 Light)))
{
if (Game1.player.currentLocation is FarmHouse)
{
//
Util.addItemToInventoryAndCleanTrackedList(this);
removeLights(this.thisLocation);
this.lightsOn = false;
Game1.playSound("coin");
// this.flaggedForPickUp = true;
thisLocation = null;
return true;
}
else
{
// return true;
// this.heldObject = new Light(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize);
Util.addItemToInventoryAndCleanTrackedList(this);
removeLights(this.thisLocation);
this.lightsOn = false;
Game1.playSound("coin");
thisLocation = null;
return true;
}
}
if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false))
{
// Game1.showRedMessage("Why3?");
// if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject);
Util.addItemToInventoryAndCleanTrackedList(this);
this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
this.heldObject = null;
Game1.playSound("coin");
removeLights(this.thisLocation);
this.lightsOn = false;
thisLocation = null;
return true;
}
return false;
}
public override bool RightClicked(StardewValley.Farmer who)
{
//Game1.activeClickableMenu = new Revitalize.Menus.LightCustomizer(this);
if (this.inputInventory == null)
{
Log.AsyncG(">>>>>>>>??????????????????>>>>>>>>>>>>>");
}
if (this.outputInventory == null)
{
Log.AsyncC(">??????????????");
}
Log.AsyncM(this.GetType());
// this.outputInventory.Add(new Revitalize.Objects.Light(0, Vector2.Zero, LightColors.Azure, LightColors.Azure));
Game1.activeClickableMenu = new Revitalize.Menus.Machines.MachineInventory(this, this.inputInventory, this.outputInventory, 3);
return false;
}
public override void DayUpdate(GameLocation location)
{
base.DayUpdate(location);
this.lightGlowAdded = false;
if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining) || Game1.timeOfDay <= 500)
{
this.removeLights(location);
return;
}
// this.addLights(thisLocation, lightColor);
this.addLights(thisLocation, lightColor);
}
public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who)
{
// Log.AsyncG("HEY!");
if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is Light) || ((dropIn as Light).getTilesWide() == 1 && (dropIn as Light).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 Light).Decoration_type));
this.heldObject.performDropDownAction(who);
if (!probe)
{
Game1.playSound("woodyStep");
// Log.AsyncC("HUH?");
if (who != null)
{
who.reduceActiveItemByOne();
}
}
return true;
}
return false;
}
public override bool minutesElapsed(int minutes, GameLocation environment)
{
this.minutesUntilReady = (this.minutesUntilReady - minutes);
if (Game1.isDarkOut() || Game1.timeOfDay <= 500)
{
this.addLights(thisLocation);
}
if (minutesUntilReady == 0)
{
minutesUntilReady = 10;
if(Util.isInventoryFull(this.outputInventory) == false)
{
Util.addItemToOtherInventory(this.outputInventory,(Item)(new StardewValley.Object(388, 1)));
}
}
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;
}
this.spillInventoryEverywhere();
base.performRemoveAction(tileLocation, environment);
}
public override bool isGroundFurniture()
{
return this.Decoration_type != 13 && this.Decoration_type != 6 && this.Decoration_type != 13;
}
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("Light"))
{
Light current = (Light)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);
}
}
return Util.canBePlacedHere(this, l, tile);
}
}
public override void updateDrawPosition()
{
this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)));
}
public override int getTilesWide()
{
return this.boundingBox.Width / Game1.tileSize;
}
public override int getTilesHigh()
{
return this.boundingBox.Height / Game1.tileSize;
}
public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
{
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 * Game1.tileSize, y / Game1.tileSize * 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("Spawner"))
{
Decoration current2 = (Decoration)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 (StardewValley.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();
// Log.AsyncO(this.boundingBox);
// Log.AsyncO(x);
// Log.AsyncY(y);
for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++)
{
Util.placementAction(this, location, x + 1, y, who);
}
for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++)
{
Util.placementAction(this, location, x + 1, y, 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;
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 * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
foreach (StardewValley.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);
}
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, StardewValley.Farmer f)
{
if (TextureSheet == null)
{
TextureSheet = Game1.content.Load<Texture2D>(texturePath);
}
if (areLightAndDrawColorsDifferent == false) spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Util.invertColor(this.lightColor), 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
else
{
spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Util.invertColor(this.drawColor), 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
}
/*
if (f.ActiveObject != null && f.ActiveObject.Name.Contains("="))
{
spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97)
{
return;
}
Game1.starCropShimmerPause += 0.04f;
if (Game1.starCropShimmerPause >= 0.8f)
{
Game1.starCropShimmerPause = -0.8f;
}
}
*/
}
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber)
{
if (TextureSheet == null)
{
TextureSheet = Game1.content.Load<Texture2D>(texturePath);
}
if (areLightAndDrawColorsDifferent == false) spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Util.invertColor(this.lightColor), 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize, SpriteEffects.None, layerDepth);
else
{
spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Util.invertColor(this.drawColor), 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 (TextureSheet == null)
{
TextureSheet = Game1.content.Load<Texture2D>(texturePath);
}
if (x == -1)
{
if (areLightAndDrawColorsDifferent == false) spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Util.invertColor(this.lightColor) * 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, this.drawPosition), new Rectangle?(this.sourceRect), Util.invertColor(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
{
if (areLightAndDrawColorsDifferent == false) 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), Util.invertColor(this.lightColor) * 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), Util.invertColor(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 Light)
{
(this.heldObject as Light).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as Spell).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha);
return;
}
if (areLightAndDrawColorsDifferent == false)
{
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), Util.invertColor(this.lightColor) * 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)), Util.invertColor(this.lightColor) * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
}
else
{
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), Util.invertColor(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)), Util.invertColor(this.drawColor) * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
}
}
}
public override void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f)
{
if (TextureSheet == null)
{
TextureSheet = Game1.content.Load<Texture2D>(texturePath);
}
spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Util.invertColor(this.drawColor) * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
}
public override Item getOne()
{
TestMachine Light = new TestMachine(this.parentSheetIndex, this.tileLocation, this.lightColor, this.drawColor, this.areLightAndDrawColorsDifferent);
/*
drawPosition = this.drawPosition;
defaultBoundingBox = this.defaultBoundingBox;
boundingBox = this.boundingBox;
currentRotation = this.currentRotation - 1;
rotations = this.rotations;
rotate();
*/
return Light;
}
public override string getCategoryName()
{
return "Machine";
// return base.getCategoryName();
}
public override Color getCategoryColor()
{
return Util.invertColor(LightColors.Black);
}
public static TestMachine ParseObject(string data)
{
TestMachine h = Serialize.ReadFromXMLFile<TestMachine>(data);
return h;
}
public static void SerializeObject(Item d)
{
Serialize.WriteToXMLFile<TestMachine>(Path.Combine(Serialize.InvPath, d.Name + ".xml"), (TestMachine)d);
// Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (BagofHolding)d);
}
public static void SerializeObjectFromWorld(CoreObject d)
{
Serialize.WriteToXMLFile(Path.Combine(Serialize.objectsInWorldPath, d.thisLocation.name, d.Name + ".xml"), (TestMachine)d);
}
}
}

View File

@ -68,7 +68,8 @@ namespace Revitalize.Resources
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));
}
acceptedTypes.Add("Revitalize.Objects.Machines.TestMachine", new SerializerDataNode(new ser(Revitalize.Objects.Machines.TestMachine.SerializeObject), new par(Objects.Machines.TestMachine.ParseObject), new world(Objects.Machines.TestMachine.SerializeObjectFromWorld)));
}
public static void addAllInteractionTypes()
{

View File

@ -56,8 +56,10 @@
<Compile Include="Aesthetics\WeatherDebris\WeatherDebrisPlus.cs" />
<Compile Include="Aesthetics\WeatherDebris\WeatherDebrisSystem.cs" />
<Compile Include="Menus\CarpenterMenu.cs" />
<Compile Include="Menus\Machines\MachineInventory.cs" />
<Compile Include="Menus\MenuComponents\ClickableComponentsExtended.cs" />
<Compile Include="Menus\MenuComponents\ClickableTextureComponentExpanded.cs" />
<Compile Include="Objects\Machines\TestMachine.cs" />
<Compile Include="Settings\MachineSettings.cs" />
<Compile Include="Settings\MagicSettings.cs" />
<Compile Include="Settings\PaintSettings.cs" />
@ -80,7 +82,6 @@
<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" />

View File

@ -44,6 +44,7 @@ namespace Revitalize
ProcessDirectoryForDeletion(objectsInWorldPath);
List<CoreObject> removalList = new List<CoreObject>();
int countProcessed = 0;
List<Item> idk = new List<Item>();
foreach (CoreObject d in Lists.trackedObjectList)
{
try
@ -69,7 +70,14 @@ namespace Revitalize
if (works == true)
{
countProcessed++;
t.worldObj.Invoke(d);
if (d.useXML == false)
{
t.worldObj.Invoke(d);
}
else
{
idk.Add(d);
}
Log.AsyncC("Progress on saving objects: " + countProcessed + "/" + Lists.trackedObjectList.Count);
removalList.Add(d);
}
@ -79,8 +87,29 @@ namespace Revitalize
{
i.thisLocation.removeObject(i.tileLocation, false);
}
removalList.Clear();
foreach(var v in idk)
{
string s = Convert.ToString((v.GetType()));
if (Dictionaries.acceptedTypes.ContainsKey(s))
{
SerializerDataNode t;
bool works = Dictionaries.acceptedTypes.TryGetValue(s, out t);
if (works == true)
{
countProcessed++;
if ((v as CoreObject).useXML == true)
{
t.worldObj.Invoke(v as CoreObject);
}
Log.AsyncG("Progress on saving objects: " + countProcessed + "/" + Lists.trackedObjectList.Count);
removalList.Add(v as CoreObject);
}
}
}
removalList.Clear();
Log.AsyncM("Revitalize: Done cleaning world for saving.");
}
@ -372,8 +401,8 @@ namespace Revitalize
{
// Create an instance of the XmlSerializer class;
// specify the type of object to serialize.
XmlSerializer serializer =
new XmlSerializer(typeof(T));
XmlSerializer serializer = new XmlSerializer(typeof(T));
TextWriter writer = new StreamWriter(filePath);
serializer.Serialize(writer, objectToWrite);
@ -1213,10 +1242,9 @@ namespace Revitalize
public static void serializeBagOfHolding(Item d)
{
WriteToXMLFile<BagofHolding>(Path.Combine(InvPath, d.Name + ".xml"), (BagofHolding)d);
// Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (BagofHolding)d);
// Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (BagofHolding)d);
}
public static Quarry parseQuarry(string data)
{
dynamic obj = JObject.Parse(data);

View File

@ -96,10 +96,14 @@ namespace Revitalize
return false;
}
}
public static bool isInventoryFull(List<Item> inventory)
public static bool isInventoryFull(List<Item> inventory, bool logInfo=false)
{
// Log.AsyncG("size "+inventory.Count);
// Log.AsyncG("max "+inventory.Capacity);
if (logInfo)
{
Log.AsyncG("size " + inventory.Count);
Log.AsyncG("max " + inventory.Capacity);
}
if (inventory.Count == inventory.Capacity) return true;
else return false;
}