diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs
index dcb607c4..e59c96c5 100644
--- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs
+++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs
@@ -5,11 +5,23 @@ using StardewValley;
namespace Revitalize.Framework.Crafting
{
+ ///
+ /// A crafting recipe.
+ ///
public class Recipe
{
+ ///
+ /// The ingredients necessary to craft this recipe.
+ ///
public Dictionary- ingredients;
+ ///
+ /// The items produced by this recipe.
+ ///
public Dictionary
- outputs;
+ ///
+ /// The item that is displayed for the crafting recipe.
+ ///
private Item displayItem;
public Item DisplayItem
@@ -18,9 +30,18 @@ namespace Revitalize.Framework.Crafting
set => this.displayItem = value;
}
+ ///
+ /// The description for the crafting recipe.
+ ///
public string outputDescription;
+ ///
+ /// The name for the crafting recipe.
+ ///
public string outputName;
+ ///
+ /// The stats that this recipe costs. Magic, HP, stamina, gold, etc.
+ ///
public StatCost statCost;
public Recipe() { }
@@ -91,6 +112,10 @@ namespace Revitalize.Framework.Crafting
&& self.GetType() == other.GetType();
}
+ ///
+ /// Consumes all of the ingredients for the recipe.
+ ///
+ ///
public void consume(ref List
- from)
{
if (this.InventoryContainsAllIngredient(from)==false)
@@ -119,6 +144,12 @@ namespace Revitalize.Framework.Crafting
from = manager.items;
}
+ ///
+ /// Produces outputs for the crafting recipe.
+ ///
+ ///
+ ///
+ ///
public void produce(ref List
- to, bool dropToGround = false, bool isPlayerInventory = false)
{
var manager = isPlayerInventory
@@ -135,7 +166,15 @@ namespace Revitalize.Framework.Crafting
to = manager.items;
}
- public void craft(ref List
- from, ref List
- to, bool dropToGround = false, bool isPlayerInventory = false)
+
+ ///
+ /// Consumes all ingredients in given inventory and adds in outputs to the other given inventory.
+ ///
+ /// The inventory to take ingredients from.
+ /// The inventory to put outputs into.
+ /// Should this item be dropped to the ground when crafted?
+ /// Checks to see if the invventory is the player's
+ private void craft(ref List
- from, ref List
- to, bool dropToGround = false, bool isPlayerInventory = false)
{
InventoryManager manager = new InventoryManager(to);
if (manager.ItemCount + this.outputs.Count >= manager.capacity)
@@ -148,6 +187,9 @@ namespace Revitalize.Framework.Crafting
this.produce(ref to, dropToGround, isPlayerInventory);
}
+ ///
+ /// Actually crafts the recipe.
+ ///
public void craft()
{
List
- playerItems = Game1.player.Items.ToList();
diff --git a/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs
index 540bf0c1..dc00e61c 100644
--- a/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs
+++ b/GeneralMods/Revitalize/Framework/Hacks/MenuHacks.cs
@@ -10,14 +10,28 @@ using StardewValley.Menus;
namespace Revitalize.Framework.Hacks
{
+ ///
+ /// Deals with hijacking menus for custom logic.
+ ///
public class MenuHacks
{
+ ///
+ /// Checks to see if the mod has had it's custom object processed at the end of the day.
+ ///
public static bool EndOfDay_HasProcessedModdedItems;
+ ///
+ /// Checks to see if the end of day menus are up and running.
+ ///
+ ///
public static bool EndOfDay_IsShowingEndOfNightMenus()
{
return Game1.showingEndOfNightStuff;
}
+ ///
+ /// Checks to see if the current end of day menu is the shippping menu.
+ ///
+ ///
public static bool EndOfDay_IsEndOfDayMenuShippingMenu()
{
if (EndOfDay_IsShowingEndOfNightMenus())
@@ -36,6 +50,10 @@ namespace Revitalize.Framework.Hacks
else return false;
}
+ ///
+ /// Gets the shipping menu from the end of day menus.
+ ///
+ ///
public static ShippingMenu EndOfDay_GetShippingMenu()
{
if (EndOfDay_IsEndOfDayMenuShippingMenu())
@@ -49,6 +67,9 @@ namespace Revitalize.Framework.Hacks
return null;
}
+ ///
+ /// Hijacks the shipping menu to process modded items.
+ ///
public static void EndOfDay_HackShipping()
{
if (EndOfDay_GetShippingMenu() != null)
@@ -101,7 +122,12 @@ namespace Revitalize.Framework.Hacks
}
}
- public static void EndOfDay_OnMenuChanged(object o, StardewModdingAPI.Events.RenderedEventArgs sender)
+ ///
+ /// Triggers
+ ///
+ ///
+ ///
+ public static void EndOfDay_RenderCheck(object o, StardewModdingAPI.Events.RenderedEventArgs sender)
{
if (EndOfDay_IsShowingEndOfNightMenus() && EndOfDay_HasProcessedModdedItems==false)
{
diff --git a/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs
new file mode 100644
index 00000000..360b2795
--- /dev/null
+++ b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Xna.Framework;
+using StardewValley;
+using SObject = StardewValley.Object;
+namespace Revitalize.Framework.Hacks
+{
+ public class ObjectInteractionHacks
+ {
+
+ ///
+ /// Returns the object underneath the mouse's position.
+ ///
+ ///
+ public static SObject GetItemAtMouseTile()
+ {
+ Vector2 mouseTilePosition = Game1.currentCursorTile;
+ if (Game1.player.currentLocation.isObjectAtTile((int)mouseTilePosition.X, (int)mouseTilePosition.Y))
+ {
+ return Game1.player.currentLocation.getObjectAtTile((int)mouseTilePosition.X, (int)mouseTilePosition.Y);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Checks to see if the given object is a SDV vanilla furnace.
+ ///
+ ///
+ ///
+ public static bool IsObjectFurnace(SObject obj)
+ {
+ if (obj.ParentSheetIndex == 13 && obj.bigCraftable.Value && obj.Category == -9 && obj.Name == "Furnace")
+ {
+ return true;
+ }
+ else return false;
+ }
+
+ public static void Input_CheckForObjectInteraction(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e)
+ {
+ if(e.Button== StardewModdingAPI.SButton.MouseRight)
+ {
+ SObject obj= GetItemAtMouseTile();
+ }
+ }
+
+ }
+}
diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
index 2bd9a172..9b46d975 100644
--- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
@@ -23,6 +23,7 @@ namespace Revitalize.Framework.Objects
public bool canBeSetIndoors;
public bool canBeSetOutdoors;
public bool isLamp;
+ public string locationName;
public AnimationManager animationManager;
diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
index 5da1e942..49d10e85 100644
--- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
@@ -29,7 +29,29 @@ namespace Revitalize.Framework.Objects
public BasicItemInformation info;
- public GameLocation location;
+ private GameLocation _location;
+ [JsonIgnore]
+ public GameLocation location
+ {
+ get
+ {
+ if (this._location == null)
+ {
+ this._location = Game1.getLocationFromName(this.info.locationName);
+ return this._location;
+ }
+ return this._location;
+ }
+ set
+ {
+ this._location = value;
+ if (this._location == null) this.info.locationName = "";
+ else
+ {
+ this.info.locationName = this._location.Name;
+ }
+ }
+ }
public Guid guid;
@@ -443,7 +465,18 @@ namespace Revitalize.Framework.Objects
}
+ public virtual void replaceAfterLoad()
+ {
+ if (string.IsNullOrEmpty(this.info.locationName) == false)
+ {
+ ModCore.log("Replace an object!");
+ this.location.removeObject(this.TileLocation, false);
+ this.placementAction(this.location, (int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize);
+ ModCore.log("Do I ingnore BB? " + this.info.ignoreBoundingBox);
+ ModCore.log("This is my BB: " + this.boundingBox.Value);
+ }
+ }
public string getDisplayNameFromStringsFile(string objectID)
diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs
index f523d22c..df47002b 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs
@@ -133,39 +133,40 @@ namespace Revitalize.Framework.Objects.Extras
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
- //instead of using this.offsetkey.x use get additional save data function and store offset key there
-
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ string GUID = additionalSaveData["GUID"];
ArcadeCabinetTile self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (self == null)
+ if (ModCore.IsNullOrDefault(self)) return null;
+ try
{
- return null;
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ ArcadeCabinetOBJ obj = (ArcadeCabinetOBJ)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ }
+ }
+ catch (Exception err)
+ {
+ ModCore.log(err);
}
- if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
- {
- //Get new container
- ArcadeCabinetOBJ obj = (ArcadeCabinetOBJ)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
- self.containerObject = obj;
- obj.addComponent(offsetKey, self);
- //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
- Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
- }
- else
- {
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
- Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
- //Revitalize.ModCore.log("READD AN OBJECT!!!!");
- }
-
- return (ICustomObject)self;
+ return self;
}
public override Dictionary getAdditionalSaveData()
{
Dictionary saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs
index a11249d5..6634cc31 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs
@@ -98,39 +98,40 @@ namespace Revitalize.Framework.Objects.Furniture
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
- //instead of using this.offsetkey.x use get additional save data function and store offset key there
-
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ string GUID = additionalSaveData["GUID"];
ChairTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (self == null)
+ if (ModCore.IsNullOrDefault(self)) return null;
+ try
{
- return null;
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ }
+ }
+ catch (Exception err)
+ {
+ ModCore.log(err);
}
- if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
- {
- //Get new container
- ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
- self.containerObject = obj;
- obj.addComponent(offsetKey, self);
- //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
- Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
- }
- else
- {
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
- Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
- //Revitalize.ModCore.log("READD AN OBJECT!!!!");
- }
-
- return (ICustomObject)self;
+ return self;
}
public override Dictionary getAdditionalSaveData()
{
Dictionary saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs
index ec7cb43b..77c9c7a6 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs
@@ -135,36 +135,39 @@ namespace Revitalize.Framework.Objects.Furniture
//instead of using this.offsetkey.x use get additional save data function and store offset key there
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ string GUID = additionalSaveData["GUID"];
LampTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (self == null)
+ if (ModCore.IsNullOrDefault(self)) return null;
+ try
{
- return null;
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ LampMultiTiledObject obj = (LampMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ }
+ }
+ catch (Exception err)
+ {
+ ModCore.log(err);
}
- if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
- {
- //Get new container
- LampMultiTiledObject obj = (LampMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
- self.containerObject = obj;
- obj.addComponent(offsetKey, self);
- //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
- Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
- }
- else
- {
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
- Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
- //Revitalize.ModCore.log("READD AN OBJECT!!!!");
- }
-
- return (ICustomObject)self;
+ return self;
}
public override Dictionary getAdditionalSaveData()
{
Dictionary saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs
index a6b1d797..04cc22df 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs
@@ -54,39 +54,40 @@ namespace Revitalize.Framework.Objects.Furniture
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
- //instead of using this.offsetkey.x use get additional save data function and store offset key there
-
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ string GUID = additionalSaveData["GUID"];
RugTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (self == null)
+ if (ModCore.IsNullOrDefault(self)) return null;
+ try
{
- return null;
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ RugMultiTiledObject obj = (RugMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ }
+ }
+ catch (Exception err)
+ {
+ ModCore.log(err);
}
- if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
- {
- //Get new container
- RugMultiTiledObject obj = (RugMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
- self.containerObject = obj;
- obj.addComponent(offsetKey, self);
- //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
- Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
- }
- else
- {
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
- Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
- //Revitalize.ModCore.log("READD AN OBJECT!!!!");
- }
-
- return (ICustomObject)self;
+ return self;
}
public override Dictionary getAdditionalSaveData()
{
Dictionary saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs
index 4f019415..157d5a6e 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureTile.cs
@@ -117,39 +117,40 @@ namespace Revitalize.Framework.Objects.Furniture
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
- //instead of using this.offsetkey.x use get additional save data function and store offset key there
-
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ string GUID = additionalSaveData["GUID"];
StorageFurnitureTile self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (self == null)
+ if (ModCore.IsNullOrDefault(self)) return null;
+ try
{
- return null;
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ StorageFurnitureOBJ obj = (StorageFurnitureOBJ)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ }
+ }
+ catch (Exception err)
+ {
+ ModCore.log(err);
}
- if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
- {
- //Get new container
- StorageFurnitureOBJ obj = (StorageFurnitureOBJ)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
- self.containerObject = obj;
- obj.addComponent(offsetKey, self);
- //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
- Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
- }
- else
- {
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
- Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
- //Revitalize.ModCore.log("READD AN OBJECT!!!!");
- }
-
- return (ICustomObject)self;
+ return self;
}
public override Dictionary getAdditionalSaveData()
{
Dictionary saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs
index 7a938bd8..56200fc6 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs
@@ -191,38 +191,52 @@ namespace Revitalize.Framework.Objects.Furniture
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
//instead of using this.offsetkey.x use get additional save data function and store offset key there
-
+ //ModCore.log("Recreate a table tile component!");
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ //ModCore.log("Got the offset key!");
+ string GUID = additionalSaveData["GUID"];
+ //ModCore.log("This tile has a parent guid of: " + additionalSaveData["ParentGUID"]);
TableTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (self == null)
+
+ if (ModCore.IsNullOrDefault(self))
{
+ //ModCore.log("SELF IS NULL");
return null;
}
-
- if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ try
{
- //Get new container
- TableMultiTiledObject obj = (TableMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
- self.containerObject = obj;
- obj.addComponent(offsetKey, self);
- //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
- Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ //ModCore.log("Load in the parent!");
+ //Get new container
+ TableMultiTiledObject obj = (TableMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ //ModCore.log("Parent already exists!");
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ //Revitalize.ModCore.log("READD AN OBJECT!!!!");
+ }
}
- else
+ catch(Exception err)
{
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
- Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
- //Revitalize.ModCore.log("READD AN OBJECT!!!!");
+ ModCore.log(err);
}
- return (ICustomObject)self;
+ return self;
}
public override Dictionary getAdditionalSaveData()
{
Dictionary saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs
index e8b5311e..6f2fda10 100644
--- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/OreResourceInformation.cs
@@ -115,7 +115,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
///
///
///
- public OreResourceInformation(Item I, List FloorsToSpawnOn, List FloorsToExclude,Func CanSpawnOnGivenFloor,Func FloorsToExcludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, double ChanceToSpawn = 1f, double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes, ChanceToSpawn, ChanceToDrop, SpawnChanceLuckFactor, SpawnAmountLuckFactor, DropChanceLuckFactor, DropAmountLuckFactor)
+ public OreResourceInformation(StardewValley.Object I, List FloorsToSpawnOn, List FloorsToExclude,Func CanSpawnOnGivenFloor,Func FloorsToExcludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, double ChanceToSpawn = 1f, double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes, ChanceToSpawn, ChanceToDrop, SpawnChanceLuckFactor, SpawnAmountLuckFactor, DropChanceLuckFactor, DropAmountLuckFactor)
{
this.spawnsOnFarm = false;
this.spawnsInQuarry = false;
@@ -172,7 +172,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
///
///
///
- public OreResourceInformation(Item I,bool SpawnsOnFarm, bool SpawnsInQuarry, bool SpawnInRegularMine, bool SpawnInSkullCave,List FloorsToSpawnOn,ListFloorsToExclude,Func CanSpawnOnGivenFloor,Func FloorsToExludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, IntRange FarmSpawnAmount,IntRange QuarrySpawnAmount,IntRange SkullCaveSpawnAmount,List FloorsToSpawnOnSkullCave,ListFloorsToExludeSkullCave,Func CanSpawnOnGivenFloorSkullCave,FuncFloorsToExludeFunSkullCave,double ChanceToSpawn = 1f,double FarmSpawnChance=1f,double QuarrySpawnChance=1f,double SkullCaveSpawnChance=1f,double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes,ChanceToSpawn,ChanceToDrop,SpawnChanceLuckFactor,SpawnAmountLuckFactor,DropChanceLuckFactor,DropAmountLuckFactor)
+ public OreResourceInformation(StardewValley.Object I,bool SpawnsOnFarm, bool SpawnsInQuarry, bool SpawnInRegularMine, bool SpawnInSkullCave,List FloorsToSpawnOn,ListFloorsToExclude,Func CanSpawnOnGivenFloor,Func FloorsToExludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, IntRange FarmSpawnAmount,IntRange QuarrySpawnAmount,IntRange SkullCaveSpawnAmount,List FloorsToSpawnOnSkullCave,ListFloorsToExludeSkullCave,Func CanSpawnOnGivenFloorSkullCave,FuncFloorsToExludeFunSkullCave,double ChanceToSpawn = 1f,double FarmSpawnChance=1f,double QuarrySpawnChance=1f,double SkullCaveSpawnChance=1f,double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes,ChanceToSpawn,ChanceToDrop,SpawnChanceLuckFactor,SpawnAmountLuckFactor,DropChanceLuckFactor,DropAmountLuckFactor)
{
// Deals with setting where this ore can spawn.
this.spawnsOnFarm = SpawnsOnFarm;
diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs
index ac29c232..a6fa0b48 100644
--- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ResourceInformaton.cs
@@ -15,7 +15,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
///
/// The item to drop.
///
- public Item droppedItem;
+ public StardewValley.Object droppedItem;
///
/// The min amount of resources to drop given the getNumberOfDrops function.
@@ -79,7 +79,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
///
///
///
- public ResourceInformaton(Item I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,double ChanceToSpawn=1f,double ChanceToDrop=1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f,double DropChanceLuckFactor=0f, double DropAmountLuckFactor = 0f)
+ public ResourceInformaton(StardewValley.Object I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,double ChanceToSpawn=1f,double ChanceToDrop=1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f,double DropChanceLuckFactor=0f, double DropAmountLuckFactor = 0f)
{
this.droppedItem = I;
this.minResourcePerDrop = MinDropAmount;
diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
index 48a8041f..cdfcbe6a 100644
--- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
@@ -95,6 +95,14 @@ namespace Revitalize.Framework.Objects
this.performDropDownAction(who);
location.objects.Add(this.TileLocation, this);
+
+
+ if(this.getBoundingBox(this.TileLocation).Width==0&& this.getBoundingBox(this.TileLocation).Height == 0)
+ {
+ this.boundingBox.Value = new Rectangle(this.boundingBox.X, this.boundingBox.Y, Game1.tileSize, Game1.tileSize);
+ }
+ ModCore.log(this.getBoundingBox(this.TileLocation));
+
return true;
}
@@ -181,7 +189,7 @@ namespace Revitalize.Framework.Objects
saveData.Add("ParentGUID", this.containerObject.guid.ToString());
saveData.Add("GUID", this.guid.ToString());
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(),this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
index 929c8340..8fb36d62 100644
--- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
@@ -81,7 +81,11 @@ namespace Revitalize.Framework.Objects
}
this.objects.Add(key, obj);
- this.childrenGuids.Add(key, new Guid());
+ if (this.childrenGuids.ContainsKey(key)==false)
+ {
+ this.childrenGuids.Add(key, obj.guid);
+ }
+
if (key.X > this.width) this.width = (int)key.X;
if (key.Y > this.height) this.height = (int)key.Y;
@@ -92,11 +96,8 @@ namespace Revitalize.Framework.Objects
public bool removeComponent(Vector2 key)
{
-
-
if (!this.objects.ContainsKey(key))
return false;
-
this.objects.Remove(key);
return true;
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs
index a74b5b33..d0c9c97e 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinTile.cs
@@ -241,40 +241,40 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
- //instead of using this.offsetkey.x use get additional save data function and store offset key there
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
+ string GUID = additionalSaveData["GUID"];
OreVeinTile self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (self == null)
+ if (ModCore.IsNullOrDefault(self)) return null;
+ try
{
- return null;
+ if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
+ {
+ OreVeinObj obj = (OreVeinObj)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
+ self.containerObject = obj;
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
+ }
+ else
+ {
+ self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ self.containerObject.removeComponent(offsetKey);
+ self.containerObject.addComponent(offsetKey, self);
+ }
+ }
+ catch (Exception err)
+ {
+ ModCore.log(err);
}
- if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
- {
- //Get new container
- OreVeinObj obj = (OreVeinObj)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]);
- self.containerObject = obj;
- obj.addComponent(offsetKey, self);
- //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
- Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
- }
- else
- {
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
- Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
- //Revitalize.ModCore.log("READD AN OBJECT!!!!");
- }
-
- return (ICustomObject)self;
-
- //throw new Exception("Why am I trying to recreate an ore vein?");
+ return self;
}
public override Dictionary getAdditionalSaveData()
{
Dictionary saveData = base.getAdditionalSaveData();
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
-
+ this.containerObject.getAdditionalSaveData();
return saveData;
}
diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/CustomObjectDataConverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/CustomObjectDataConverter.cs
new file mode 100644
index 00000000..de63a30e
--- /dev/null
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/CustomObjectDataConverter.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using PyTK.CustomElementHandler;
+
+namespace Revitalize.Framework.Utilities.Serialization.Converters
+{
+ public class CustomObjectDataConverter: JsonConverter
+ {
+ JsonSerializerSettings settings;
+
+ public CustomObjectDataConverter()
+ {
+ this.settings = new JsonSerializerSettings()
+ {
+ Converters = new List()
+ {
+ new Framework.Utilities.Serialization.Converters.RectangleConverter(),
+ new Framework.Utilities.Serialization.Converters.Texture2DConverter(),
+ new Vector2Converter(),
+ },
+ Formatting = Formatting.Indented,
+ ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+ NullValueHandling = NullValueHandling.Include
+ };
+ }
+
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ List properties = value.GetType().GetProperties().ToList();
+ List fields = value.GetType().GetFields().ToList();
+
+ writer.WriteStartObject();
+
+ for (int i = 0; i < properties.Count; i++)
+ {
+ PropertyInfo p = properties[i];
+ writer.WritePropertyName(p.Name);
+ serializer.Serialize(writer, p.GetValue(value) != null ? ModCore.Serializer.ToJSONString(p.GetValue(value)) : null);
+ }
+
+
+ foreach (FieldInfo f in fields)
+ {
+ writer.WritePropertyName(f.Name);
+ serializer.Serialize(writer, f.GetValue(value) != null ? ModCore.Serializer.ToJSONString(f.GetValue(value)) : null);
+ }
+
+ writer.WriteEndObject();
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ if (reader.TokenType == JsonToken.Null)
+ {
+
+ throw new JsonSerializationException("Cant convert to item!");
+ return null;
+ }
+
+ JObject jo = JObject.Load(reader);
+
+ string id = jo["id"].Value();
+ string texture = jo["texture"].Value();
+ string type = jo["type"].Value();
+ string color = jo["color"].Value();
+ string bigcraftable = jo["bigCraftable"].Value();
+
+ Texture2D tex=ModCore.Serializer.DeserializeFromJSONString(texture);
+ Type t = Type.GetType(type);
+ Color c = ModCore.Serializer.DeserializeFromJSONString(color);
+ bool craftable = ModCore.Serializer.DeserializeFromJSONString(bigcraftable);
+
+ return PyTKHelper.CreateOBJData(id, tex, t, c, craftable);
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(CustomObjectData);
+ }
+ }
+}
diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs
index 0d510cef..81547b24 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs
@@ -11,7 +11,7 @@ using StardewValley;
namespace Revitalize.Framework.Utilities.Serialization.Converters
{
- public class ItemCoverter:Newtonsoft.Json.JsonConverter
+ public class ItemCoverter : Newtonsoft.Json.JsonConverter
{
public static Dictionary AllTypes = new Dictionary();
@@ -24,7 +24,6 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
{
new Framework.Utilities.Serialization.Converters.RectangleConverter(),
new Framework.Utilities.Serialization.Converters.Texture2DConverter(),
- new Vector2Converter()
},
Formatting = Formatting.Indented,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
@@ -40,30 +39,8 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
writer.WriteStartObject();
writer.WritePropertyName("Type");
serializer.Serialize(writer, value.GetType().FullName.ToString());
-
- List properties=value.GetType().GetProperties().ToList();
- List fields=value.GetType().GetFields().ToList();
-
writer.WritePropertyName("Item");
- writer.WriteStartObject();
-
- for(int i = 0; i < properties.Count; i++) {
- PropertyInfo p = properties[i];
- writer.WritePropertyName(p.Name);
- serializer.Serialize(writer, p.GetValue(value)!=null? p.GetValue(value).ToString():null);
- }
-
-
- foreach (FieldInfo f in fields)
- {
- writer.WritePropertyName(f.Name);
- serializer.Serialize(writer, f.GetValue(value) != null ? f.GetValue(value).ToString() : null);
- }
- writer.WriteEndObject();
-
- //writer.WritePropertyName("Item");
-
- //serializer.Serialize(writer, convertedString);
+ serializer.Serialize(writer, convertedString);
writer.WriteEndObject();
}
@@ -98,20 +75,18 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
Assembly asm = typeof(StardewValley.Object).Assembly;
Type type = null;
-
+
type = asm.GetType(t);
- //Check if the type exists in the SDV assembly. If not then try to load it from revitalize.
if (type == null)
{
asm = typeof(Revitalize.ModCore).Assembly;
type = asm.GetType(t);
}
- //If the type doesn't exist from revitalize look through ALL loded assemblies and try to load it.
if (type == null)
{
- foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
asm = assembly;
type = asm.GetType(t);
@@ -121,13 +96,13 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
if (type == null)
{
- throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can't deserialize this thing!: " + t);
+ throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can;t deserialize this thing!: " + t);
}
//Cache the newly found type.
AllTypes.Add(t, type);
- return JsonConvert.DeserializeObject(jo["Item"].ToString(),type, this.settings);
+ return JsonConvert.DeserializeObject(jo["Item"].ToString(), type, this.settings);
/*
if (t== typeof(StardewValley.Tools.Axe).FullName.ToString())
{
@@ -141,17 +116,13 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
Revitalize.ModCore.log("DESERIALIZE Multi Tile Object!!!");
return JsonConvert.DeserializeObject(jo["Item"].ToString(), this.settings);
// return jo["Item"].Value();
-
}
else if (t == typeof(Revitalize.Framework.Objects.MultiTiledComponent).FullName.ToString())
{
-
Revitalize.ModCore.log("DESERIALIZE Multi Tile Component!!!");
return JsonConvert.DeserializeObject(jo["Item"].ToString(), this.settings);
// return jo["Item"].Value();
-
}
-
else
{
@@ -167,7 +138,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
public override bool CanConvert(Type objectType)
{
- return this.IsSameOrSubclass(typeof(StardewValley.Item),objectType);
+ return this.IsSameOrSubclass(typeof(StardewValley.Item), objectType);
}
///
diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
index ba326e08..55d0b80e 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
@@ -44,10 +44,11 @@ namespace Revitalize.Framework.Utilities
this.addConverter(new Framework.Utilities.Serialization.Converters.RectangleConverter());
this.addConverter(new Framework.Utilities.Serialization.Converters.Texture2DConverter());
this.addConverter(new Framework.Utilities.Serialization.Converters.ItemCoverter());
+ //this.addConverter(new Framework.Utilities.Serialization.Converters.CustomObjectDataConverter());
//this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter());
//this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter());
- this.gatherAllFilesForCleanup();
+ //this.gatherAllFilesForCleanup();
this.settings = new JsonSerializerSettings();
foreach(JsonConverter converter in this.serializer.Converters)
@@ -91,6 +92,27 @@ namespace Revitalize.Framework.Utilities
}
}
+ private void deleteFilesBeforeSave()
+ {
+ if (!Directory.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"))) Directory.CreateDirectory(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
+ this.filesToDelete.Clear();
+ string[] directories = Directory.GetDirectories(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
+ foreach (string playerData in directories)
+ {
+ string objectPath = Path.Combine(playerData, "SavedObjectInformation");
+ string[] objectFiles = Directory.GetFiles(objectPath);
+ foreach (string file in objectFiles)
+ {
+ string playerName = new DirectoryInfo(objectPath).Parent.Name;
+ if (playerName != this.getUniqueCharacterString()) return;
+ else
+ {
+ File.Delete(file);
+ }
+ }
+ }
+ }
+
///
/// Called after load to deal with internal file cleanUp
///
@@ -102,7 +124,7 @@ namespace Revitalize.Framework.Utilities
public void returnToTitle()
{
- this.gatherAllFilesForCleanup();
+ //this.gatherAllFilesForCleanup();
}
private void removeNullObjects()
@@ -257,15 +279,15 @@ namespace Revitalize.Framework.Utilities
public T DeserializeGUID(string fileName)
{
string path = Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData", Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID, "SavedObjectInformation", fileName + ".json");
- this.removeFileFromDeletion((Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID),path);
+ //this.removeFileFromDeletion((Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID),path);
if (File.Exists(path))
{
-
+ //ModCore.log("Deseralizing file:" + path);
return this.Deserialize(path);
}
else
{
- return default(T);
+ throw new Exception("Can't deserialize file. Default returned. " + path);
}
}
@@ -330,6 +352,20 @@ namespace Revitalize.Framework.Utilities
this.Serialize(path, obj);
}
+ public void DayEnding_CleanUpFilesForDeletion(object o, StardewModdingAPI.Events.DayEndingEventArgs sender)
+ {
+ //ModCore.log("Day ending now delete files!");
+ this.deleteFilesBeforeSave();
+ }
+
+ ///
+ /// Gets the unique character path string.
+ ///
+ ///
+ public string getUniqueCharacterString()
+ {
+ return Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID;
+ }
///
/// https://stackoverflow.com/questions/2742276/how-do-i-check-if-a-type-is-a-subtype-or-the-type-of-an-object
diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs
index 403d4301..3b038854 100644
--- a/GeneralMods/Revitalize/ModCore.cs
+++ b/GeneralMods/Revitalize/ModCore.cs
@@ -31,10 +31,11 @@ namespace Revitalize
// -Chair tops cut off objects
// -load content MUST be enabled for the table to be placed?????? WTF
// TODO:
- /*
+ /* Add in crafting menu.
+ * Add in crafting table.
+ * Find way to hack vanilla furnace for more recipes.
*
*
- // -Add in object pool class to handle the multitudes of objects I'll be making. (WIP)
// -Make this mod able to load content packs for easier future modding
//
// -Multiple Lights On Object
@@ -49,6 +50,8 @@ namespace Revitalize
// -fun interactables
// -Arcade machines
// -More crafting tables
+ // -Baths (see chairs but swimming)
+ //
// -Machines
// !=Energy
// Generators:
@@ -56,7 +59,7 @@ namespace Revitalize
-burnable
-watermill
-windmill
- -crank
+ -crank (costs stamina)
Storage:
-Batery Pack
-
@@ -66,6 +69,8 @@ namespace Revitalize
// -Stone Quarry
// -Mayo Maker
// -Cheese Maker
+ -Yogurt Maker
+ -Fruit yogurts (artisan good)
// -Auto fisher
// -Auto Preserves
// -Auto Keg
@@ -237,7 +242,9 @@ namespace Revitalize
ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed;
ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged;
ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn;
+ ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction;
+ ModHelper.Events.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion;
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
}
@@ -335,7 +342,7 @@ namespace Revitalize
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet);
- ModCore.log("Added in SSC!");
+ //ModCore.log("Added in SSC!");
}
private void createDirectories()
@@ -380,10 +387,19 @@ namespace Revitalize
{
throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!");
}
+
+ foreach(var v in ObjectGroups)
+ {
+ foreach(var obj in v.Value.objects.Values)
+ {
+ (obj as CustomObject).replaceAfterLoad();
+ }
+ }
+
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
- //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
+ Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest"));
- //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Tables.OakTable"));
+ Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable"));
//Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
//Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous));
@@ -398,11 +414,12 @@ namespace Revitalize
Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin",19));
- Ore tin = ObjectManager.resources.getOre("Tin", 19);
+ //Ore tin = ObjectManager.resources.getOre("Tin", 19);
- ModCore.log("Tin sells for: " + tin.sellToStorePrice());
+
+ //ModCore.log("Tin sells for: " + tin.sellToStorePrice());
- ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7));
+ //ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7));
}
/*
@@ -426,7 +443,35 @@ namespace Revitalize
///
public static void log(object message)
{
- ModMonitor.Log(message.ToString());
+ ModMonitor.Log(message.ToString()+" "+getFileDebugInfo());
+ }
+
+ public static string getFileDebugInfo()
+ {
+ string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(2).GetFileName();
+ int currentLine = new System.Diagnostics.StackTrace(true).GetFrame(2).GetFileLineNumber();
+ return currentFile + " line:" + currentLine;
+ }
+
+ public static bool IsNullOrDefault(T argument)
+ {
+ // deal with normal scenarios
+ if (argument == null) return true;
+ if (object.Equals(argument, default(T))) return true;
+
+ // deal with non-null nullables
+ Type methodType = typeof(T);
+ if (Nullable.GetUnderlyingType(methodType) != null) return false;
+
+ // deal with boxed value types
+ Type argumentType = argument.GetType();
+ if (argumentType.IsValueType && argumentType != methodType)
+ {
+ object obj = Activator.CreateInstance(argument.GetType());
+ return obj.Equals(argument);
+ }
+
+ return false;
}
}
}
diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj
index 6c8f7e16..92c3e77a 100644
--- a/GeneralMods/Revitalize/Revitalize.csproj
+++ b/GeneralMods/Revitalize/Revitalize.csproj
@@ -64,6 +64,7 @@
+
@@ -144,6 +145,7 @@
+
diff --git a/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs b/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs
index ae25f24c..e6523f05 100644
--- a/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs
+++ b/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs
@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardustCore.UIUtilities;
using StardustCore.UIUtilities.MenuComponents;
+using StardustCore.UIUtilities.MenuComponents.ComponentsV1;
namespace Vocalization.Framework.Menus
{
@@ -34,19 +35,19 @@ namespace Vocalization.Framework.Menus
public void setUpButtons()
{
- Texture2DExtended buttonTexture = new Texture2DExtended(Vocalization.ModHelper, Path.Combine("Content", "Graphics", "SliderButton.png"));
- Button bar = new Button(new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 200, 40), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("Content", "Graphics", "SliderBar.png")), new Rectangle(0, 0, 100, 10), 2f);
+ Texture2DExtended buttonTexture = new Texture2DExtended(Vocalization.ModHelper,Vocalization.Manifest,Path.Combine("Content", "Graphics", "SliderButton.png"));
+ Button bar = new Button(new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 200, 40), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png")), new Rectangle(0, 0, 100, 10), 2f);
//Texture2DExtended barTexture = new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png"));
Rectangle sourceRect = new Rectangle(0, 0, 4, 16);
this.sliderButton = new SliderButton("Slider", "Volume", new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 4, 16), buttonTexture, bar, sourceRect, 2f, new SliderInformation(SliderStyle.Horizontal, (int)(Vocalization.config.voiceVolume * 100), 1), new StardustCore.Animations.Animation(sourceRect), Color.White, Color.Black, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, null, true);
- Button english = new Button(LanguageName.English.ToString(), "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f);
- Button spanish = new Button(LanguageName.Spanish.ToString(), "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f);
- Button portuguese = new Button(LanguageName.Portuguese.ToString(), "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f);
- Button russian = new Button(LanguageName.Russian.ToString(), "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f);
- Button chinese = new Button(LanguageName.Chinese.ToString(), "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f);
- Button japanese = new Button(LanguageName.Japanese.ToString(), "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f);
- Button german = new Button(LanguageName.German.ToString(), "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f);
+ Button english = new Button(LanguageName.English.ToString(), "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f);
+ Button spanish = new Button(LanguageName.Spanish.ToString(), "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f);
+ Button portuguese = new Button(LanguageName.Portuguese.ToString(), "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f);
+ Button russian = new Button(LanguageName.Russian.ToString(), "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f);
+ Button chinese = new Button(LanguageName.Chinese.ToString(), "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f);
+ Button japanese = new Button(LanguageName.Japanese.ToString(), "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f);
+ Button german = new Button(LanguageName.German.ToString(), "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f);
List