diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 371e8eed..ce4ac74c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -1,8 +1,6 @@ using System; -using System.IO; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Netcode; using PyTK.CustomElementHandler; using Revitalize.Framework.Graphics.Animations; using Revitalize.Framework.Illuminate; @@ -11,11 +9,7 @@ using StardewValley; namespace Revitalize.Framework.Objects { - - /// - /// In Order to make this network compatible, I MUST, MUST, MUST make it use this INetSerializable functionality. - /// - public class BasicItemInformation : CustomObjectData, INetSerializable + public class BasicItemInformation : CustomObjectData { public string name; public string description; @@ -97,36 +91,7 @@ namespace Revitalize.Framework.Objects this.inventory = Inventory ?? new InventoryManager(); this.lightManager = Lights ?? new LightManager(); this.facingDirection = Enums.Direction.Down; - } - - public uint DirtyTick { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - - public bool Dirty => throw new NotImplementedException(); - - public bool NeedsTick { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public bool ChildNeedsTick { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public INetSerializable Parent { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - - public INetRoot Root => throw new NotImplementedException(); - - public void MarkClean() - { - throw new NotImplementedException(); - } - - public void MarkDirty() - { - throw new NotImplementedException(); - } - - public void Read(BinaryReader reader, NetVersion version) - { - throw new NotImplementedException(); - } - - public void ReadFull(BinaryReader reader, NetVersion version) - { - throw new NotImplementedException(); + } public void recreateDataString() @@ -134,19 +99,6 @@ namespace Revitalize.Framework.Objects this.data = $"{this.name}/{this.price}/{this.edibility}/Crafting -9/{this.description}/{this.canBeSetOutdoors}/{this.canBeSetIndoors}/{this.fragility}/{this.isLamp}/{this.name}"; } - public bool Tick() - { - throw new NotImplementedException(); - } - - public void Write(BinaryWriter writer) - { - throw new NotImplementedException(); - } - - public void WriteFull(BinaryWriter writer) - { - throw new NotImplementedException(); - } + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 695bb12a..6b0615c2 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -77,6 +77,9 @@ namespace Revitalize.Framework.Objects this.bigCraftable.Value = false; + this.initNetFields(); + + //if (this.info.ignoreBoundingBox) // this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0); } @@ -369,6 +372,8 @@ namespace Revitalize.Framework.Objects public void InitNetFields() { this.initNetFields(); + this.syncObject = new PySync(this); + this.NetFields.AddField(this.syncObject); } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index ff245bcc..ad9b2404 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -228,11 +228,13 @@ namespace Revitalize.Framework.Objects obj.childrenGuids.Remove(pair.Key); Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); MultiTiledComponent component= (MultiTiledComponent)Revitalize.ModCore.Serializer.Deserialize(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, pair.Value + ".json")); - obj.addComponent(pair.Key, component); + component.InitNetFields(); + + obj.addComponent(pair.Key, component); } - + obj.InitNetFields(); if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) { diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs index e976fdd6..06552ce7 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/NetFieldConverter.cs @@ -18,7 +18,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - + string str = (string)reader.Value; //string str=jsonObject.ToObject(serializer); diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs index 87f5dca2..8af52c9c 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs @@ -30,7 +30,7 @@ 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.NetFieldConverter()); + //this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter()); //this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter()); } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 4964d35d..4e7499d1 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -275,7 +275,10 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - + if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient) + { + throw new Exception("Can't run in multiplayer!"); + } Game1.player.addItemToInventory(customObjects["Omegasis.BigTiledTest"]);