Added in axes, watering cans, and hoes and default color swaps. Now to make content.
This commit is contained in:
parent
a4d8a4c1a8
commit
36e7b5e6ef
Binary file not shown.
After Width: | Height: | Size: 993 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -17,8 +17,15 @@ namespace Revitalize.Framework.Hacks
|
|||
public static class ColorChanger
|
||||
{
|
||||
|
||||
private static Texture2D mostRecentPicxaxeSwap;
|
||||
private static bool AxeNeedsReset;
|
||||
private static bool PickaxeNeedsReset;
|
||||
private static bool WateringCanNeedsReset;
|
||||
private static bool HoeNeedsReset;
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the colors for the pickaxe working animation.
|
||||
/// </summary>
|
||||
/// <param name="TargetTexture"></param>
|
||||
public static void SwapPickaxeTextures(Texture2D TargetTexture)
|
||||
{
|
||||
/*
|
||||
|
@ -108,19 +115,354 @@ namespace Revitalize.Framework.Hacks
|
|||
//Reapply the texture.
|
||||
Game1.toolSpriteSheet.SetData<Color>(beforeData);
|
||||
|
||||
Stream stream = File.Create(Path.Combine(ModCore.ModHelper.DirectoryPath,"ToolTest.png"));
|
||||
Game1.toolSpriteSheet.SaveAsPng(stream, width, height);
|
||||
stream.Dispose();
|
||||
//Stream stream = File.Create(Path.Combine(ModCore.ModHelper.DirectoryPath,"ToolTest.png"));
|
||||
//Game1.toolSpriteSheet.SaveAsPng(stream, width, height);
|
||||
//stream.Dispose();
|
||||
PickaxeNeedsReset = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the colors for the hoe animation.
|
||||
/// </summary>
|
||||
/// <param name="TargetTexture"></param>
|
||||
public static void SwapHoeTextures(Texture2D TargetTexture)
|
||||
{
|
||||
/*
|
||||
if (mostRecentPicxaxeSwap != null)
|
||||
{
|
||||
if (TargetTexture == mostRecentPicxaxeSwap) return;
|
||||
}
|
||||
*/
|
||||
int height = Game1.toolSpriteSheet.Height;
|
||||
int width = Game1.toolSpriteSheet.Width;
|
||||
|
||||
Color[] beforeData = new Color[Game1.toolSpriteSheet.Width * Game1.toolSpriteSheet.Height];
|
||||
Game1.toolSpriteSheet.GetData<Color>(beforeData);
|
||||
Color[] afterData = new Color[TargetTexture.Width * TargetTexture.Height]; //Get a color data to replace
|
||||
TargetTexture.GetData<Color>(afterData); //Get data from swap texture.
|
||||
|
||||
///Convert tool data to grid
|
||||
Color[,] beforeGrid = new Color[height, width];
|
||||
for (int row = 0; row < height; row++)
|
||||
{
|
||||
for (int column = 0; column < width; column++)
|
||||
{
|
||||
// Assumes row major ordering of the array.
|
||||
beforeGrid[row, column] = beforeData[row * width + column];
|
||||
}
|
||||
}
|
||||
//Convert target data to grid
|
||||
int targetHeight = TargetTexture.Height;
|
||||
int targetWidth = TargetTexture.Width;
|
||||
Color[,] afterGrid = new Color[targetHeight, targetWidth];
|
||||
for (int row = 0; row < targetHeight; row++)
|
||||
{
|
||||
for (int column = 0; column < targetWidth; column++)
|
||||
{
|
||||
// Assumes row major ordering of the array.
|
||||
afterGrid[row, column] = afterData[row * targetWidth + column];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Copy over data from the target texture into the before grid.
|
||||
Rectangle stoneRegion = new Rectangle(0, 16, 80, 32);
|
||||
Rectangle copperRegion = new Rectangle();
|
||||
Rectangle ironRegion = new Rectangle(224, 16, 80, 32); //Create the region we want to replace.
|
||||
Rectangle goldRegion = new Rectangle();
|
||||
Rectangle irridumRegon = new Rectangle();
|
||||
|
||||
List<Rectangle> rects = new List<Rectangle>();
|
||||
//rects.Add(ironRegion);
|
||||
rects.Add(stoneRegion);
|
||||
foreach (Rectangle region in rects)
|
||||
{
|
||||
|
||||
for (int x = region.X; x < region.X + region.Width; x++)
|
||||
{
|
||||
for (int y = region.Y; y < region.Y + region.Height; y++)
|
||||
{
|
||||
//ModCore.log("value is: " + new Vector2(x, y));
|
||||
beforeGrid[y, x] = afterGrid[(int)(y - region.Y), x - region.X]; //Row, column order aka y,x order.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Convert the tool grid back into a 1d color array
|
||||
for (int row = 0; row < height; row++)
|
||||
{
|
||||
for (int column = 0; column < width; column++)
|
||||
{
|
||||
try
|
||||
{
|
||||
beforeData[row * width + column] = beforeGrid[row, column];
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log("Setting pixel color at: " + new Vector2(column, row));
|
||||
ModCore.log("That's position: " + (row * width + column).ToString());
|
||||
}
|
||||
//ModCore.log("Setting pixel color at: " + new Vector2(column, row));
|
||||
//ModCore.log("That's position: " + (row * width + column).ToString());
|
||||
//beforeData[row * targetWidth + column] = beforeGrid[row,column];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//beforeGrid.CopyTo(beforeData, 0);
|
||||
//Reapply the texture.
|
||||
Game1.toolSpriteSheet.SetData<Color>(beforeData);
|
||||
HoeNeedsReset = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the colors for the axe working animation.
|
||||
/// </summary>
|
||||
/// <param name="TargetTexture"></param>
|
||||
public static void SwapAxeTextures(Texture2D TargetTexture)
|
||||
{
|
||||
/*
|
||||
if (mostRecentPicxaxeSwap != null)
|
||||
{
|
||||
if (TargetTexture == mostRecentPicxaxeSwap) return;
|
||||
}
|
||||
*/
|
||||
int height = Game1.toolSpriteSheet.Height;
|
||||
int width = Game1.toolSpriteSheet.Width;
|
||||
|
||||
Color[] beforeData = new Color[Game1.toolSpriteSheet.Width * Game1.toolSpriteSheet.Height];
|
||||
Game1.toolSpriteSheet.GetData<Color>(beforeData);
|
||||
Color[] afterData = new Color[TargetTexture.Width * TargetTexture.Height]; //Get a color data to replace
|
||||
TargetTexture.GetData<Color>(afterData); //Get data from swap texture.
|
||||
|
||||
///Convert tool data to grid
|
||||
Color[,] beforeGrid = new Color[height, width];
|
||||
for (int row = 0; row < height; row++)
|
||||
{
|
||||
for (int column = 0; column < width; column++)
|
||||
{
|
||||
// Assumes row major ordering of the array.
|
||||
beforeGrid[row, column] = beforeData[row * width + column];
|
||||
}
|
||||
}
|
||||
//Convert target data to grid
|
||||
int targetHeight = TargetTexture.Height;
|
||||
int targetWidth = TargetTexture.Width;
|
||||
Color[,] afterGrid = new Color[targetHeight, targetWidth];
|
||||
for (int row = 0; row < targetHeight; row++)
|
||||
{
|
||||
for (int column = 0; column < targetWidth; column++)
|
||||
{
|
||||
// Assumes row major ordering of the array.
|
||||
afterGrid[row, column] = afterData[row * targetWidth + column];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Copy over data from the target texture into the before grid.
|
||||
Rectangle stoneRegion = new Rectangle(0, 144, 80, 32);
|
||||
Rectangle copperRegion = new Rectangle();
|
||||
Rectangle ironRegion = new Rectangle(224, 144, 80, 32); //Create the region we want to replace.
|
||||
Rectangle goldRegion = new Rectangle();
|
||||
Rectangle irridumRegon = new Rectangle();
|
||||
|
||||
List<Rectangle> rects = new List<Rectangle>();
|
||||
//rects.Add(ironRegion);
|
||||
rects.Add(stoneRegion);
|
||||
foreach (Rectangle region in rects)
|
||||
{
|
||||
|
||||
for (int x = region.X; x < region.X + region.Width; x++)
|
||||
{
|
||||
for (int y = region.Y; y < region.Y + region.Height; y++)
|
||||
{
|
||||
//ModCore.log("value is: " + new Vector2(x, y));
|
||||
beforeGrid[y, x] = afterGrid[(int)(y - region.Y), x - region.X]; //Row, column order aka y,x order.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Convert the tool grid back into a 1d color array
|
||||
for (int row = 0; row < height; row++)
|
||||
{
|
||||
for (int column = 0; column < width; column++)
|
||||
{
|
||||
try
|
||||
{
|
||||
beforeData[row * width + column] = beforeGrid[row, column];
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log("Setting pixel color at: " + new Vector2(column, row));
|
||||
ModCore.log("That's position: " + (row * width + column).ToString());
|
||||
}
|
||||
//ModCore.log("Setting pixel color at: " + new Vector2(column, row));
|
||||
//ModCore.log("That's position: " + (row * width + column).ToString());
|
||||
//beforeData[row * targetWidth + column] = beforeGrid[row,column];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//beforeGrid.CopyTo(beforeData, 0);
|
||||
//Reapply the texture.
|
||||
Game1.toolSpriteSheet.SetData<Color>(beforeData);
|
||||
AxeNeedsReset = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the colors for the watering can working animation.
|
||||
/// </summary>
|
||||
/// <param name="TargetTexture"></param>
|
||||
public static void SwapWateringCanTextures(Texture2D TargetTexture)
|
||||
{
|
||||
/*
|
||||
if (mostRecentPicxaxeSwap != null)
|
||||
{
|
||||
if (TargetTexture == mostRecentPicxaxeSwap) return;
|
||||
}
|
||||
*/
|
||||
int height = Game1.toolSpriteSheet.Height;
|
||||
int width = Game1.toolSpriteSheet.Width;
|
||||
|
||||
Color[] beforeData = new Color[Game1.toolSpriteSheet.Width * Game1.toolSpriteSheet.Height];
|
||||
Game1.toolSpriteSheet.GetData<Color>(beforeData);
|
||||
Color[] afterData = new Color[TargetTexture.Width * TargetTexture.Height]; //Get a color data to replace
|
||||
TargetTexture.GetData<Color>(afterData); //Get data from swap texture.
|
||||
|
||||
///Convert tool data to grid
|
||||
Color[,] beforeGrid = new Color[height, width];
|
||||
for (int row = 0; row < height; row++)
|
||||
{
|
||||
for (int column = 0; column < width; column++)
|
||||
{
|
||||
// Assumes row major ordering of the array.
|
||||
beforeGrid[row, column] = beforeData[row * width + column];
|
||||
}
|
||||
}
|
||||
//Convert target data to grid
|
||||
int targetHeight = TargetTexture.Height;
|
||||
int targetWidth = TargetTexture.Width;
|
||||
Color[,] afterGrid = new Color[targetHeight, targetWidth];
|
||||
for (int row = 0; row < targetHeight; row++)
|
||||
{
|
||||
for (int column = 0; column < targetWidth; column++)
|
||||
{
|
||||
// Assumes row major ordering of the array.
|
||||
afterGrid[row, column] = afterData[row * targetWidth + column];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Copy over data from the target texture into the before grid.
|
||||
Rectangle stoneRegion = new Rectangle(0, 208, 80, 32);
|
||||
Rectangle copperRegion = new Rectangle();
|
||||
Rectangle ironRegion = new Rectangle(224, 208, 80, 32); //Create the region we want to replace.
|
||||
Rectangle goldRegion = new Rectangle();
|
||||
Rectangle irridumRegon = new Rectangle();
|
||||
|
||||
List<Rectangle> rects = new List<Rectangle>();
|
||||
//rects.Add(ironRegion);
|
||||
rects.Add(stoneRegion);
|
||||
foreach (Rectangle region in rects)
|
||||
{
|
||||
|
||||
for (int x = region.X; x < region.X + region.Width; x++)
|
||||
{
|
||||
for (int y = region.Y; y < region.Y + region.Height; y++)
|
||||
{
|
||||
//ModCore.log("value is: " + new Vector2(x, y));
|
||||
beforeGrid[y, x] = afterGrid[(int)(y - region.Y), x - region.X]; //Row, column order aka y,x order.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Convert the tool grid back into a 1d color array
|
||||
for (int row = 0; row < height; row++)
|
||||
{
|
||||
for (int column = 0; column < width; column++)
|
||||
{
|
||||
try
|
||||
{
|
||||
beforeData[row * width + column] = beforeGrid[row, column];
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log("Setting pixel color at: " + new Vector2(column, row));
|
||||
ModCore.log("That's position: " + (row * width + column).ToString());
|
||||
}
|
||||
//ModCore.log("Setting pixel color at: " + new Vector2(column, row));
|
||||
//ModCore.log("That's position: " + (row * width + column).ToString());
|
||||
//beforeData[row * targetWidth + column] = beforeGrid[row,column];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//beforeGrid.CopyTo(beforeData, 0);
|
||||
//Reapply the texture.
|
||||
Game1.toolSpriteSheet.SetData<Color>(beforeData);
|
||||
WateringCanNeedsReset = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the colors for the pickaxe.
|
||||
/// </summary>
|
||||
public static void ResetPickaxeTexture()
|
||||
{
|
||||
SwapPickaxeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultPickaxeWorking"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the colors for the hoe.
|
||||
/// </summary>
|
||||
public static void ResetHoeTexture()
|
||||
{
|
||||
SwapHoeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultHoeWorking"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the colors for the axe.
|
||||
/// </summary>
|
||||
public static void ResetAxeTexture()
|
||||
{
|
||||
SwapAxeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultAxeWorking"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the colors for the watering can.
|
||||
/// </summary>
|
||||
public static void ResetWateringCanTexture()
|
||||
{
|
||||
SwapAxeTextures(TextureManager.GetTexture(ModCore.Manifest, "Tools", "DefaultWateringCanWorking"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets all of the custom color swaps for tools.
|
||||
/// </summary>
|
||||
public static void ResetToolColorSwaps()
|
||||
{
|
||||
ResetPickaxeTexture();
|
||||
if (PickaxeNeedsReset)
|
||||
{
|
||||
ResetPickaxeTexture();
|
||||
PickaxeNeedsReset = false;
|
||||
}
|
||||
if (HoeNeedsReset)
|
||||
{
|
||||
ResetHoeTexture();
|
||||
HoeNeedsReset = false;
|
||||
}
|
||||
if (AxeNeedsReset)
|
||||
{
|
||||
ResetAxeTexture();
|
||||
AxeNeedsReset = false;
|
||||
}
|
||||
if (WateringCanNeedsReset)
|
||||
{
|
||||
ResetWateringCanTexture();
|
||||
WateringCanNeedsReset = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,305 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Newtonsoft.Json;
|
||||
using PyTK.CustomElementHandler;
|
||||
using Revitalize.Framework.Objects.Interfaces;
|
||||
using Revitalize.Framework.Utilities;
|
||||
using StardewValley;
|
||||
using StardewValley.Tools;
|
||||
using StardustCore.UIUtilities;
|
||||
|
||||
namespace Revitalize.Framework.Objects.Items.Tools
|
||||
{
|
||||
public class AxeExtended: StardewValley.Tools.Axe, ISaveElement, IItemInfo
|
||||
{
|
||||
public BasicItemInformation info;
|
||||
public Texture2DExtended workingTexture;
|
||||
|
||||
/// <summary>
|
||||
/// Used only for accessibility for casting.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public BasicItemInformation Info
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.info;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.info = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Guid guid;
|
||||
|
||||
public override string Name
|
||||
{
|
||||
|
||||
get
|
||||
{
|
||||
if (this.info != null)
|
||||
{
|
||||
return this.netName.Value.Split('>')[0];
|
||||
//return this.info.name;
|
||||
}
|
||||
if (this.netName == null)
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value.
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.netName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.netName.Value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
{
|
||||
this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back.
|
||||
}
|
||||
else
|
||||
{
|
||||
this.netName.Value = value; //Otherwise just set the net name.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.info != null)
|
||||
{
|
||||
return this.info.name;
|
||||
}
|
||||
return this.netName.Value.Split('>')[0];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.netName == null) return;
|
||||
if (this.netName.Value == null) return;
|
||||
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
this.netName.Value = value + ">" + split[1];
|
||||
else
|
||||
this.netName.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result.
|
||||
else
|
||||
return ""; //Otherwise return nothing.
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.netName == null) return;
|
||||
if (this.netName.Value == null) return;
|
||||
{
|
||||
this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual string ItemInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + Revitalize.ModCore.Serializer.ToJSONString(this.workingTexture);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
string[] data = value.Split('<');
|
||||
string infoString = data[0];
|
||||
string guidString = data[1];
|
||||
string WorkingTexture = data[2];
|
||||
|
||||
this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation));
|
||||
Guid oldGuid = this.guid;
|
||||
this.guid = Guid.Parse(guidString);
|
||||
this.workingTexture = Revitalize.ModCore.Serializer.DeserializeFromJSONString<Texture2DExtended>(WorkingTexture);
|
||||
if (ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
//ModCore.log("Update item with guid: " + this.guid);
|
||||
ModCore.CustomItems[this.guid] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModCore.log("Add in new guid: " + this.guid);
|
||||
ModCore.CustomItems.Add(this.guid, this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AxeExtended()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public AxeExtended(BasicItemInformation ItemInfo, int UpgradeLevel, Texture2DExtended WorkingTexture)
|
||||
{
|
||||
this.info = ItemInfo;
|
||||
this.upgradeLevel.Value = UpgradeLevel;
|
||||
this.guid = Guid.NewGuid();
|
||||
this.workingTexture = WorkingTexture;
|
||||
this.updateInfo();
|
||||
}
|
||||
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
if (this.lastUser == null || this.lastUser.toolPower <= 0 || !this.lastUser.canReleaseTool)
|
||||
return;
|
||||
this.updateInfo();
|
||||
foreach (Vector2 vector2 in this.tilesAffected(this.lastUser.GetToolLocation(false) / 64f, this.lastUser.toolPower, this.lastUser))
|
||||
this.info.animationManager.draw(b, Game1.GlobalToLocal(new Vector2((float)((int)vector2.X * 64), (float)((int)vector2.Y * 64))), Color.White, 4f, SpriteEffects.None, 0.01f);
|
||||
}
|
||||
|
||||
public override void drawAttachments(SpriteBatch b, int x, int y)
|
||||
{
|
||||
this.updateInfo();
|
||||
//base.drawAttachments(b, x, y);
|
||||
//this.info.animationManager.draw(b,)
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow)
|
||||
{
|
||||
this.updateInfo();
|
||||
this.info.animationManager.draw(spriteBatch, location, color * transparency, 4f * scaleSize, SpriteEffects.None, layerDepth);
|
||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> serializedInfo = new Dictionary<string, string>();
|
||||
serializedInfo.Add("id", this.ItemInfo);
|
||||
serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||
return serializedInfo;
|
||||
}
|
||||
|
||||
public override bool beginUsing(GameLocation location, int x, int y, Farmer who)
|
||||
{
|
||||
this.updateInfo();
|
||||
Revitalize.Framework.Hacks.ColorChanger.SwapAxeTextures(this.workingTexture.texture);
|
||||
return base.beginUsing(location, x, y, who);
|
||||
}
|
||||
public override void endUsing(GameLocation location, Farmer who)
|
||||
{
|
||||
//Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture();
|
||||
base.endUsing(location, who);
|
||||
}
|
||||
|
||||
public override bool onRelease(GameLocation location, int x, int y, Farmer who)
|
||||
{
|
||||
//Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture();
|
||||
return base.onRelease(location, x, y, who);
|
||||
}
|
||||
|
||||
public override void actionWhenStopBeingHeld(Farmer who)
|
||||
{
|
||||
Revitalize.Framework.Hacks.ColorChanger.ResetAxeTexture();
|
||||
base.actionWhenStopBeingHeld(who);
|
||||
}
|
||||
|
||||
public override Color getCategoryColor()
|
||||
{
|
||||
return this.info.categoryColor;
|
||||
}
|
||||
|
||||
public override string getCategoryName()
|
||||
{
|
||||
return this.info.categoryName;
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return this.info.name;
|
||||
}
|
||||
|
||||
public override Item getOne()
|
||||
{
|
||||
return new AxeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy());
|
||||
}
|
||||
|
||||
public object getReplacement()
|
||||
{
|
||||
return new StardewValley.Tools.Axe { UpgradeLevel = this.UpgradeLevel };
|
||||
}
|
||||
|
||||
public void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||
this.upgradeLevel.Value = (replacement as Axe).UpgradeLevel;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the info on the item.
|
||||
/// </summary>
|
||||
public virtual void updateInfo()
|
||||
{
|
||||
if (this.info == null || this.workingTexture == null)
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.requiresUpdate())
|
||||
{
|
||||
this.text = this.ItemInfo;
|
||||
this.info.cleanAfterUpdate();
|
||||
MultiplayerUtilities.RequestUpdateSync(this.guid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an update for this item.
|
||||
/// </summary>
|
||||
public virtual void getUpdate()
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if this item requires a sync update.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool requiresUpdate()
|
||||
{
|
||||
if (this.info.requiresSyncUpdate())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,305 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Newtonsoft.Json;
|
||||
using PyTK.CustomElementHandler;
|
||||
using Revitalize.Framework.Objects.Interfaces;
|
||||
using Revitalize.Framework.Utilities;
|
||||
using StardewValley;
|
||||
using StardewValley.Tools;
|
||||
using StardustCore.UIUtilities;
|
||||
|
||||
namespace Revitalize.Framework.Objects.Items.Tools
|
||||
{
|
||||
public class HoeExtended: StardewValley.Tools.Hoe, ISaveElement, IItemInfo
|
||||
{
|
||||
public BasicItemInformation info;
|
||||
public Texture2DExtended workingTexture;
|
||||
|
||||
/// <summary>
|
||||
/// Used only for accessibility for casting.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public BasicItemInformation Info
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.info;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.info = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Guid guid;
|
||||
|
||||
public override string Name
|
||||
{
|
||||
|
||||
get
|
||||
{
|
||||
if (this.info != null)
|
||||
{
|
||||
return this.netName.Value.Split('>')[0];
|
||||
//return this.info.name;
|
||||
}
|
||||
if (this.netName == null)
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value.
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.netName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.netName.Value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
{
|
||||
this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back.
|
||||
}
|
||||
else
|
||||
{
|
||||
this.netName.Value = value; //Otherwise just set the net name.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.info != null)
|
||||
{
|
||||
return this.info.name;
|
||||
}
|
||||
return this.netName.Value.Split('>')[0];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.netName == null) return;
|
||||
if (this.netName.Value == null) return;
|
||||
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
this.netName.Value = value + ">" + split[1];
|
||||
else
|
||||
this.netName.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result.
|
||||
else
|
||||
return ""; //Otherwise return nothing.
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.netName == null) return;
|
||||
if (this.netName.Value == null) return;
|
||||
{
|
||||
this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual string ItemInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + Revitalize.ModCore.Serializer.ToJSONString(this.workingTexture);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
string[] data = value.Split('<');
|
||||
string infoString = data[0];
|
||||
string guidString = data[1];
|
||||
string WorkingTexture = data[2];
|
||||
|
||||
this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation));
|
||||
Guid oldGuid = this.guid;
|
||||
this.guid = Guid.Parse(guidString);
|
||||
this.workingTexture = Revitalize.ModCore.Serializer.DeserializeFromJSONString<Texture2DExtended>(WorkingTexture);
|
||||
if (ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
//ModCore.log("Update item with guid: " + this.guid);
|
||||
ModCore.CustomItems[this.guid] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModCore.log("Add in new guid: " + this.guid);
|
||||
ModCore.CustomItems.Add(this.guid, this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public HoeExtended()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public HoeExtended(BasicItemInformation ItemInfo, int UpgradeLevel, Texture2DExtended WorkingTexture)
|
||||
{
|
||||
this.info = ItemInfo;
|
||||
this.upgradeLevel.Value = UpgradeLevel;
|
||||
this.guid = Guid.NewGuid();
|
||||
this.workingTexture = WorkingTexture;
|
||||
this.updateInfo();
|
||||
}
|
||||
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
if (this.lastUser == null || this.lastUser.toolPower <= 0 || !this.lastUser.canReleaseTool)
|
||||
return;
|
||||
this.updateInfo();
|
||||
foreach (Vector2 vector2 in this.tilesAffected(this.lastUser.GetToolLocation(false) / 64f, this.lastUser.toolPower, this.lastUser))
|
||||
this.info.animationManager.draw(b, Game1.GlobalToLocal(new Vector2((float)((int)vector2.X * 64), (float)((int)vector2.Y * 64))), Color.White, 4f, SpriteEffects.None, 0.01f);
|
||||
}
|
||||
|
||||
public override void drawAttachments(SpriteBatch b, int x, int y)
|
||||
{
|
||||
this.updateInfo();
|
||||
//base.drawAttachments(b, x, y);
|
||||
//this.info.animationManager.draw(b,)
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow)
|
||||
{
|
||||
this.updateInfo();
|
||||
this.info.animationManager.draw(spriteBatch, location, color * transparency, 4f * scaleSize, SpriteEffects.None, layerDepth);
|
||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> serializedInfo = new Dictionary<string, string>();
|
||||
serializedInfo.Add("id", this.ItemInfo);
|
||||
serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||
return serializedInfo;
|
||||
}
|
||||
|
||||
public override bool beginUsing(GameLocation location, int x, int y, Farmer who)
|
||||
{
|
||||
this.updateInfo();
|
||||
Revitalize.Framework.Hacks.ColorChanger.SwapHoeTextures(this.workingTexture.texture);
|
||||
return base.beginUsing(location, x, y, who);
|
||||
}
|
||||
public override void endUsing(GameLocation location, Farmer who)
|
||||
{
|
||||
//Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture();
|
||||
base.endUsing(location, who);
|
||||
}
|
||||
|
||||
public override bool onRelease(GameLocation location, int x, int y, Farmer who)
|
||||
{
|
||||
//Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture();
|
||||
return base.onRelease(location, x, y, who);
|
||||
}
|
||||
|
||||
public override void actionWhenStopBeingHeld(Farmer who)
|
||||
{
|
||||
Revitalize.Framework.Hacks.ColorChanger.ResetHoeTexture();
|
||||
base.actionWhenStopBeingHeld(who);
|
||||
}
|
||||
|
||||
public override Color getCategoryColor()
|
||||
{
|
||||
return this.info.categoryColor;
|
||||
}
|
||||
|
||||
public override string getCategoryName()
|
||||
{
|
||||
return this.info.categoryName;
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return this.info.name;
|
||||
}
|
||||
|
||||
public override Item getOne()
|
||||
{
|
||||
return new HoeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy());
|
||||
}
|
||||
|
||||
public object getReplacement()
|
||||
{
|
||||
return new StardewValley.Tools.Hoe { UpgradeLevel = this.UpgradeLevel };
|
||||
}
|
||||
|
||||
public void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||
this.upgradeLevel.Value = (replacement as Hoe).UpgradeLevel;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the info on the item.
|
||||
/// </summary>
|
||||
public virtual void updateInfo()
|
||||
{
|
||||
if (this.info == null || this.workingTexture == null)
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.requiresUpdate())
|
||||
{
|
||||
this.text = this.ItemInfo;
|
||||
this.info.cleanAfterUpdate();
|
||||
MultiplayerUtilities.RequestUpdateSync(this.guid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an update for this item.
|
||||
/// </summary>
|
||||
public virtual void getUpdate()
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if this item requires a sync update.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool requiresUpdate()
|
||||
{
|
||||
if (this.info.requiresSyncUpdate())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -268,7 +268,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
|||
if (this.info == null || this.workingTexture==null)
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
ModCore.log("Updated item info!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,306 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Newtonsoft.Json;
|
||||
using PyTK.CustomElementHandler;
|
||||
using Revitalize.Framework.Objects.Interfaces;
|
||||
using Revitalize.Framework.Utilities;
|
||||
using StardewValley;
|
||||
using StardewValley.Tools;
|
||||
using StardustCore.UIUtilities;
|
||||
|
||||
namespace Revitalize.Framework.Objects.Items.Tools
|
||||
{
|
||||
public class WateringCanExtended:StardewValley.Tools.WateringCan, ISaveElement, IItemInfo
|
||||
{
|
||||
public BasicItemInformation info;
|
||||
public Texture2DExtended workingTexture;
|
||||
|
||||
/// <summary>
|
||||
/// Used only for accessibility for casting.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public BasicItemInformation Info
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.info;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.info = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Guid guid;
|
||||
|
||||
public override string Name
|
||||
{
|
||||
|
||||
get
|
||||
{
|
||||
if (this.info != null)
|
||||
{
|
||||
return this.netName.Value.Split('>')[0];
|
||||
//return this.info.name;
|
||||
}
|
||||
if (this.netName == null)
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value.
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.netName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.netName.Value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
{
|
||||
this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back.
|
||||
}
|
||||
else
|
||||
{
|
||||
this.netName.Value = value; //Otherwise just set the net name.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.info != null)
|
||||
{
|
||||
return this.info.name;
|
||||
}
|
||||
return this.netName.Value.Split('>')[0];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.netName == null) return;
|
||||
if (this.netName.Value == null) return;
|
||||
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
this.netName.Value = value + ">" + split[1];
|
||||
else
|
||||
this.netName.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
||||
return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result.
|
||||
else
|
||||
return ""; //Otherwise return nothing.
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.netName == null) return;
|
||||
if (this.netName.Value == null) return;
|
||||
{
|
||||
this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual string ItemInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return Revitalize.ModCore.Serializer.ToJSONString(this.info) + "<" + this.guid + "<" + Revitalize.ModCore.Serializer.ToJSONString(this.workingTexture);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
string[] data = value.Split('<');
|
||||
string infoString = data[0];
|
||||
string guidString = data[1];
|
||||
string WorkingTexture = data[2];
|
||||
|
||||
this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation));
|
||||
Guid oldGuid = this.guid;
|
||||
this.guid = Guid.Parse(guidString);
|
||||
this.workingTexture = Revitalize.ModCore.Serializer.DeserializeFromJSONString<Texture2DExtended>(WorkingTexture);
|
||||
if (ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
//ModCore.log("Update item with guid: " + this.guid);
|
||||
ModCore.CustomItems[this.guid] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModCore.log("Add in new guid: " + this.guid);
|
||||
ModCore.CustomItems.Add(this.guid, this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public WateringCanExtended()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WateringCanExtended(BasicItemInformation ItemInfo, int UpgradeLevel, Texture2DExtended WorkingTexture,int WaterCapacity)
|
||||
{
|
||||
this.info = ItemInfo;
|
||||
this.upgradeLevel.Value = UpgradeLevel;
|
||||
this.guid = Guid.NewGuid();
|
||||
this.workingTexture = WorkingTexture;
|
||||
this.waterCanMax = WaterCapacity;
|
||||
this.updateInfo();
|
||||
}
|
||||
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
if (this.lastUser == null || this.lastUser.toolPower <= 0 || !this.lastUser.canReleaseTool)
|
||||
return;
|
||||
this.updateInfo();
|
||||
foreach (Vector2 vector2 in this.tilesAffected(this.lastUser.GetToolLocation(false) / 64f, this.lastUser.toolPower, this.lastUser))
|
||||
this.info.animationManager.draw(b, Game1.GlobalToLocal(new Vector2((float)((int)vector2.X * 64), (float)((int)vector2.Y * 64))), Color.White, 4f, SpriteEffects.None, 0.01f);
|
||||
}
|
||||
|
||||
public override void drawAttachments(SpriteBatch b, int x, int y)
|
||||
{
|
||||
this.updateInfo();
|
||||
//base.drawAttachments(b, x, y);
|
||||
//this.info.animationManager.draw(b,)
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow)
|
||||
{
|
||||
this.updateInfo();
|
||||
this.info.animationManager.draw(spriteBatch, location, color * transparency, 4f * scaleSize, SpriteEffects.None, layerDepth);
|
||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> serializedInfo = new Dictionary<string, string>();
|
||||
serializedInfo.Add("id", this.ItemInfo);
|
||||
serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||
return serializedInfo;
|
||||
}
|
||||
|
||||
public override bool beginUsing(GameLocation location, int x, int y, Farmer who)
|
||||
{
|
||||
this.updateInfo();
|
||||
Revitalize.Framework.Hacks.ColorChanger.SwapWateringCanTextures(this.workingTexture.texture);
|
||||
return base.beginUsing(location, x, y, who);
|
||||
}
|
||||
public override void endUsing(GameLocation location, Farmer who)
|
||||
{
|
||||
//Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture();
|
||||
base.endUsing(location, who);
|
||||
}
|
||||
|
||||
public override bool onRelease(GameLocation location, int x, int y, Farmer who)
|
||||
{
|
||||
//Revitalize.Framework.Hacks.ColorChanger.ResetPickaxeTexture();
|
||||
return base.onRelease(location, x, y, who);
|
||||
}
|
||||
|
||||
public override void actionWhenStopBeingHeld(Farmer who)
|
||||
{
|
||||
Revitalize.Framework.Hacks.ColorChanger.ResetWateringCanTexture();
|
||||
base.actionWhenStopBeingHeld(who);
|
||||
}
|
||||
|
||||
public override Color getCategoryColor()
|
||||
{
|
||||
return this.info.categoryColor;
|
||||
}
|
||||
|
||||
public override string getCategoryName()
|
||||
{
|
||||
return this.info.categoryName;
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return this.info.name;
|
||||
}
|
||||
|
||||
public override Item getOne()
|
||||
{
|
||||
return new WateringCanExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy(),this.waterCanMax);
|
||||
}
|
||||
|
||||
public object getReplacement()
|
||||
{
|
||||
return new StardewValley.Tools.WateringCan { UpgradeLevel = this.UpgradeLevel, waterCanMax=this.waterCanMax };
|
||||
}
|
||||
|
||||
public void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||
this.upgradeLevel.Value = (replacement as WateringCan).UpgradeLevel;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the info on the item.
|
||||
/// </summary>
|
||||
public virtual void updateInfo()
|
||||
{
|
||||
if (this.info == null || this.workingTexture == null)
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.requiresUpdate())
|
||||
{
|
||||
this.text = this.ItemInfo;
|
||||
this.info.cleanAfterUpdate();
|
||||
MultiplayerUtilities.RequestUpdateSync(this.guid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an update for this item.
|
||||
/// </summary>
|
||||
public virtual void getUpdate()
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if this item requires a sync update.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool requiresUpdate()
|
||||
{
|
||||
if (this.info.requiresSyncUpdate())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue