From a752503964b2ba503ef827888e05061a81e0af7b Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 27 Aug 2019 19:42:05 -0700 Subject: [PATCH] Got custom furniture to sync before and after saves! --- .../Framework/Objects/CustomObject.cs | 2 +- .../Objects/Furniture/ChairTileComponent.cs | 4 +++- .../Objects/Furniture/LampTileComponent.cs | 2 ++ .../Objects/Furniture/TableTileComponent.cs | 2 ++ .../Furniture/ChairInformation.cs | 2 +- .../Furniture/FurnitureInformation.cs | 16 ---------------- .../Framework/Objects/MultiTiledComponent.cs | 2 +- .../Utilities/MultiplayerUtilities.cs | 18 +++++++++--------- .../Utilities/Serialization/Serialization.cs | 6 +++--- GeneralMods/Revitalize/Revitalize.csproj | 1 - 10 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 65531817..2487ac83 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -112,7 +112,7 @@ namespace Revitalize.Framework.Objects if (this.info == null) { - ModCore.log("Info was null when getting data."); + //ModCore.log("Info was null when getting data."); this.updateInfo(); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index 6634cc31..d3be7f08 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles.Furniture; using StardewValley; @@ -22,11 +23,12 @@ namespace Revitalize.Framework.Objects.Furniture /// /// Checks if the player can sit "on" this component. /// + [JsonIgnore] public bool CanSitHere { get { - return (this.furnitureInfo as InformationFiles.Furniture.ChairInformation).canSitHere; + return this.furnitureInfo.canSitHere; } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs index 77c9c7a6..cb483679 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Illuminate; using Revitalize.Framework.Utilities.Serialization; @@ -15,6 +16,7 @@ namespace Revitalize.Framework.Objects.Furniture { public class LampTileComponent:FurnitureTileComponent { + [JsonIgnore] public bool canTurnOn { get diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index 9e5ed04d..98303134 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using Newtonsoft.Json; using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles.Furniture; using Revitalize.Framework.Utilities.Serialization; @@ -18,6 +19,7 @@ namespace Revitalize.Framework.Objects.Furniture public TableInformation furnitureInfo; + [JsonIgnore] public bool CanPlaceItemsHere { get diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs index f1e4fe33..3719751f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ChairInformation.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Revitalize.Framework.Objects.InformationFiles.Furniture { - public class ChairInformation:FurnitureInformation + public class ChairInformation { public bool canSitHere; diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs deleted file mode 100644 index 2df3b252..00000000 --- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/FurnitureInformation.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Revitalize.Framework.Objects.InformationFiles.Furniture -{ - public class FurnitureInformation - { - public FurnitureInformation() - { - - } - } -} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 7f285116..b3a0d24d 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -365,7 +365,7 @@ namespace Revitalize.Framework.Objects if (this.info == null || this.containerObject==null) { this.ItemInfo = this.text; - ModCore.log("Updated item info!"); + //ModCore.log("Updated item info!"); return; } diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs index 4b4ac848..5e2e1c2d 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs @@ -18,17 +18,17 @@ namespace Revitalize.Framework.Utilities public static string RequestALLModObjects = "Revitalize.EndOfDayRequestAllObjects"; public static void GetModMessage(object o, StardewModdingAPI.Events.ModMessageReceivedEventArgs e) { - ModCore.log("Get a mod message: "+e.Type); + //ModCore.log("Get a mod message: "+e.Type); if (e.Type.Equals(RequestGUIDMessage)) { - ModCore.log("Send GUID Request"); + //ModCore.log("Send GUID Request"); Guid request = Guid.Parse(e.ReadAs()); SendGuidObject(request); } if (e.Type.Equals(ReceieveGUIDMessage)) { - ModCore.log("Receieve GUID Request"); + //ModCore.log("Receieve GUID Request"); string objStr = e.ReadAs (); CustomObject v=(CustomObject)ModCore.Serializer.DeserializeFromJSONString(objStr); if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) @@ -45,13 +45,13 @@ namespace Revitalize.Framework.Utilities if(e.Type.Equals(RequestGUIDMessage_Tile)) { - ModCore.log("Send GUID Request FOR TILE"); + //odCore.log("Send GUID Request FOR TILE"); Guid request = Guid.Parse(e.ReadAs()); SendGuidObject_Tile(request); } if(e.Type.Equals(ReceieveGUIDMessage_Tile)) { - ModCore.log("Receieve GUID Request FOR TILE"); + //ModCore.log("Receieve GUID Request FOR TILE"); string objStr = e.ReadAs(); CustomObject v =(CustomObject)ModCore.Serializer.DeserializeFromJSONString(objStr); if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false) @@ -81,13 +81,13 @@ namespace Revitalize.Framework.Utilities { if (ModCore.CustomObjects.ContainsKey(request)) { - ModCore.log("Send guid request!"); + //ModCore.log("Send guid request!"); //ModCore.CustomObjects[request].forceUpdate(); ModCore.ModHelper.Multiplayer.SendMessage(ModCore.Serializer.ToJSONString(ModCore.CustomObjects[request]), ReceieveGUIDMessage, new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() }); } else { - ModCore.log("This mod doesn't have the guid object"); + //ModCore.log("This mod doesn't have the guid object"); } } @@ -95,7 +95,7 @@ namespace Revitalize.Framework.Utilities { if (ModCore.CustomObjects.ContainsKey(request)) { - ModCore.log("Send guid tile request!"); + //ModCore.log("Send guid tile request!"); //(ModCore.CustomObjects[request] as MultiTiledComponent).forceUpdate(); //(ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.forceUpdate(); (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject.updateInfo(); @@ -103,7 +103,7 @@ namespace Revitalize.Framework.Utilities } else { - ModCore.log("This mod doesn't have the guid tile"); + //ModCore.log("This mod doesn't have the guid tile"); } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index 70a0d788..72ea284b 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -263,14 +263,14 @@ namespace Revitalize.Framework.Utilities { //ModCore.log("Found a custom object in a chest!"); string jsonString = JsonName; - ModCore.log(JsonName); + //ModCore.log(JsonName); string dataSplit= jsonString.Split(new string[] { "<" }, StringSplitOptions.None)[1]; string backUpGUID = dataSplit.Split('|')[0]; string[] guidArr = jsonString.Split(new string[] { "|" }, StringSplitOptions.None); foreach(string s in guidArr) { - ModCore.log(s); + //ModCore.log(s); } string guidName = guidArr[guidArr.Length - 1]; @@ -285,7 +285,7 @@ namespace Revitalize.Framework.Utilities Guid d = Guid.Parse(backUpGUID); guidName = backUpGUID; } - ModCore.log("THE GUID IS:"+ guidName); + //ModCore.log("THE GUID IS:"+ guidName); //ModCore.log(jsonString); string type = jsonString.Split('|')[2]; diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e053ea9e..e454010f 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -127,7 +127,6 @@ -