diff --git a/GeneralMods/StardustCore/Interfaces/ISerializeable.cs b/GeneralMods/StardustCore/Interfaces/ISerializeable.cs index 9aeeef69..35c7292e 100644 --- a/GeneralMods/StardustCore/Interfaces/ISerializeable.cs +++ b/GeneralMods/StardustCore/Interfaces/ISerializeable.cs @@ -16,7 +16,7 @@ namespace StardustCore.Interfaces /// Gets the type of object I am trying to parse. /// /// - Type getCutsomType(); + Type getCustomType(); /// /// Returns the serialization name of the object I am serializing. diff --git a/GeneralMods/StardustCore/ModCore.cs b/GeneralMods/StardustCore/ModCore.cs index 35b71450..e426a2c7 100644 --- a/GeneralMods/StardustCore/ModCore.cs +++ b/GeneralMods/StardustCore/ModCore.cs @@ -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) diff --git a/GeneralMods/StardustCore/Objects/CoreObject.cs b/GeneralMods/StardustCore/Objects/CoreObject.cs index 814def34..e77eff49 100644 --- a/GeneralMods/StardustCore/Objects/CoreObject.cs +++ b/GeneralMods/StardustCore/Objects/CoreObject.cs @@ -1602,7 +1602,7 @@ namespace StardustCore return Color.Black; } - public virtual Type getCutsomType() + public virtual Type getCustomType() { return this.GetType(); } diff --git a/GeneralMods/StardustCore/Objects/Tools/BasicToolInfo.cs b/GeneralMods/StardustCore/Objects/Tools/BasicToolInfo.cs new file mode 100644 index 00000000..eb2866be --- /dev/null +++ b/GeneralMods/StardustCore/Objects/Tools/BasicToolInfo.cs @@ -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 + { + /// + /// The name of the tool. + /// + public string name; + + /// + /// The upgrade level of the tool. + /// + public int level; + + /// + /// The description of the tool. + /// + public string description; + + /// + /// Constructor used to hold generic info shared across all tools. + /// + /// + /// + /// + public BasicToolInfo(String Name, int Level, string Description) + { + this.name = Name; + this.level = Level; + this.description = Description; + } + + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs index c60c9b1e..a271dfa6 100644 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs @@ -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. diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs new file mode 100644 index 00000000..ebbcc04a --- /dev/null +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs @@ -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; } + + /// + /// Generates a default axe. Doens't really do much. + /// + 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. + } + + /// + /// Serializes the said item properly. + /// + /// + 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(resultPath, sAxe); + } + + /// + /// Serializes the said item to a chest. + /// + /// + /// + 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(resultPath, sAxe); + } + + /// + /// Deserializes the object from a .json. + /// + /// + /// + public static ExtendedHoe Deserialize(string data) + { + Serialization_ExtendedHoe axeData = ModCore.ModHelper.ReadJsonFile(data); + return new ExtendedHoe(axeData); + } + + + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs new file mode 100644 index 00000000..74bc63a6 --- /dev/null +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs @@ -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; } + + /// + /// Generates a default axe. Doens't really do much. + /// + 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. + } + + /// + /// Serializes the said item properly. + /// + /// + 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(resultPath, sAxe); + } + + /// + /// Serializes the said item to a chest. + /// + /// + /// + 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(resultPath, sAxe); + } + + /// + /// Deserializes the object from a .json. + /// + /// + /// + public static ExtendedPickaxe Deserialize(string data) + { + Serialization_ExtendedPickaxe axeData = ModCore.ModHelper.ReadJsonFile(data); + return new ExtendedPickaxe(axeData); + } + + + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs new file mode 100644 index 00000000..345ec345 --- /dev/null +++ b/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs @@ -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; } + + /// + /// Generates a default axe. Doens't really do much. + /// + 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; + } + + /// + /// Serializes the said item properly. + /// + /// + 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(resultPath, tool); + } + + /// + /// Serializes the said item to a chest. + /// + /// + /// + 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(resultPath, tool); + } + + /// + /// Deserializes the object from a .json. + /// + /// + /// + public static ExtendedWateringCan Deserialize(string data) + { + SerializationInformation.Serialization_ExtendedWateringCan toolData = ModCore.ModHelper.ReadJsonFile< SerializationInformation.Serialization_ExtendedWateringCan>(data); + return new ExtendedWateringCan(toolData); + } + + + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs index 700b347a..fc296b61 100644 --- a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs +++ b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs @@ -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); } diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedHoe.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedHoe.cs new file mode 100644 index 00000000..a314f0c6 --- /dev/null +++ b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedHoe.cs @@ -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(); + } + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedPickaxe.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedPickaxe.cs new file mode 100644 index 00000000..15a78bd3 --- /dev/null +++ b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedPickaxe.cs @@ -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(); + } + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedWateringCan.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedWateringCan.cs new file mode 100644 index 00000000..7f99ebd7 --- /dev/null +++ b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedWateringCan.cs @@ -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(); + } + } +} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs index 0e1c7442..c315a1e5 100644 --- a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs +++ b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs @@ -16,7 +16,7 @@ namespace StardustCore.Objects.Tools.SerializationInformation this.SerializationName = this.GetSerializationName(); } - public virtual Type getCutsomType() + public virtual Type getCustomType() { return this.GetType(); } diff --git a/GeneralMods/StardustCore/Serialization/Serialization.cs b/GeneralMods/StardustCore/Serialization/Serialization.cs index d3faa361..f59e351b 100644 --- a/GeneralMods/StardustCore/Serialization/Serialization.cs +++ b/GeneralMods/StardustCore/Serialization/Serialization.cs @@ -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) { diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 67405b94..eddcade2 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -89,8 +89,15 @@ + + + + + + +