diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
index 191847a7..aa5cc108 100644
--- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs
@@ -77,7 +77,6 @@ namespace Revitalize.Framework.Objects
/// Places an object down.
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
{
- ModCore.ModMonitor.Log("SCREAMING!!!!");
this.updateDrawPosition(x, y);
this.location = location;
@@ -115,38 +114,29 @@ namespace Revitalize.Framework.Objects
//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"]));
-
-
- //do same container creation logic in multitiled object
-
-
- MultiTiledComponent self = Revitalize.ModCore.Serializer.DeserializeGUID( additionalSaveData["GUID"]);
- if (self == null) return null;
+ MultiTiledComponent self = Revitalize.ModCore.Serializer.DeserializeGUID( additionalSaveData["GUID"]);
+ if (self == null)
+ {
+ return null;
+ }
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
- {
+ {
//Get new container
MultiTiledObject obj = (MultiTiledObject)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"], (MultiTiledObject)obj);
- }
- else
- {
- self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
+ }
+ 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;
- BasicItemInformation data = Revitalize.ModCore.customObjects[additionalSaveData["id"]].info;
- return new MultiTiledComponent(data, (replacement as Chest).TileLocation)
- {
- containerObject = this.containerObject,
- offsetKey = this.offsetKey,
- Stack = Convert.ToInt32(additionalSaveData["stack"])
- };
+ return (ICustomObject)self;
}
public override Dictionary getAdditionalSaveData()
@@ -158,7 +148,7 @@ namespace Revitalize.Framework.Objects
string saveLocation = "";
if (this.location == null)
{
- Revitalize.ModCore.log("WHY IS LOCTION NULL???");
+ //Revitalize.ModCore.log("WHY IS LOCTION NULL???");
saveLocation = "";
}
else
@@ -170,7 +160,6 @@ namespace Revitalize.Framework.Objects
}
}
- Revitalize.ModCore.log("SAVE LOCATION: " + saveLocation);
saveData.Add("GameLocationName", saveLocation);
saveData.Add("Rotation", ((int)this.info.facingDirection).ToString());
@@ -199,8 +188,6 @@ namespace Revitalize.Framework.Objects
/// What happens when the object is drawn at a tile location.
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{
- Revitalize.ModCore.log("DRAW THE THING!!!");
- Revitalize.ModCore.log(this.Name);
if (this.info == null) Revitalize.ModCore.log("info is null");
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
index 9670abeb..c5b822e3 100644
--- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
@@ -174,7 +174,6 @@ namespace Revitalize.Framework.Objects
}
public override bool clicked(Farmer who)
{
- ModCore.log("WTF IS HAPPENING???");
bool cleanUp = this.clicked(who);
if (cleanUp)
this.pickUp();
@@ -213,7 +212,10 @@ namespace Revitalize.Framework.Objects
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]);
- if (obj == null) return null;
+ if (obj == null)
+ {
+ return null;
+ }
Dictionary guids = new Dictionary();
diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs
index 06da37c4..5f73bc18 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs
@@ -25,6 +25,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
{
string textureName = reader.Value as string;
//ModCore.log(textureName);
+ if (string.IsNullOrEmpty(textureName)) return new Texture2D(Game1.graphics.GraphicsDevice, 2, 2);
string[] names = textureName.Split('.');
if (names.Length == 0) return null;
diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
index 6e4744c7..dffd06ea 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json;
using Revitalize.Framework.Utilities.Serialization.ContractResolvers;
using StardewValley;
+using StardewValley.Objects;
namespace Revitalize.Framework.Utilities
{
@@ -24,7 +25,7 @@ namespace Revitalize.Framework.Utilities
///
private Dictionary> filesToDelete = new Dictionary>();
-
+ public List- itemsToRemove = new List
- ();
///
@@ -54,7 +55,7 @@ namespace Revitalize.Framework.Utilities
///
private void gatherAllFilesForCleanup()
{
-
+ this.filesToDelete.Clear();
string[] directories = Directory.GetDirectories(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
foreach (string playerData in directories)
{
@@ -85,6 +86,30 @@ namespace Revitalize.Framework.Utilities
public void afterLoad()
{
deleteAllUnusedFiles();
+ removeNullObjects();
+ }
+
+ public void returnToTitle()
+ {
+ gatherAllFilesForCleanup();
+ }
+
+ private void removeNullObjects()
+ {
+ List
- removalList = new List
- ();
+ foreach(Item I in Game1.player.items)
+ {
+ if (I == null) continue;
+ if (I.DisplayName.Contains("Revitalize.Framework") && (I is Chest))
+ {
+ removalList.Add(I);
+ }
+
+ }
+ foreach(Item I in removalList)
+ {
+ Game1.player.items.Remove(I);
+ }
}
///
diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs
index d14bd4d1..0cccbbb1 100644
--- a/GeneralMods/Revitalize/ModCore.cs
+++ b/GeneralMods/Revitalize/ModCore.cs
@@ -20,9 +20,6 @@ using StardewValley.Objects;
namespace Revitalize
{
// TODO:
- // Find a way to delete unnecessary files in SaveData/Player/SaveObjectInformation
- //
- //
//
// -Multiple Lights On Object
// -Illumination Colors
@@ -119,6 +116,7 @@ namespace Revitalize
ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded;
ModHelper.Events.GameLoop.TimeChanged += this.GameLoop_TimeChanged;
ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
+ ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle;
playerInfo = new PlayerInfo();
Framework.Graphics.TextureManager.TextureManagers.Add("Furniture", new TextureManager());
@@ -132,6 +130,11 @@ namespace Revitalize
}
+ private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e)
+ {
+ Serializer.returnToTitle();
+ }
+
private void loadContent()
{
MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.Red, true, null, null));