Added tool support for axe, hoe, watering can and pickaxe.
This commit is contained in:
parent
7010644498
commit
a928f7d18e
|
@ -16,7 +16,7 @@ namespace StardustCore.Interfaces
|
|||
/// Gets the type of object I am trying to parse.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Type getCutsomType();
|
||||
Type getCustomType();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the serialization name of the object I am serializing.
|
||||
|
|
|
@ -5,6 +5,7 @@ using StardewValley.Menus;
|
|||
using StardustCore.ModInfo;
|
||||
using StardustCore.Objects.Tools;
|
||||
using StardustCore.Serialization;
|
||||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.SpriteFonts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -56,14 +57,25 @@ namespace StardustCore
|
|||
{
|
||||
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
|
||||
|
||||
ExtendedAxe axe = new ExtendedAxe();
|
||||
axe.UpgradeLevel = 1;
|
||||
axe.Name = "Hello Axe";
|
||||
axe.DisplayName = "Hello Axe";
|
||||
ExtendedAxe axe = new ExtendedAxe(new BasicToolInfo("My First Axe",7,"An axe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")));
|
||||
Game1.player.addItemToInventory(axe);
|
||||
|
||||
ExtendedHoe hoe = new ExtendedHoe(new BasicToolInfo("My First Hoe", 7, "An hoe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")));
|
||||
Game1.player.addItemToInventory(hoe);
|
||||
|
||||
ExtendedPickaxe pick = new ExtendedPickaxe(new BasicToolInfo("My First pickaxe", 7, "An pickaxe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")));
|
||||
Game1.player.addItemToInventory(pick);
|
||||
|
||||
ExtendedWateringCan water = new ExtendedWateringCan(new BasicToolInfo("My First Can", 7, "An can so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")),10,3);
|
||||
Game1.player.addItemToInventory(water);
|
||||
|
||||
|
||||
|
||||
ExtendedWateringCan.Serialize(water);
|
||||
ExtendedAxe.Serialize(axe);
|
||||
|
||||
ExtendedPickaxe.Serialize(pick);
|
||||
ExtendedHoe.Serialize(hoe);
|
||||
|
||||
}
|
||||
|
||||
private void SaveEvents_AfterSave(object sender, EventArgs e)
|
||||
|
|
|
@ -1602,7 +1602,7 @@ namespace StardustCore
|
|||
return Color.Black;
|
||||
}
|
||||
|
||||
public virtual Type getCutsomType()
|
||||
public virtual Type getCustomType()
|
||||
{
|
||||
return this.GetType();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardustCore.Objects.Tools
|
||||
{
|
||||
public class BasicToolInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the tool.
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// The upgrade level of the tool.
|
||||
/// </summary>
|
||||
public int level;
|
||||
|
||||
/// <summary>
|
||||
/// The description of the tool.
|
||||
/// </summary>
|
||||
public string description;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor used to hold generic info shared across all tools.
|
||||
/// </summary>
|
||||
/// <param name="Name"></param>
|
||||
/// <param name="Level"></param>
|
||||
/// <param name="Description"></param>
|
||||
public BasicToolInfo(String Name, int Level, string Description)
|
||||
{
|
||||
this.name = Name;
|
||||
this.level = Level;
|
||||
this.description = Description;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -29,14 +29,12 @@ namespace StardustCore.Objects.Tools
|
|||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content","Graphics","Tools","CustomAxe.png"));
|
||||
}
|
||||
|
||||
public ExtendedAxe(IModHelper helper,String texturePath) : base()
|
||||
public ExtendedAxe(BasicToolInfo info, Texture2DExtended texture)
|
||||
{
|
||||
this.texture = new Texture2DExtended(helper, texturePath);
|
||||
}
|
||||
|
||||
public ExtendedAxe(Texture2DExtended texture) :base()
|
||||
{
|
||||
this.texture = texture;
|
||||
this.texture = texture;
|
||||
this.displayName = info.name;
|
||||
this.description = info.description;
|
||||
this.UpgradeLevel = info.level;
|
||||
}
|
||||
|
||||
public ExtendedAxe(SerializedObjectBase dataBase) : base()
|
||||
|
@ -59,7 +57,7 @@ namespace StardustCore.Objects.Tools
|
|||
spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16 , 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth);
|
||||
}
|
||||
|
||||
public Type getCutsomType()
|
||||
public Type getCustomType()
|
||||
{
|
||||
return this.GetType();
|
||||
}
|
||||
|
@ -74,6 +72,16 @@ namespace StardustCore.Objects.Tools
|
|||
return 1;
|
||||
}
|
||||
|
||||
public override bool canBeDropped()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool canBeTrashed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void setNewTileIndexForUpgradeLevel()
|
||||
{
|
||||
//Do nothing.
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardustCore.Interfaces;
|
||||
using StardustCore.Objects.Tools.SerializationInformation;
|
||||
using StardustCore.UIUtilities;
|
||||
|
||||
namespace StardustCore.Objects.Tools
|
||||
{
|
||||
public class ExtendedHoe : StardewValley.Tools.Hoe, IItemSerializeable, IToolSerializer
|
||||
{
|
||||
public Texture2DExtended texture;
|
||||
|
||||
public override string DisplayName { get => this.displayName; set => this.displayName = value; }
|
||||
public override string Name { get => this.displayName; set => this.displayName = value; }
|
||||
|
||||
/// <summary>
|
||||
/// Generates a default axe. Doens't really do much.
|
||||
/// </summary>
|
||||
public ExtendedHoe() : base()
|
||||
{
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
}
|
||||
|
||||
public ExtendedHoe(BasicToolInfo info, Texture2DExtended texture)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.displayName = info.name;
|
||||
this.description = info.description;
|
||||
this.UpgradeLevel = info.level;
|
||||
}
|
||||
|
||||
public ExtendedHoe(SerializedObjectBase dataBase) : base()
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log("WTF EVEN " + dataBase.GetType().ToString());
|
||||
StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedHoe).Name);
|
||||
this.displayName = "Hello";
|
||||
this.description = (dataBase as Serialization_ExtendedHoe).Description;
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.UpgradeLevel = (dataBase as Serialization_ExtendedHoe).UpgradeLevel;
|
||||
}
|
||||
|
||||
public override bool canBeDropped()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool canBeTrashed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
base.draw(b);
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow)
|
||||
{
|
||||
spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16, 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth);
|
||||
}
|
||||
|
||||
public Type getCustomType()
|
||||
{
|
||||
return this.GetType();
|
||||
}
|
||||
|
||||
public string GetSerializationName()
|
||||
{
|
||||
return this.GetType().ToString();
|
||||
}
|
||||
|
||||
public override int maximumStackSize()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override void setNewTileIndexForUpgradeLevel()
|
||||
{
|
||||
//Do nothing.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the said item properly.
|
||||
/// </summary>
|
||||
/// <param name="I"></param>
|
||||
public static void Serialize(Item I)
|
||||
{
|
||||
SerializationInformation.Serialization_ExtendedHoe sAxe = new SerializationInformation.Serialization_ExtendedHoe((I as ExtendedHoe));
|
||||
String savePath = ModCore.SerializationManager.playerInventoryPath;
|
||||
String fileName = I.Name + ".json";
|
||||
String resultPath = Path.Combine(savePath, fileName);
|
||||
int count = 0;
|
||||
while (File.Exists(resultPath))
|
||||
{
|
||||
resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count);
|
||||
count++;
|
||||
}
|
||||
StardustCore.ModCore.ModHelper.WriteJsonFile<Serialization_ExtendedHoe>(resultPath, sAxe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the said item to a chest.
|
||||
/// </summary>
|
||||
/// <param name="I"></param>
|
||||
/// <param name="s"></param>
|
||||
public static void SerializeToContainer(Item I, string s)
|
||||
{
|
||||
SerializationInformation.Serialization_ExtendedHoe sAxe = new SerializationInformation.Serialization_ExtendedHoe((I as ExtendedHoe));
|
||||
String savePath = s;
|
||||
String fileName = I.Name + ".json";
|
||||
String resultPath = Path.Combine(savePath, fileName);
|
||||
int count = 0;
|
||||
while (File.Exists(resultPath))
|
||||
{
|
||||
resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count);
|
||||
count++;
|
||||
}
|
||||
StardustCore.ModCore.ModHelper.WriteJsonFile<SerializedObjectBase>(resultPath, sAxe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the object from a .json.
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public static ExtendedHoe Deserialize(string data)
|
||||
{
|
||||
Serialization_ExtendedHoe axeData = ModCore.ModHelper.ReadJsonFile<Serialization_ExtendedHoe>(data);
|
||||
return new ExtendedHoe(axeData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardustCore.Interfaces;
|
||||
using StardustCore.Objects.Tools.SerializationInformation;
|
||||
using StardustCore.UIUtilities;
|
||||
|
||||
namespace StardustCore.Objects.Tools
|
||||
{
|
||||
public class ExtendedPickaxe : StardewValley.Tools.Pickaxe, IItemSerializeable, IToolSerializer
|
||||
{
|
||||
public Texture2DExtended texture;
|
||||
|
||||
public override string DisplayName { get => this.displayName; set => this.displayName = value; }
|
||||
public override string Name { get => this.displayName; set => this.displayName = value; }
|
||||
|
||||
/// <summary>
|
||||
/// Generates a default axe. Doens't really do much.
|
||||
/// </summary>
|
||||
public ExtendedPickaxe() : base()
|
||||
{
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
}
|
||||
|
||||
public ExtendedPickaxe(BasicToolInfo info, Texture2DExtended texture)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.displayName = info.name;
|
||||
this.description = info.description;
|
||||
this.UpgradeLevel = info.level;
|
||||
}
|
||||
|
||||
public ExtendedPickaxe(SerializedObjectBase dataBase) : base()
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log("WTF EVEN " + dataBase.GetType().ToString());
|
||||
StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedPickaxe).Name);
|
||||
this.displayName = "Hello";
|
||||
this.description = (dataBase as Serialization_ExtendedPickaxe).Description;
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.UpgradeLevel = (dataBase as Serialization_ExtendedPickaxe).UpgradeLevel;
|
||||
}
|
||||
|
||||
public override bool canBeDropped()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool canBeTrashed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
base.draw(b);
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow)
|
||||
{
|
||||
spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16, 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth);
|
||||
}
|
||||
|
||||
public Type getCustomType()
|
||||
{
|
||||
return this.GetType();
|
||||
}
|
||||
|
||||
public string GetSerializationName()
|
||||
{
|
||||
return this.GetType().ToString();
|
||||
}
|
||||
|
||||
public override int maximumStackSize()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override void setNewTileIndexForUpgradeLevel()
|
||||
{
|
||||
//Do nothing.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the said item properly.
|
||||
/// </summary>
|
||||
/// <param name="I"></param>
|
||||
public static void Serialize(Item I)
|
||||
{
|
||||
SerializationInformation.Serialization_ExtendedPickaxe sAxe = new SerializationInformation.Serialization_ExtendedPickaxe((I as ExtendedPickaxe));
|
||||
String savePath = ModCore.SerializationManager.playerInventoryPath;
|
||||
String fileName = I.Name + ".json";
|
||||
String resultPath = Path.Combine(savePath, fileName);
|
||||
int count = 0;
|
||||
while (File.Exists(resultPath))
|
||||
{
|
||||
resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count);
|
||||
count++;
|
||||
}
|
||||
StardustCore.ModCore.ModHelper.WriteJsonFile<SerializedObjectBase>(resultPath, sAxe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the said item to a chest.
|
||||
/// </summary>
|
||||
/// <param name="I"></param>
|
||||
/// <param name="s"></param>
|
||||
public static void SerializeToContainer(Item I, string s)
|
||||
{
|
||||
SerializationInformation.Serialization_ExtendedPickaxe sAxe = new SerializationInformation.Serialization_ExtendedPickaxe((I as ExtendedPickaxe));
|
||||
String savePath = s;
|
||||
String fileName = I.Name + ".json";
|
||||
String resultPath = Path.Combine(savePath, fileName);
|
||||
int count = 0;
|
||||
while (File.Exists(resultPath))
|
||||
{
|
||||
resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count);
|
||||
count++;
|
||||
}
|
||||
StardustCore.ModCore.ModHelper.WriteJsonFile<SerializedObjectBase>(resultPath, sAxe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the object from a .json.
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public static ExtendedPickaxe Deserialize(string data)
|
||||
{
|
||||
Serialization_ExtendedPickaxe axeData = ModCore.ModHelper.ReadJsonFile<Serialization_ExtendedPickaxe>(data);
|
||||
return new ExtendedPickaxe(axeData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardustCore.Interfaces;
|
||||
using StardustCore.Objects.Tools.SerializationInformation;
|
||||
using StardustCore.UIUtilities;
|
||||
|
||||
namespace StardustCore.Objects.Tools
|
||||
{
|
||||
public class ExtendedWateringCan : StardewValley.Tools.WateringCan, IItemSerializeable, IToolSerializer
|
||||
{
|
||||
public Texture2DExtended texture;
|
||||
|
||||
public override string DisplayName { get => this.displayName; set => this.displayName = value; }
|
||||
public override string Name { get => this.displayName; set => this.displayName = value; }
|
||||
|
||||
/// <summary>
|
||||
/// Generates a default axe. Doens't really do much.
|
||||
/// </summary>
|
||||
public ExtendedWateringCan() : base()
|
||||
{
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.waterCanMax = 30;
|
||||
this.WaterLeft = 0;
|
||||
}
|
||||
|
||||
public ExtendedWateringCan(BasicToolInfo info, Texture2DExtended texture, int waterMax, int waterCurrent)
|
||||
{
|
||||
this.texture = texture;
|
||||
this.displayName = info.name;
|
||||
this.description = info.description;
|
||||
this.UpgradeLevel = info.level;
|
||||
this.waterCanMax = waterMax;
|
||||
this.WaterLeft = waterCurrent;
|
||||
}
|
||||
|
||||
public ExtendedWateringCan(SerializedObjectBase dataBase) : base()
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedWateringCan).Name);
|
||||
this.displayName = "Hello";
|
||||
this.description = (dataBase as Serialization_ExtendedWateringCan).Description;
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.UpgradeLevel = (dataBase as Serialization_ExtendedWateringCan).UpgradeLevel;
|
||||
this.waterCanMax= (dataBase as Serialization_ExtendedWateringCan).MaxCapacity;
|
||||
this.WaterLeft= (dataBase as Serialization_ExtendedWateringCan).WaterLeft;
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
base.draw(b);
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow)
|
||||
{
|
||||
spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16, 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth);
|
||||
if (!drawStackNumber || Game1.player.hasWateringCanEnchantment)
|
||||
return;
|
||||
spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(4f, 44f), new Rectangle?(new Rectangle(297, 420, 14, 5)), Color.White * transparency, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, layerDepth + 0.0001f);
|
||||
spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)location.X + 8, (int)location.Y + 64 - 16, (int)((double)this.WaterLeft / (double)this.waterCanMax * 48.0), 8), Color.DodgerBlue * 0.7f * transparency);
|
||||
}
|
||||
|
||||
public override bool canBeDropped()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool canBeTrashed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Type getCustomType()
|
||||
{
|
||||
return this.GetType();
|
||||
}
|
||||
|
||||
public string GetSerializationName()
|
||||
{
|
||||
return this.GetType().ToString();
|
||||
}
|
||||
|
||||
public override int maximumStackSize()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override void setNewTileIndexForUpgradeLevel()
|
||||
{
|
||||
//Do nothing.
|
||||
}
|
||||
|
||||
public void upgradeWateringCapacity(int amount)
|
||||
{
|
||||
this.waterCanMax += amount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the said item properly.
|
||||
/// </summary>
|
||||
/// <param name="I"></param>
|
||||
public static void Serialize(Item I)
|
||||
{
|
||||
SerializationInformation.Serialization_ExtendedWateringCan tool = new SerializationInformation.Serialization_ExtendedWateringCan((I as ExtendedWateringCan));
|
||||
String savePath = ModCore.SerializationManager.playerInventoryPath;
|
||||
String fileName = I.Name + ".json";
|
||||
String resultPath = Path.Combine(savePath, fileName);
|
||||
int count = 0;
|
||||
while (File.Exists(resultPath))
|
||||
{
|
||||
resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count);
|
||||
count++;
|
||||
}
|
||||
StardustCore.ModCore.ModHelper.WriteJsonFile<SerializedObjectBase>(resultPath, tool);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the said item to a chest.
|
||||
/// </summary>
|
||||
/// <param name="I"></param>
|
||||
/// <param name="s"></param>
|
||||
public static void SerializeToContainer(Item I, string s)
|
||||
{
|
||||
SerializationInformation.Serialization_ExtendedWateringCan tool = new SerializationInformation.Serialization_ExtendedWateringCan((I as ExtendedWateringCan));
|
||||
String savePath = s;
|
||||
String fileName = I.Name + ".json";
|
||||
String resultPath = Path.Combine(savePath, fileName);
|
||||
int count = 0;
|
||||
while (File.Exists(resultPath))
|
||||
{
|
||||
resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count);
|
||||
count++;
|
||||
}
|
||||
StardustCore.ModCore.ModHelper.WriteJsonFile<SerializedObjectBase>(resultPath, tool);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the object from a .json.
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public static ExtendedWateringCan Deserialize(string data)
|
||||
{
|
||||
SerializationInformation.Serialization_ExtendedWateringCan toolData = ModCore.ModHelper.ReadJsonFile< SerializationInformation.Serialization_ExtendedWateringCan>(data);
|
||||
return new ExtendedWateringCan(toolData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using StardustCore.Interfaces;
|
||||
using StardustCore.Objects.Tools.SerializationInformation;
|
||||
using StardustCore.UIUtilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -29,7 +30,7 @@ namespace StardustCore.Objects.Tools.SerializationInformation
|
|||
this.SerializationName = GetSerializationName();
|
||||
}
|
||||
|
||||
public override Type getCutsomType()
|
||||
public override Type getCustomType()
|
||||
{
|
||||
return typeof(ExtendedAxe);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
using StardustCore.Interfaces;
|
||||
using StardustCore.Objects.Tools.SerializationInformation;
|
||||
using StardustCore.UIUtilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardustCore.Objects.Tools.SerializationInformation
|
||||
{
|
||||
public class Serialization_ExtendedHoe : SerializedObjectBase
|
||||
{
|
||||
public string Name;
|
||||
public string Description;
|
||||
public int UpgradeLevel;
|
||||
public Texture2DExtended TextureInformation;
|
||||
|
||||
public Serialization_ExtendedHoe() : base()
|
||||
{
|
||||
this.SerializationName = GetSerializationName();
|
||||
}
|
||||
|
||||
public Serialization_ExtendedHoe(ExtendedHoe axe) : base()
|
||||
{
|
||||
this.UpgradeLevel = axe.UpgradeLevel;
|
||||
this.Name = axe.Name;
|
||||
this.Description = axe.description;
|
||||
this.TextureInformation = axe.texture;
|
||||
this.SerializationName = GetSerializationName();
|
||||
}
|
||||
|
||||
public override Type getCustomType()
|
||||
{
|
||||
return typeof(ExtendedHoe);
|
||||
}
|
||||
|
||||
public override string GetSerializationName()
|
||||
{
|
||||
return typeof(ExtendedHoe).ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
using StardustCore.Interfaces;
|
||||
using StardustCore.UIUtilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardustCore.Objects.Tools.SerializationInformation
|
||||
{
|
||||
public class Serialization_ExtendedPickaxe : SerializedObjectBase
|
||||
{
|
||||
public string Name;
|
||||
public string Description;
|
||||
public int UpgradeLevel;
|
||||
public Texture2DExtended TextureInformation;
|
||||
|
||||
public Serialization_ExtendedPickaxe() : base()
|
||||
{
|
||||
this.SerializationName = GetSerializationName();
|
||||
}
|
||||
|
||||
public Serialization_ExtendedPickaxe(ExtendedPickaxe axe) : base()
|
||||
{
|
||||
this.UpgradeLevel = axe.UpgradeLevel;
|
||||
this.Name = axe.Name;
|
||||
this.Description = axe.description;
|
||||
this.TextureInformation = axe.texture;
|
||||
this.SerializationName = GetSerializationName();
|
||||
}
|
||||
|
||||
public override Type getCustomType()
|
||||
{
|
||||
return typeof(ExtendedPickaxe);
|
||||
}
|
||||
|
||||
public override string GetSerializationName()
|
||||
{
|
||||
return typeof(ExtendedPickaxe).ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using StardustCore.Interfaces;
|
||||
using StardustCore.UIUtilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardustCore.Objects.Tools.SerializationInformation
|
||||
{
|
||||
public class Serialization_ExtendedWateringCan : SerializedObjectBase
|
||||
{
|
||||
public string Name;
|
||||
public string Description;
|
||||
public int UpgradeLevel;
|
||||
public Texture2DExtended TextureInformation;
|
||||
public int MaxCapacity;
|
||||
public int WaterLeft;
|
||||
|
||||
public Serialization_ExtendedWateringCan() : base()
|
||||
{
|
||||
this.SerializationName = GetSerializationName();
|
||||
}
|
||||
|
||||
public Serialization_ExtendedWateringCan(ExtendedWateringCan tool) : base()
|
||||
{
|
||||
this.UpgradeLevel = tool.UpgradeLevel;
|
||||
this.Name = tool.Name;
|
||||
this.Description = tool.description;
|
||||
this.TextureInformation = tool.texture;
|
||||
this.SerializationName = GetSerializationName();
|
||||
this.MaxCapacity = tool.waterCanMax;
|
||||
this.WaterLeft = tool.WaterLeft;
|
||||
}
|
||||
|
||||
public override Type getCustomType()
|
||||
{
|
||||
return typeof(ExtendedWateringCan);
|
||||
}
|
||||
|
||||
public override string GetSerializationName()
|
||||
{
|
||||
return typeof(ExtendedWateringCan).ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ namespace StardustCore.Objects.Tools.SerializationInformation
|
|||
this.SerializationName = this.GetSerializationName();
|
||||
}
|
||||
|
||||
public virtual Type getCutsomType()
|
||||
public virtual Type getCustomType()
|
||||
{
|
||||
return this.GetType();
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace StardustCore.Serialization
|
|||
}
|
||||
foreach (var i in removalList)
|
||||
{
|
||||
if (i.getCutsomType() == typeof(CoreObject))
|
||||
if (i.getCustomType() == typeof(CoreObject))
|
||||
{
|
||||
(i as CoreObject).thisLocation.removeObject((i as CoreObject).TileLocation, false);
|
||||
}
|
||||
|
@ -826,7 +826,7 @@ public string ParseXMLType(string path)
|
|||
{
|
||||
foreach(var v in StardustCore.ModCore.SerializationManager.trackedObjectList)
|
||||
{
|
||||
if (v.getCutsomType() == typeof(CoreObject))
|
||||
if (v.getCustomType() == typeof(CoreObject))
|
||||
{
|
||||
if (c.TileLocation == (v as CoreObject).TileLocation && c.thisLocation == (v as CoreObject).thisLocation)
|
||||
{
|
||||
|
|
|
@ -89,8 +89,15 @@
|
|||
<Compile Include="Interfaces\IToolSerializer.cs" />
|
||||
<Compile Include="Math\Hex.cs" />
|
||||
<Compile Include="Math\Hex32.cs" />
|
||||
<Compile Include="Objects\Tools\BasicToolInfo.cs" />
|
||||
<Compile Include="Objects\Tools\ExtendedAxe.cs" />
|
||||
<Compile Include="Objects\Tools\ExtendedHoe.cs" />
|
||||
<Compile Include="Objects\Tools\ExtendedPickaxe.cs" />
|
||||
<Compile Include="Objects\Tools\ExtendedWateringCan.cs" />
|
||||
<Compile Include="Objects\Tools\SerializationInformation\Serialization_ExtendedAxe.cs" />
|
||||
<Compile Include="Objects\Tools\SerializationInformation\Serialization_ExtendedHoe.cs" />
|
||||
<Compile Include="Objects\Tools\SerializationInformation\Serialization_ExtendedPickaxe.cs" />
|
||||
<Compile Include="Objects\Tools\SerializationInformation\Serialization_ExtendedWateringCan.cs" />
|
||||
<Compile Include="Objects\Tools\SerializationInformation\SerializedObjectBase.cs" />
|
||||
<Compile Include="UIUtilities\IClickableMenuExtended.cs" />
|
||||
<Compile Include="UIUtilities\LayeredTexture.cs" />
|
||||
|
|
Loading…
Reference in New Issue