diff --git a/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs
index 5914f950..b4eb9698 100644
--- a/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs
+++ b/GeneralMods/Revitalize/Framework/Hacks/ObjectInteractionHacks.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
-using Revitalize.Framework.Crafting;
+//using Revitalize.Framework.Crafting;
using Revitalize.Framework.Objects;
using Revitalize.Framework.Utilities;
using StardewValley;
diff --git a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs
index 3c632cbc..9af53caa 100644
--- a/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs
+++ b/GeneralMods/Revitalize/Framework/Hacks/ShopHacks.cs
@@ -18,11 +18,11 @@ namespace Revitalize.Framework.Hacks
///
public static void AddOreToClintsShop()
{
- PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),100), "Clint");
- PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), 150), "Clint");
- PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Lead", 1), 200), "Clint");
- PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Silver", 1), 250), "Clint");
- PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Titanium", 1), 300), "Clint");
+ //PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),100), "Clint");
+ //PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), 150), "Clint");
+ //PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Lead", 1), 200), "Clint");
+ //PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Silver", 1), 250), "Clint");
+ //PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Titanium", 1), 300), "Clint");
}
}
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
index 9b46d975..ca0a6df2 100644
--- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
@@ -41,6 +41,8 @@ namespace Revitalize.Framework.Objects
public int shakeTimer;
+ public bool bigCraftable;
+
public BasicItemInformation()
{
this.name = "";
@@ -64,7 +66,7 @@ namespace Revitalize.Framework.Objects
}
- public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights)
+ public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors,bool BigCraftable,Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights)
{
this.name = name;
this.id = id;
@@ -93,6 +95,7 @@ namespace Revitalize.Framework.Objects
this.lightManager = Lights ?? new LightManager();
this.facingDirection = Enums.Direction.Down;
this.shakeTimer = 0;
+ this.bigCraftable = BigCraftable;
}
@@ -111,7 +114,7 @@ namespace Revitalize.Framework.Objects
///
public BasicItemInformation Copy()
{
- return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this.inventory.Copy(), this.lightManager.Copy());
+ return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors,this.bigCraftable ,this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this.inventory.Copy(), this.lightManager.Copy());
}
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
index ce2dcbf4..d5ccc9da 100644
--- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
@@ -10,6 +10,7 @@ using StardewValley;
using StardewValley.Objects;
using Netcode;
using StardewModdingAPI;
+using Revitalize.Framework.Utilities;
namespace Revitalize.Framework.Objects
{
@@ -19,7 +20,7 @@ namespace Revitalize.Framework.Objects
// -Inventories
/// A custom object template.
- public class CustomObject : PySObject
+ public class CustomObject : StardewValley.Object,ISaveElement
{
public string id
{
@@ -85,12 +86,12 @@ namespace Revitalize.Framework.Objects
public CustomObject()
{
this.guid = Guid.NewGuid();
- this.InitNetFields();
+ //this.InitNetFields();
}
/// Construct an instance.
- public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, int Stack = 1)
- : base(PyTKData, Vector2.Zero)
+ public CustomObject(BasicItemInformation info, int Stack = 1)
+ : base()
{
this.info = info;
this.initializeBasics();
@@ -100,8 +101,8 @@ namespace Revitalize.Framework.Objects
}
/// Construct an instance.
- public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, int Stack = 1)
- : base(PyTKData, TileLocation)
+ public CustomObject(BasicItemInformation info, Vector2 TileLocation, int Stack = 1)
+ : base()
{
this.info = info;
this.initializeBasics();
@@ -117,17 +118,21 @@ namespace Revitalize.Framework.Objects
this.Edibility = this.info.edibility;
this.Category = -9; //For crafting.
this.displayName = this.info.name;
- this.setOutdoors.Value = true;
- this.setIndoors.Value = true;
+ this.setOutdoors.Value = this.info.canBeSetOutdoors;
+ this.setIndoors.Value = this.info.canBeSetIndoors;
this.isLamp.Value = false;
this.Fragility = 0;
this.updateDrawPosition(0, 0);
- this.bigCraftable.Value = false;
+ this.bigCraftable.Value = this.info.bigCraftable;
+ this.Price = this.info.price;
+ ModCore.CustomObjects.Add(this.guid, this);
+
+ this.NetFields.AddField(new NetGuid(this.guid));
//this.initNetFields();
- this.InitNetFields();
+ //this.InitNetFields();
//if (this.info.ignoreBoundingBox)
// this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0);
}
@@ -136,7 +141,7 @@ namespace Revitalize.Framework.Objects
public override bool isPassable()
{
- return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this;
+ return this.info.ignoreBoundingBox; //|| Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this;
}
public override Rectangle getBoundingBox(Vector2 tileLocation)
@@ -150,8 +155,6 @@ namespace Revitalize.Framework.Objects
/// Checks for interaction with the object.
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
{
-
-
MouseState mState = Mouse.GetState();
KeyboardState keyboardState = Game1.GetKeyboardState();
@@ -172,18 +175,33 @@ namespace Revitalize.Framework.Objects
return this.clicked(who);
}
+ /*
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]];
BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]);
- return new CustomObject(data, info, (replacement as Chest).TileLocation);
+ return new CustomObject(data, info);
}
+ */
+ /*
public override Dictionary getAdditionalSaveData()
{
Dictionary serializedInfo = new Dictionary();
+ serializedInfo.Add("id", this.ItemInfo);
serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
return serializedInfo;
}
+ */
+ /*
+ public override void rebuild(Dictionary additionalSaveData, object replacement)
+ {
+ string id = additionalSaveData["id"];
+ this.ItemInfo = id;
+ this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]);
+ base.rebuild(additionalSaveData, replacement);
+ ModCore.log("Rebuilt custom object.");
+ }
+ */
/// What happens when the player right clicks the object.
public virtual bool rightClicked(Farmer who)
@@ -328,12 +346,19 @@ namespace Revitalize.Framework.Objects
/// Gets a clone of the game object.
public override Item getOne()
{
- return new CustomObject(this.data, this.info);
+ return new CustomObject(this.info);
}
/// What happens when the object is drawn at a tile location.
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{
+ if (this.info == null)
+ {
+ ModCore.log("Info is null:");
+ ModCore.log("Need request for guid: " + this.guid);
+ MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
+ return;
+ }
if (x <= -1)
{
spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y * Game1.tileSize) / 10000f));
@@ -355,7 +380,6 @@ namespace Revitalize.Framework.Objects
//Log.AsyncC("Animation Manager is working!");
int addedDepth = 0;
if (this.info.ignoreBoundingBox) addedDepth++;
- if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((this.TileLocation.Y + addedDepth) * Game1.tileSize) / 10000f));
try
{
@@ -375,25 +399,14 @@ namespace Revitalize.Framework.Objects
/// Draw the game object at a non-tile spot. Aka like debris.
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f)
{
- /*
- if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64))
- return;
- if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2)
- spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32), (float)(yNonTile + 51 + 4))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, layerDepth - 1E-06f);
- SpriteBatch spriteBatch1 = spriteBatch;
- Texture2D objectSpriteSheet = Game1.objectSpriteSheet;
- Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)), (float)(yNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0))));
- Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(this.ParentSheetIndex));
- Color color = Color.White * alpha;
- double num1 = 0.0;
- Vector2 origin = new Vector2(8f, 8f);
- Vector2 scale = this.scale;
- double num2 = (double)this.scale.Y > 1.0 ? (double)this.getScale().Y : 4.0;
- int num3 = (bool)(this.flipped) ? 1 : 0;
- double num4 = (double)layerDepth;
- spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, this.info.drawColor * alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4);
- */
+ if(this.info == null)
+ {
+ ModCore.log("Info is null:");
+ ModCore.log("Need request for guid: " + this.guid);
+ MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
+ return;
+ }
//The actual planter box being drawn.
if (this.animationManager == null)
{
@@ -409,7 +422,6 @@ namespace Revitalize.Framework.Objects
//Log.AsyncC("Animation Manager is working!");
int addedDepth = 0;
if (this.info.ignoreBoundingBox) addedDepth++;
- if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.Flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, layerDepth));
try
{
@@ -429,6 +441,13 @@ namespace Revitalize.Framework.Objects
/// What happens when the object is drawn in a menu.
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
{
+ if (this.info == null)
+ {
+ ModCore.log("Info is null:");
+ ModCore.log("Need request for guid: " + this.guid);
+ MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
+ return;
+ }
if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1)
Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White);
if (drawStackNumber && this.Quality > 0)
@@ -442,7 +461,37 @@ namespace Revitalize.Framework.Objects
/// What happens when the object is drawn when held by a player.
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
{
+ if (this.info == null)
+ {
+ ModCore.log("Info is null:");
+ ModCore.log("Need request for guid: " + this.guid);
+ MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
+
+ if (ModCore.CustomObjects.ContainsKey(this.guid))
+ {
+ if (ModCore.CustomObjects[this.guid].info != null)
+ {
+ this.info = ModCore.CustomObjects[this.guid].info;
+ }
+ }
+ else
+ {
+ foreach(var v in ModCore.CustomObjects)
+ {
+ if (v.Value == this)
+ {
+ this.info = v.Value.info;
+ }
+ }
+ }
+
+ return;
+ }
+ else
+ {
+ ModCore.log("Drawing custom object: " + this.guid);
+ }
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
if (f.ActiveObject.bigCraftable.Value)
@@ -472,38 +521,36 @@ namespace Revitalize.Framework.Objects
{
//Do nothing because this shouldn't be placeable anywhere.
}
-
- public void InitNetFields()
+ /*
+ public virtual bool InitNetFields()
{
- if (Game1.IsMultiplayer == false && (Game1.IsClient == false || Game1.IsClient == false)) return;
- this.initNetFields();
+ if (Game1.IsMultiplayer == false)
+ {
+ //ModCore.log("Not multiplayer!");
+ return false;
+ }
+ if (MultiplayerUtilities.HasLoadedIn == false)
+ {
+ return false;
+ }
+
+ ModCore.log("Initialize net fields!");
+ //this.initNetFields();
this.syncObject = new PySync(this);
- this.NetFields.AddField(this.syncObject);
- this.netItemInfo = new Netcode.NetString(this.ItemInfo);
- this.NetFields.AddField(this.netItemInfo);
+ ///this.NetFields.AddField(this.syncObject);
+ //this.netItemInfo = new Netcode.NetString(this.ItemInfo);
+ //this.NetFields.AddField(this.netItemInfo);
+ //this.netInfo = new NetBasicItemInformation(this.info);
+ //this.NetFields.AddField(this.netInfo);
+ return true;
}
+ */
- ///
- /// Gets all of the data necessary for syncing.
- ///
- ///
- public override Dictionary getSyncData()
- {
- Dictionary syncData = base.getSyncData();
- syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
- return syncData;
- }
///
/// Syncs all of the info to all players.
///
///
- public override void sync(Dictionary syncData)
- {
- //Revitalize.ModCore.log("SYNC OBJECT DATA!");
- base.sync(syncData);
- this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(syncData["BasicItemInfo"]);
- }
public virtual void replaceAfterLoad()
@@ -516,6 +563,7 @@ namespace Revitalize.Framework.Objects
//ModCore.log("Do I ingnore BB? " + this.info.ignoreBoundingBox);
//ModCore.log("This is my BB: " + this.boundingBox.Value);
+ //this.InitNetFields();
}
}
@@ -526,12 +574,25 @@ namespace Revitalize.Framework.Objects
return this.info.name;
}
-
- public virtual void setNetFieldParent(INetSerializable Parent)
+ public object getReplacement()
{
- this.NetFields.Parent = Parent;
- IReflectedProperty p=ModCore.ModHelper.Reflection.GetProperty(this.NetFields, "Root", true);
- p.SetValue(Parent.Root);
+ return new StardewValley.Object(this.TileLocation, 14, false);
+ }
+
+ public Dictionary getAdditionalSaveData()
+ {
+ Dictionary saveData = new Dictionary();
+ saveData.Add("Greeting", "Hello");
+ saveData.Add("ItemInfo", ModCore.Serializer.ToJSONString(this.info));
+ return saveData;
+ }
+
+ public void rebuild(Dictionary additionalSaveData, object replacement)
+ {
+ this.DisplayName = additionalSaveData["Greeting"];
+ this.info =ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]);
+ this.initializeBasics();
+ ModCore.log("Rebuilt custom object and it's info from save!");
}
}
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs
index 7b8160a3..d279669e 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs
@@ -71,13 +71,12 @@ namespace Revitalize.Framework.Objects.Extras
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -105,13 +104,11 @@ namespace Revitalize.Framework.Objects.Extras
{
this.childrenGuids.Remove(pair.Key);
ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs
index 9ad29549..7c9a9b2a 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs
@@ -86,13 +86,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ ///component.InitNetFields();
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
+ //obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -118,13 +118,13 @@ namespace Revitalize.Framework.Objects.Furniture
{
this.childrenGuids.Remove(pair.Key);
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
+ //this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs
index 694c650f..992bf452 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs
@@ -87,13 +87,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
+ //obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -121,13 +121,13 @@ namespace Revitalize.Framework.Objects.Furniture
{
this.childrenGuids.Remove(pair.Key);
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
+ //this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs
index 6634cc31..88465886 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs
@@ -163,7 +163,7 @@ namespace Revitalize.Framework.Objects.Furniture
y *= -1;
}
*/
-
+ this.updateInfoIfNull();
if (this.info == null)
{
Revitalize.ModCore.log("info is null");
@@ -215,6 +215,7 @@ namespace Revitalize.Framework.Objects.Furniture
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
{
+ this.updateInfoIfNull();
if (objectPosition.X < 0) objectPosition.X *= -1;
if (objectPosition.Y < 0) objectPosition.Y *= -1;
base.drawWhenHeld(spriteBatch, objectPosition, f);
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs
index db17d900..110ea5e0 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs
@@ -71,13 +71,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
+ //obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -105,13 +105,13 @@ namespace Revitalize.Framework.Objects.Furniture
{
this.childrenGuids.Remove(pair.Key);
LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
+ //this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs
index 8b155f11..d8f3c20c 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs
@@ -73,13 +73,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
RugTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
+ //obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -107,13 +107,13 @@ namespace Revitalize.Framework.Objects.Furniture
{
this.childrenGuids.Remove(pair.Key);
RugTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
+ //this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs
index bca689d7..7756eef4 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/StorageFurnitureOBJ.cs
@@ -71,13 +71,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
+ //obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -105,13 +105,13 @@ namespace Revitalize.Framework.Objects.Furniture
{
this.childrenGuids.Remove(pair.Key);
StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
+ //this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs
index 191806d2..a13abfe9 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs
@@ -72,13 +72,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
TableTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
+ //obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -106,13 +106,13 @@ namespace Revitalize.Framework.Objects.Furniture
{
this.childrenGuids.Remove(pair.Key);
TableTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
+ //this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs
index 56200fc6..edd9ed30 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs
@@ -255,9 +255,23 @@ namespace Revitalize.Framework.Objects.Furniture
if (this.info == null)
{
Revitalize.ModCore.log("info is null");
+ this.info = this.netInfo.Value;
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
}
- if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
+ if (this.animationManager == null)
+ {
+ Revitalize.ModCore.log("Animation Manager Null");
+ if (this.info == null)
+ {
+ ModCore.log("And info is still null!");
+ return;
+ }
+ else
+ {
+ this.info.animationManager = this.netInfo.Value.animationManager;
+ return;
+ }
+ }
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
//The actual planter box being drawn.
diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs
deleted file mode 100644
index d3b14494..00000000
--- a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/ObjectGUIDInfo.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Revitalize.Framework.Objects.InformationFiles
-{
- public class ObjectGUIDInfo
- {
- public enum ObjectType
- {
- Solid,
- Display
- }
-
- public ObjectGUIDInfo()
- {
-
- }
-
- }
-}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/CustomToolExample.cs b/GeneralMods/Revitalize/Framework/Objects/Items/CustomToolExample.cs
new file mode 100644
index 00000000..53b60b8f
--- /dev/null
+++ b/GeneralMods/Revitalize/Framework/Objects/Items/CustomToolExample.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using PyTK.CustomElementHandler;
+using StardewValley;
+using StardewValley.Objects;
+
+namespace Revitalize.Framework.Objects.Items
+{
+ internal class MyTool : Tool, ISaveElement
+ {
+ public string something;
+ public object getReplacement()
+ {
+ return new Chest(true);
+ }
+
+ public Dictionary getAdditionalSaveData()
+ {
+ Dictionary saveData = new Dictionary();
+ saveData.Add("something", "myValue");
+ return saveData;
+ }
+
+ public void rebuild(Dictionary additionalSaveData, object replacement)
+ {
+ this.something = additionalSaveData["something"];
+ ModCore.log("What is my something: " + this.something);
+ }
+
+ protected override string loadDisplayName()
+ {
+ return "Pytk tool";
+ }
+
+ protected override string loadDescription()
+ {
+ return "My description";
+ }
+
+ public override Item getOne()
+ {
+ return new MyTool();
+ }
+ }
+}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs
index ed28709a..2263e1a9 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs
@@ -177,16 +177,19 @@ namespace Revitalize.Framework.Objects.Items.Resources
/// What happens when the object is drawn at a tile location.
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{
+ this.updateInfoIfNull();
if (this.info.ignoreBoundingBox == true)
{
x *= -1;
y *= -1;
}
+
if (this.info == null)
{
Revitalize.ModCore.log("info is null");
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
+ return;
}
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
@@ -223,6 +226,7 @@ namespace Revitalize.Framework.Objects.Items.Resources
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
{
+ this.updateInfoIfNull();
if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1)
Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White);
if (drawStackNumber && this.Quality > 0)
diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
index d221ec11..0dead662 100644
--- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs
@@ -7,7 +7,9 @@ using Microsoft.Xna.Framework.Graphics;
using Netcode;
using Newtonsoft.Json;
using PyTK.CustomElementHandler;
+using Revitalize.Framework.Networking.Fields;
using StardewValley;
+using StardewValley.Network;
using StardewValley.Objects;
namespace Revitalize.Framework.Objects
@@ -292,13 +294,11 @@ namespace Revitalize.Framework.Objects
{
obj.childrenGuids.Remove(pair.Key);
MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
obj.removeComponent(pair.Key);
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -329,13 +329,11 @@ namespace Revitalize.Framework.Objects
{
this.childrenGuids.Remove(pair.Key);
MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
@@ -373,5 +371,6 @@ namespace Revitalize.Framework.Objects
return 1;
}
+
}
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs
index 69cee6a6..48b10992 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Resources/OreVeins/OreVeinObj.cs
@@ -83,13 +83,13 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
obj.addComponent(pair.Key, component);
}
- obj.InitNetFields();
+ //obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@@ -117,13 +117,13 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins
{
this.childrenGuids.Remove(pair.Key);
OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString());
- component.InitNetFields();
+ //component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
- this.InitNetFields();
+ //this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{
diff --git a/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs
index 275e6355..bc5423c7 100644
--- a/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs
+++ b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs
@@ -4,18 +4,18 @@ namespace Revitalize.Framework.Player
{
public class PlayerInfo
{
- public SittingInfo sittingInfo;
+ //public SittingInfo sittingInfo;
public MagicManager magicManager;
public PlayerInfo()
{
- this.sittingInfo = new SittingInfo();
+ //this.sittingInfo = new SittingInfo();
this.magicManager = new MagicManager();
}
public void update()
{
- this.sittingInfo.update();
+ //this.sittingInfo.update();
}
}
}
diff --git a/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs
index 6d485cc5..2cf0564d 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/LocationUtilities.cs
@@ -93,7 +93,7 @@ namespace Revitalize.Framework.Utilities
//ModCore.log("Dimensions of map is: " + dimensions);
return dimensions;
}
-
+ /*
///
/// Gets all open positions for this location for this object.
///
@@ -117,7 +117,7 @@ namespace Revitalize.Framework.Utilities
}
return openTiles;
}
-
+ */
///
/// Checks to see if the farm for the game is the hilltop farm.
///
diff --git a/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs
new file mode 100644
index 00000000..148d1d56
--- /dev/null
+++ b/GeneralMods/Revitalize/Framework/Utilities/MultiplayerUtilities.cs
@@ -0,0 +1,212 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Xna.Framework;
+using Revitalize.Framework.Objects;
+using StardewValley;
+
+namespace Revitalize.Framework.Utilities
+{
+ public class MultiplayerUtilities
+ {
+ public static Dictionary>> ItemsToRestore = new Dictionary>>();
+ public static Dictionary> PlayerItemsToRestore = new Dictionary>();
+
+ public static int onlineFarmers;
+ public static bool needToRestore;
+ public static bool HasLoadedIn;
+
+ public static bool ShouldRestoreObjects
+ {
+ get
+ {
+ return HasLoadedIn && Game1.player.isMoving() && needToRestore == true;
+ }
+ }
+
+ public static void OnPlayerConnect(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e)
+ {
+ if (Game1.IsServer)
+ {
+ needToRestore = true;
+ foreach (Farmer f in Game1.getAllFarmers())
+ {
+ if (PlayerItemsToRestore.ContainsKey(f.UniqueMultiplayerID))
+ {
+ //Do nothing.
+ }
+ else
+ {
+ PlayerItemsToRestore.Add(f.UniqueMultiplayerID, new List- ());
+ }
+
+ foreach (Item I in f.Items)
+ {
+ if (I == null) continue;
+
+ if (I is CustomObject)
+ {
+ //(I as CustomObject).InitNetFields();
+ PlayerItemsToRestore[f.UniqueMultiplayerID].Add(I);
+ }
+ }
+ foreach (Item I in PlayerItemsToRestore[f.UniqueMultiplayerID])
+ {
+ f.removeItemFromInventory(I);
+ }
+ }
+ ModCore.log("Clear items because someone showed up.");
+ }
+
+ }
+
+ public static void OnPlayerDisconnect(object sender, StardewModdingAPI.Events.PeerDisconnectedEventArgs e)
+ {
+ if (Game1.IsServer)
+ {
+ foreach (Farmer f in Game1.getAllFarmers())
+ {
+ if (PlayerItemsToRestore.ContainsKey(f.UniqueMultiplayerID))
+ {
+ //Do nothing.
+ }
+ else
+ {
+ PlayerItemsToRestore.Add(f.UniqueMultiplayerID, new List
- ());
+ }
+
+ foreach (Item I in f.Items)
+ {
+ if (I == null) continue;
+ if (I is CustomObject)
+ {
+ //(I as CustomObject).InitNetFields();
+ PlayerItemsToRestore[f.UniqueMultiplayerID].Add(I);
+ /*
+ if (I is MultiTiledObject)
+ {
+ foreach (CustomObject c in (I as MultiTiledObject).objects.Values)
+ {
+ //c.InitNetFields();
+ }
+ }
+ */
+ }
+ }
+ foreach (Item I in PlayerItemsToRestore[f.UniqueMultiplayerID])
+ {
+ f.removeItemFromInventory(I);
+ }
+ }
+ ModCore.log("Clear items because someone disconnected.");
+ }
+ }
+
+ public static void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
+ {
+ if (ShouldRestoreObjects)
+ {
+ ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.RestoreModObjectsAfterConnect", "Revitalize.RestoreModObjectsAfterConnect", new string[] { ModCore.Manifest.UniqueID });
+ needToRestore = false;
+ }
+ }
+
+ public static void ModMessageReceived(object sender, StardewModdingAPI.Events.ModMessageReceivedEventArgs e)
+ {
+ if (e.Type == "Revitalize.RestoreModObjectsAfterConnect")
+ {
+ RestoreModObjects();
+ needToRestore = false;
+ }
+ if(e.Type == "Revitalize.RequestCustomObjects")
+ {
+ SendCustomObjects();
+ }
+ if(e.Type== "Revitalize.SendCustomObjects")
+ {
+ Dictionary additionalObjects =ModCore.Serializer.Deserialize>(e.ReadAs());
+ foreach(KeyValuePair pair in additionalObjects)
+ {
+ if (ModCore.CustomObjects.ContainsKey(pair.Key))
+ {
+ ModCore.CustomObjects[pair.Key] = pair.Value;
+ }
+ else
+ {
+ ModCore.CustomObjects.Add(pair.Key, pair.Value);
+ }
+ }
+ }
+
+ if(e.Type== "Revitalize.RequestCustomObjectGUID")
+ {
+ Guid requested = Guid.Parse(e.ReadAs());
+ //if specific guid exists send that.
+ if (ModCore.CustomObjects.ContainsKey(requested))
+ {
+ if (ModCore.CustomObjects[requested].info != null)
+ {
+ KeyValuePair pair = new KeyValuePair(requested, ModCore.CustomObjects[requested]);
+ SendCustomObject(pair);
+ }
+ }
+ else
+ {
+ //If it doesn't exist send the whole dictionary.
+ SendCustomObjects();
+ }
+ }
+ if(e.Type== "Revitalize.SendCustomObjectGUID")
+ {
+ KeyValuePair requested = ModCore.Serializer.DeserializeFromJSONString>(e.ReadAs());
+ if (ModCore.CustomObjects.ContainsKey(requested.Key))
+ {
+ ModCore.CustomObjects[requested.Key] = requested.Value;
+ }
+ else
+ {
+ ModCore.CustomObjects.Add(requested.Key, requested.Value);
+ }
+ }
+ }
+
+ public static void RestoreModObjects()
+ {
+ foreach (KeyValuePair> items in PlayerItemsToRestore)
+ {
+ Farmer f = Game1.getFarmer(items.Key);
+ foreach (Item I in items.Value)
+ {
+ f.addItemToInventoryBool(I, false);
+ }
+ items.Value.Clear();
+ }
+ ModCore.log("Restore mod objects!");
+ needToRestore = false;
+ }
+
+ public static void SendCustomObjects()
+ {
+ ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.SendCustomObjects", ModCore.Serializer.ToJSONString(ModCore.CustomObjects), new string[] { ModCore.Manifest.UniqueID });
+ }
+
+ public static void SendRequestForCustomObjects()
+ {
+ ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.RequestCustomObjects", "Revitalize.RequestCustomObjects", new string[] { ModCore.Manifest.UniqueID });
+ }
+
+ public static void SendRequestForSpecificGUID(Guid guid)
+ {
+ ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.RequestCustomObjectGUID", guid.ToString(), new string[] { ModCore.Manifest.UniqueID });
+ }
+
+ public static void SendCustomObject(KeyValuePair Pair)
+ {
+ string s = ModCore.Serializer.ToJSONString(Pair);
+ ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.SendCustomObjectGUID", s , new string[] { ModCore.Manifest.UniqueID });
+ }
+
+ }
+}
diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
index f59af916..72896494 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
using Netcode;
using Newtonsoft.Json;
using Revitalize.Framework.Objects;
-using Revitalize.Framework.Objects.Furniture;
+//using Revitalize.Framework.Objects.Furniture;
using Revitalize.Framework.Utilities.Serialization.ContractResolvers;
using Revitalize.Framework.Utilities.Serialization.Converters;
using StardewValley;
@@ -135,9 +135,10 @@ namespace Revitalize.Framework.Utilities
{
this.deleteAllUnusedFiles();
//this.removeNullObjects();
- this.restoreModObjects();
+ //this.restoreModObjects();
}
+ /*
///
/// Restore mod objects to inventories and world after load.
///
@@ -166,10 +167,6 @@ namespace Revitalize.Framework.Utilities
if (o is Chest && o.Name != "Chest")
{
Item I = this.GetItemFromChestName(o.Name);
- if (I.NetFields != null)
- {
- (I as CustomObject).setNetFieldParent(o.NetFields);
- }
ModCore.log("Found a custom item in a chest!");
toAdd.Add(I);
toRemove.Add(o);
@@ -195,10 +192,6 @@ namespace Revitalize.Framework.Utilities
if (o is Chest && o.Name != "Chest")
{
Item I = this.GetItemFromChestName(o.Name);
- if (I.NetFields != null)
- {
- (I as CustomObject).setNetFieldParent(o.NetFields);
- }
toAdd.Add(I);
toRemove.Add(o);
}
@@ -217,10 +210,6 @@ namespace Revitalize.Framework.Utilities
{
ModCore.log("Found a custom object as a held object!");
Item I = this.GetItemFromChestName(c.heldObject.Value.Name);
- if (I.NetFields != null)
- {
- (I as CustomObject).setNetFieldParent(c.NetFields);
- }
c.heldObject.Value = (StardewValley.Object)I;
}
}
@@ -233,10 +222,6 @@ namespace Revitalize.Framework.Utilities
{
ModCore.log("Found a custom object as a held object!");
Item I = this.GetItemFromChestName(c.heldObject.Value.Name);
- if (I.NetFields != null)
- {
- (I as CustomObject).setNetFieldParent(c.NetFields);
- }
c.heldObject.Value = (StardewValley.Object)I;
}
}
@@ -253,10 +238,6 @@ namespace Revitalize.Framework.Utilities
if (I is Chest && I.Name != "Chest")
{
Item ret = this.GetItemFromChestName(I.Name);
- if (I.NetFields != null)
- {
- (ret as CustomObject).setNetFieldParent(I.NetFields);
- }
toAdd2.Add(ret);
toRemove2.Add(I);
}
@@ -272,7 +253,7 @@ namespace Revitalize.Framework.Utilities
Game1.player.addItemToInventory(I);
}
}
-
+ */
///
/// Gets an Item recreated from PYTK's chest replacement objects.
@@ -288,10 +269,7 @@ namespace Revitalize.Framework.Utilities
string type = jsonString.Split('|')[2];
Item I = (Item)ModCore.Serializer.DeserializeGUID(guidName, Type.GetType(type));
- if (I is MultiTiledObject)
- {
- (I as MultiTiledObject).recreate();
- }
+ //(I as CustomObject).InitNetFields();
return I;
}
diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs
index d1299323..a478d0c9 100644
--- a/GeneralMods/Revitalize/ModCore.cs
+++ b/GeneralMods/Revitalize/ModCore.cs
@@ -5,12 +5,12 @@ using Microsoft.Xna.Framework;
using PyTK.Extensions;
using PyTK.Types;
using Revitalize.Framework;
-using Revitalize.Framework.Crafting;
+//using Revitalize.Framework.Crafting;
using Revitalize.Framework.Environment;
-using Revitalize.Framework.Factories.Objects;
+//using Revitalize.Framework.Factories.Objects;
using Revitalize.Framework.Illuminate;
using Revitalize.Framework.Objects;
-using Revitalize.Framework.Objects.Furniture;
+//using Revitalize.Framework.Objects.Furniture;
using Revitalize.Framework.Player;
using Revitalize.Framework.Utilities;
using StardewModdingAPI;
@@ -19,11 +19,12 @@ using StardewValley.Objects;
using StardustCore.UIUtilities;
using StardustCore.Animations;
using StardewValley.Menus;
-using Revitalize.Framework.Objects.Extras;
+//using Revitalize.Framework.Objects.Extras;
using Revitalize.Framework.Minigame.SeasideScrambleMinigame;
-using Revitalize.Framework.Objects.Items.Resources;
+//using Revitalize.Framework.Objects.Items.Resources;
using Revitalize.Framework.Hacks;
using Netcode;
+//using Revitalize.Framework.Objects.Items;
namespace Revitalize
{
@@ -183,20 +184,23 @@ namespace Revitalize
///
/// Keeps track of custom objects.
///
- public static ObjectManager ObjectManager;
+ //public static ObjectManager ObjectManager;
///
/// Keeps track of all of the extra object groups.
///
- public static Dictionary ObjectGroups;
+ //public static Dictionary ObjectGroups;
public static PlayerInfo playerInfo;
public static Serializer Serializer;
- public static Dictionary ObjectsToDraw;
- public static VanillaRecipeBook VanillaRecipeBook;
+ //public static Dictionary ObjectsToDraw;
+ //public static VanillaRecipeBook VanillaRecipeBook;
+ public static Dictionary CustomObjects;
+
+
public override void Entry(IModHelper helper)
{
ModHelper = helper;
@@ -205,6 +209,7 @@ namespace Revitalize
this.createDirectories();
this.initailizeComponents();
+ CustomObjects = new Dictionary();
Serializer = new Serializer();
playerInfo = new PlayerInfo();
@@ -212,10 +217,10 @@ namespace Revitalize
this.loadInTextures();
//Loads in objects to be use by the mod.
- ObjectGroups = new Dictionary();
- ObjectManager = new ObjectManager(Manifest);
- ObjectManager.loadInItems();
- ObjectsToDraw = new Dictionary();
+ //ObjectGroups = new Dictionary();
+ //ObjectManager = new ObjectManager(Manifest);
+ //ObjectManager.loadInItems();
+ //ObjectsToDraw = new Dictionary();
//Adds in event handling for the mod.
ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded;
@@ -223,18 +228,24 @@ namespace Revitalize
ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle;
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.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.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
+ //ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
+ //ModHelper.Events.Multiplayer.PeerContextReceived += MultiplayerUtilities.OnPlayerConnect;
+ //ModHelper.Events.Multiplayer.PeerDisconnected += MultiplayerUtilities.OnPlayerDisconnect;
+ //ModHelper.Events.GameLoop.UpdateTicked += MultiplayerUtilities.GameLoop_OneSecondUpdateTicked;
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
+ //ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.ModMessageReceived;
+ //MultiplayerUtilities.onlineFarmers = 1;
//Adds in recipes to the mod.
- VanillaRecipeBook = new VanillaRecipeBook();
+ //VanillaRecipeBook = new VanillaRecipeBook();
}
+
///
/// Loads in textures to be used by the mod.
///
@@ -273,17 +284,17 @@ namespace Revitalize
private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e)
{
Serializer.returnToTitle();
- ObjectManager = new ObjectManager(Manifest);
+ //ObjectManager = new ObjectManager(Manifest);
}
///
/// Must be enabled for the tabled to be placed????
///
private void loadContent()
{
-
- MultiTiledComponent obj = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest", "Omegasis.TEST1", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, false, null, null));
- MultiTiledComponent obj2 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest2", "Omegasis.TEST2", "Some fun!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, false, null, null));
- MultiTiledComponent obj3 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest3", "Omegasis.TEST3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 100, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null));
+ /*
+ //MultiTiledComponent obj = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest", "Omegasis.TEST1", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, false, null, null));
+ //MultiTiledComponent obj2 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest2", "Omegasis.TEST2", "Some fun!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, false, null, null));
+ //MultiTiledComponent obj3 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest3", "Omegasis.TEST3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 100, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null));
obj3.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj3);
@@ -344,6 +355,7 @@ namespace Revitalize
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet);
//ModCore.log("Added in SSC!");
+ */
}
private void createDirectories()
@@ -379,6 +391,7 @@ namespace Revitalize
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
{
+ MultiplayerUtilities.HasLoadedIn = true;
this.loadContent();
/*
if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient)
@@ -388,12 +401,16 @@ namespace Revitalize
*/
Serializer.afterLoad();
ShopHacks.AddOreToClintsShop();
+
+ MultiplayerUtilities.needToRestore = true;
+
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
- Game1.player.addItemToInventory(ObjectManager.getChair("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(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable"));
+ //Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable"));
+ MultiplayerUtilities.onlineFarmers = Game1.getOnlineFarmers().Count;
//Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
//Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous));
@@ -406,14 +423,16 @@ namespace Revitalize
*/
//Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne());
-
- Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19));
+ //Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot"));
+ //Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19));
//Ore tin = ObjectManager.resources.getOre("Tin", 19);
-
+ //Game1.player.addItemToInventory(new MyTool());
//ModCore.log("Tin sells for: " + tin.sellToStorePrice());
//ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7));
+ CustomObject tinIngot = new CustomObject(new BasicItemInformation("Tin Ingot", "Omegasis.Revitalize.Items.Resources.Ore.TinIngot", "A tin ingot that can be used for crafting purposes.", "Metal", Color.Silver, -300, 0, false, 75, false, false,false,TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinIngot"), new AnimationManager(), Color.White, true, null, null), 1);
+ Game1.player.addItemToInventory(tinIngot);
}
/*
diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj
index 42b1fbde..86e7b8cb 100644
--- a/GeneralMods/Revitalize/Revitalize.csproj
+++ b/GeneralMods/Revitalize/Revitalize.csproj
@@ -52,22 +52,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -109,43 +97,15 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -375,7 +335,7 @@
-
+
\ No newline at end of file
diff --git a/GeneralMods/Revitalize/manifest.json b/GeneralMods/Revitalize/manifest.json
index 5c46a2a6..bdacfdcc 100644
--- a/GeneralMods/Revitalize/manifest.json
+++ b/GeneralMods/Revitalize/manifest.json
@@ -8,6 +8,11 @@
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [],
"Dependencies": [
- { "UniqueID": "Omegasis.StardustCore" }
+ {
+ "UniqueID": "Omegasis.StardustCore"
+ },
+ {
+ "UniqueID": "Platonymous.Toolkit"
+ }
]
}