Fixed tools serialization. Also made modded tools able to be trashed.
This commit is contained in:
parent
caa7653b32
commit
68bfaa38c9
|
@ -10,12 +10,13 @@ using PyTK.CustomElementHandler;
|
||||||
using Revitalize.Framework.Objects.Interfaces;
|
using Revitalize.Framework.Objects.Interfaces;
|
||||||
using Revitalize.Framework.Utilities;
|
using Revitalize.Framework.Utilities;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Objects;
|
||||||
using StardewValley.Tools;
|
using StardewValley.Tools;
|
||||||
using StardustCore.UIUtilities;
|
using StardustCore.UIUtilities;
|
||||||
|
|
||||||
namespace Revitalize.Framework.Objects.Items.Tools
|
namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
{
|
{
|
||||||
public class AxeExtended: StardewValley.Tools.Axe, ISaveElement, IItemInfo
|
public class AxeExtended: StardewValley.Tools.Axe, ISaveElement, IItemInfo,ICustomObject
|
||||||
{
|
{
|
||||||
public BasicItemInformation info;
|
public BasicItemInformation info;
|
||||||
public Texture2DExtended workingTexture;
|
public Texture2DExtended workingTexture;
|
||||||
|
@ -194,15 +195,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
//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)
|
public override bool beginUsing(GameLocation location, int x, int y, Farmer who)
|
||||||
{
|
{
|
||||||
this.updateInfo();
|
this.updateInfo();
|
||||||
|
@ -247,17 +239,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return new AxeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy());
|
return new AxeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual object getReplacement()
|
|
||||||
{
|
|
||||||
return new StardewValley.Tools.Axe { UpgradeLevel = this.UpgradeLevel };
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
|
||||||
{
|
|
||||||
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
|
||||||
this.upgradeLevel.Value = (replacement as Axe).UpgradeLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the info on the item.
|
/// Updates the info on the item.
|
||||||
|
@ -301,5 +282,43 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public virtual ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
AxeExtended p = Revitalize.ModCore.Serializer.DeserializeGUID<AxeExtended>(additionalSaveData["GUID"]);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
public virtual 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));
|
||||||
|
serializedInfo.Add("GUID", this.guid.ToString());
|
||||||
|
serializedInfo.Add("Level", this.UpgradeLevel.ToString());
|
||||||
|
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||||
|
return serializedInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual object getReplacement()
|
||||||
|
{
|
||||||
|
Chest c = new Chest(true);
|
||||||
|
c.playerChoiceColor.Value = Color.Magenta;
|
||||||
|
c.TileLocation = new Vector2(0, 0);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
//ModCore.log("REBULD THE PICKAXE!!!!!!!");
|
||||||
|
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||||
|
this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]);
|
||||||
|
//this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool canBeTrashed()
|
||||||
|
{
|
||||||
|
return base.canBeTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,11 @@ using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Netcode;
|
using Netcode;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using PyTK.CustomElementHandler;
|
||||||
using Revitalize.Framework.Energy;
|
using Revitalize.Framework.Energy;
|
||||||
using Revitalize.Framework.Utilities;
|
using Revitalize.Framework.Utilities;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Objects;
|
||||||
using StardewValley.Tools;
|
using StardewValley.Tools;
|
||||||
using StardustCore.UIUtilities;
|
using StardustCore.UIUtilities;
|
||||||
using xTile.ObjectModel;
|
using xTile.ObjectModel;
|
||||||
|
@ -234,16 +236,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return new Chainsaw(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy());
|
return new Chainsaw(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object getReplacement()
|
|
||||||
{
|
|
||||||
return new StardewValley.Tools.Axe { UpgradeLevel = this.UpgradeLevel };
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
|
||||||
{
|
|
||||||
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
|
||||||
this.upgradeLevel.Value = (replacement as Axe).UpgradeLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getEnergyConsumptionRate()
|
private int getEnergyConsumptionRate()
|
||||||
{
|
{
|
||||||
|
@ -259,5 +251,44 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
{
|
{
|
||||||
this.info.EnergyManager = Manager;
|
this.info.EnergyManager = Manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
Chainsaw p = Revitalize.ModCore.Serializer.DeserializeGUID<Chainsaw>(additionalSaveData["GUID"]);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
public override 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));
|
||||||
|
serializedInfo.Add("GUID", this.guid.ToString());
|
||||||
|
serializedInfo.Add("Level", this.UpgradeLevel.ToString());
|
||||||
|
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||||
|
return serializedInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object getReplacement()
|
||||||
|
{
|
||||||
|
Chest c = new Chest(true);
|
||||||
|
c.playerChoiceColor.Value = Color.Magenta;
|
||||||
|
c.TileLocation = new Vector2(0, 0);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
//ModCore.log("REBULD THE PICKAXE!!!!!!!");
|
||||||
|
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||||
|
this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]);
|
||||||
|
//this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool canBeTrashed()
|
||||||
|
{
|
||||||
|
return base.canBeTrashed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,13 @@ using PyTK.CustomElementHandler;
|
||||||
using Revitalize.Framework.Objects.Interfaces;
|
using Revitalize.Framework.Objects.Interfaces;
|
||||||
using Revitalize.Framework.Utilities;
|
using Revitalize.Framework.Utilities;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Objects;
|
||||||
using StardewValley.Tools;
|
using StardewValley.Tools;
|
||||||
using StardustCore.UIUtilities;
|
using StardustCore.UIUtilities;
|
||||||
|
|
||||||
namespace Revitalize.Framework.Objects.Items.Tools
|
namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
{
|
{
|
||||||
public class HoeExtended: StardewValley.Tools.Hoe, ISaveElement, IItemInfo
|
public class HoeExtended: StardewValley.Tools.Hoe, ISaveElement, IItemInfo,ICustomObject
|
||||||
{
|
{
|
||||||
public BasicItemInformation info;
|
public BasicItemInformation info;
|
||||||
public Texture2DExtended workingTexture;
|
public Texture2DExtended workingTexture;
|
||||||
|
@ -194,15 +195,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
//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)
|
public override bool beginUsing(GameLocation location, int x, int y, Farmer who)
|
||||||
{
|
{
|
||||||
this.updateInfo();
|
this.updateInfo();
|
||||||
|
@ -247,17 +239,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return new HoeExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy());
|
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>
|
/// <summary>
|
||||||
/// Updates the info on the item.
|
/// Updates the info on the item.
|
||||||
|
@ -301,5 +282,43 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public virtual ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
HoeExtended p = Revitalize.ModCore.Serializer.DeserializeGUID<HoeExtended>(additionalSaveData["GUID"]);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
serializedInfo.Add("GUID", this.guid.ToString());
|
||||||
|
serializedInfo.Add("Level", this.UpgradeLevel.ToString());
|
||||||
|
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||||
|
return serializedInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual object getReplacement()
|
||||||
|
{
|
||||||
|
Chest c = new Chest(true);
|
||||||
|
c.playerChoiceColor.Value = Color.Magenta;
|
||||||
|
c.TileLocation = new Vector2(0, 0);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
//ModCore.log("REBULD THE PICKAXE!!!!!!!");
|
||||||
|
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||||
|
this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]);
|
||||||
|
//this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
||||||
|
|
||||||
|
}
|
||||||
|
public override bool canBeTrashed()
|
||||||
|
{
|
||||||
|
return base.canBeTrashed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,11 @@ using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Netcode;
|
using Netcode;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using PyTK.CustomElementHandler;
|
||||||
using Revitalize.Framework.Energy;
|
using Revitalize.Framework.Energy;
|
||||||
using Revitalize.Framework.Utilities;
|
using Revitalize.Framework.Utilities;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Objects;
|
||||||
using StardewValley.Tools;
|
using StardewValley.Tools;
|
||||||
using StardustCore.UIUtilities;
|
using StardustCore.UIUtilities;
|
||||||
|
|
||||||
|
@ -362,13 +364,25 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
|
|
||||||
public override object getReplacement()
|
public override object getReplacement()
|
||||||
{
|
{
|
||||||
return new StardewValley.Tools.Pickaxe { UpgradeLevel = this.UpgradeLevel };
|
Chest c = new Chest(true);
|
||||||
|
c.playerChoiceColor.Value = Color.Magenta;
|
||||||
|
c.TileLocation = new Vector2(0, 0);
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
public override void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
{
|
{
|
||||||
|
//ModCore.log("REBULD THE PICKAXE!!!!!!!");
|
||||||
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||||
this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]);
|
||||||
|
//this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
MiningDrill p = Revitalize.ModCore.Serializer.DeserializeGUID<MiningDrill>(additionalSaveData["GUID"]);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -386,5 +400,10 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
{
|
{
|
||||||
this.info.EnergyManager = Manager;
|
this.info.EnergyManager = Manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool canBeTrashed()
|
||||||
|
{
|
||||||
|
return base.canBeTrashed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,13 @@ using Revitalize.Framework.Hacks;
|
||||||
using Revitalize.Framework.Objects.Interfaces;
|
using Revitalize.Framework.Objects.Interfaces;
|
||||||
using Revitalize.Framework.Utilities;
|
using Revitalize.Framework.Utilities;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Objects;
|
||||||
using StardewValley.Tools;
|
using StardewValley.Tools;
|
||||||
using StardustCore.UIUtilities;
|
using StardustCore.UIUtilities;
|
||||||
|
|
||||||
namespace Revitalize.Framework.Objects.Items.Tools
|
namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
{
|
{
|
||||||
public class PickaxeExtended:StardewValley.Tools.Pickaxe, ISaveElement,IItemInfo
|
public class PickaxeExtended:StardewValley.Tools.Pickaxe, ISaveElement,IItemInfo, ICustomObject
|
||||||
{
|
{
|
||||||
public BasicItemInformation info;
|
public BasicItemInformation info;
|
||||||
public Texture2DExtended workingTexture;
|
public Texture2DExtended workingTexture;
|
||||||
|
@ -195,14 +196,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
//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)
|
public override bool beginUsing(GameLocation location, int x, int y, Farmer who)
|
||||||
{
|
{
|
||||||
|
@ -248,15 +241,11 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return new PickaxeExtended(this.info.Copy(), this.UpgradeLevel,this.workingTexture.Copy());
|
return new PickaxeExtended(this.info.Copy(), this.UpgradeLevel,this.workingTexture.Copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual object getReplacement()
|
|
||||||
{
|
|
||||||
return new StardewValley.Tools.Pickaxe { UpgradeLevel = this.UpgradeLevel };
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
|
||||||
|
public override bool canBeTrashed()
|
||||||
{
|
{
|
||||||
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
return true;
|
||||||
this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,5 +291,40 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
PickaxeExtended p = Revitalize.ModCore.Serializer.DeserializeGUID<PickaxeExtended>(additionalSaveData["GUID"]);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
serializedInfo.Add("GUID", this.guid.ToString());
|
||||||
|
serializedInfo.Add("Level", this.UpgradeLevel.ToString());
|
||||||
|
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||||
|
return serializedInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual object getReplacement()
|
||||||
|
{
|
||||||
|
Chest c = new Chest(true);
|
||||||
|
c.playerChoiceColor.Value = Color.Magenta;
|
||||||
|
c.TileLocation = new Vector2(0, 0);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
//ModCore.log("REBULD THE PICKAXE!!!!!!!");
|
||||||
|
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||||
|
this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]);
|
||||||
|
//this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,13 @@ using PyTK.CustomElementHandler;
|
||||||
using Revitalize.Framework.Objects.Interfaces;
|
using Revitalize.Framework.Objects.Interfaces;
|
||||||
using Revitalize.Framework.Utilities;
|
using Revitalize.Framework.Utilities;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Objects;
|
||||||
using StardewValley.Tools;
|
using StardewValley.Tools;
|
||||||
using StardustCore.UIUtilities;
|
using StardustCore.UIUtilities;
|
||||||
|
|
||||||
namespace Revitalize.Framework.Objects.Items.Tools
|
namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
{
|
{
|
||||||
public class WateringCanExtended:StardewValley.Tools.WateringCan, ISaveElement, IItemInfo
|
public class WateringCanExtended:StardewValley.Tools.WateringCan, ISaveElement, IItemInfo, ICustomObject
|
||||||
{
|
{
|
||||||
public BasicItemInformation info;
|
public BasicItemInformation info;
|
||||||
public Texture2DExtended workingTexture;
|
public Texture2DExtended workingTexture;
|
||||||
|
@ -195,15 +196,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
//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)
|
public override bool beginUsing(GameLocation location, int x, int y, Farmer who)
|
||||||
{
|
{
|
||||||
this.updateInfo();
|
this.updateInfo();
|
||||||
|
@ -248,18 +240,6 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return new WateringCanExtended(this.info.Copy(), this.UpgradeLevel, this.workingTexture.Copy(),this.waterCanMax);
|
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>
|
/// <summary>
|
||||||
/// Updates the info on the item.
|
/// Updates the info on the item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -302,5 +282,42 @@ namespace Revitalize.Framework.Objects.Items.Tools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
WateringCanExtended p = Revitalize.ModCore.Serializer.DeserializeGUID<WateringCanExtended>(additionalSaveData["GUID"]);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
serializedInfo.Add("GUID", this.guid.ToString());
|
||||||
|
serializedInfo.Add("Level", this.UpgradeLevel.ToString());
|
||||||
|
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
||||||
|
return serializedInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual object getReplacement()
|
||||||
|
{
|
||||||
|
Chest c = new Chest(true);
|
||||||
|
c.playerChoiceColor.Value = Color.Magenta;
|
||||||
|
c.TileLocation = new Vector2(0, 0);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
//ModCore.log("REBULD THE PICKAXE!!!!!!!");
|
||||||
|
this.info = ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
||||||
|
this.UpgradeLevel = Convert.ToInt32(additionalSaveData["Level"]);
|
||||||
|
//this.upgradeLevel.Value = (replacement as Pickaxe).UpgradeLevel;
|
||||||
|
|
||||||
|
}
|
||||||
|
public override bool canBeTrashed()
|
||||||
|
{
|
||||||
|
return base.canBeTrashed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue