diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
index 040a31e2..26c354eb 100644
--- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs
@@ -19,6 +19,89 @@ namespace Revitalize.Framework.Objects
/// A custom object template.
public class CustomObject : PySObject
{
+
+ public string text
+ {
+ get
+ {
+ if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
+ return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result.
+ else
+ return ""; //Otherwise return nothing.
+ }
+ set
+ {
+ if (this.netName == null) return;
+ if (this.netName.Value == null) return;
+ {
+ this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name.
+ }
+ }
+ }
+
+
+ public override string Name
+ {
+
+ get
+ {
+ if (this.info != null)
+ {
+ return this.netName.Value.Split('>')[0];
+ //return this.info.name;
+ }
+ if (this.netName == null)
+ {
+ return this.name;
+ }
+ else
+ {
+ return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value.
+ }
+ }
+
+ set
+ {
+ if (this.netName == null)
+ {
+ return;
+ }
+ if (this.netName.Value == null)
+ {
+ return;
+ }
+ if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
+ {
+ this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back.
+ }
+ else
+ {
+ this.netName.Value = value; //Otherwise just set the net name.
+ }
+ }
+ }
+
+ public override string DisplayName
+ {
+ get
+ {
+ if (this.info != null)
+ {
+ return this.info.name;
+ }
+ return this.netName.Value.Split('>')[0];
+ }
+
+ set
+ {
+ if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
+ this.netName.Value = value + ">" + split[1];
+ else
+ this.netName.Value = value;
+ }
+ }
+
+
public string id
{
get
@@ -75,10 +158,6 @@ namespace Revitalize.Framework.Objects
}
}
-
-
- protected Netcode.NetString netItemInfo;
-
/// Empty constructor.
public CustomObject()
{
@@ -124,8 +203,12 @@ namespace Revitalize.Framework.Objects
this.bigCraftable.Value = false;
+ this.syncObject = new PySync(this);
+ this.syncObject.init();
//this.initNetFields();
this.InitNetFields();
+ this.updateInfo();
+ this.Price = info.price;
//if (this.info.ignoreBoundingBox)
// this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0);
}
@@ -145,6 +228,16 @@ namespace Revitalize.Framework.Objects
: base.getBoundingBox(tileLocation);
}
+ public override int sellToStorePrice()
+ {
+ return this.Price;
+ }
+
+ public override int salePrice()
+ {
+ return this.Price * 2;
+ }
+
/// Checks for interaction with the object.
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
{
@@ -170,18 +263,6 @@ 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);
- }
- public override Dictionary getAdditionalSaveData()
- {
- Dictionary serializedInfo = new Dictionary();
- serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
- return serializedInfo;
- }
/// What happens when the player right clicks the object.
public virtual bool rightClicked(Farmer who)
@@ -332,6 +413,7 @@ 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)
{
+ this.updateInfo();
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));
@@ -373,6 +455,7 @@ 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)
{
+ this.updateInfo();
/*
if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64))
return;
@@ -395,6 +478,7 @@ namespace Revitalize.Framework.Objects
//The actual planter box being drawn.
if (this.animationManager == null)
{
+ this.syncObject.MarkDirty();
if (this.animationManager.getExtendedTexture() == null)
ModCore.ModMonitor.Log("Tex Extended is null???");
@@ -427,6 +511,7 @@ 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)
{
+ this.updateInfo();
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)
@@ -440,8 +525,11 @@ 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.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
+ this.updateInfo();
+ 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)
{
@@ -473,35 +561,8 @@ namespace Revitalize.Framework.Objects
public void InitNetFields()
{
- if (Game1.IsMultiplayer == false && (Game1.IsClient == false || Game1.IsClient == false)) return;
- this.initNetFields();
- this.syncObject = new PySync(this);
- this.NetFields.AddField(this.syncObject);
- this.netItemInfo = new Netcode.NetString(this.ItemInfo);
- this.NetFields.AddField(this.netItemInfo);
}
- ///
- /// 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()
@@ -523,5 +584,82 @@ namespace Revitalize.Framework.Objects
//Load in a file that has all object names referenced here or something.
return this.info.name;
}
+
+ public void updateInfo()
+ {
+ if (this.info == null)
+ {
+ this.ItemInfo = this.text;
+ ModCore.log("Updated item info!");
+ return;
+ }
+
+ if (string.IsNullOrEmpty(this.ItemInfo))
+ {
+ this.ItemInfo = this.text;
+ }
+ else
+ {
+ this.text = this.ItemInfo;
+ }
+ }
+
+ //~~~~~~~~~~~~~~~~~~~~~~~~~//
+ // PyTk Functions //
+ //~~~~~~~~~~~~~~~~~~~~~~~~~//
+ #region
+
+ ///
+ /// Rebuilds the data from saves.
+ ///
+ ///
+ ///
+ public override void rebuild(Dictionary additionalSaveData, object replacement)
+ {
+ CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]];
+ BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]);
+
+ }
+
+ ///
+ /// Prepares the data for saves.
+ ///
+ ///
+ public override Dictionary getAdditionalSaveData()
+ {
+ Dictionary serializedInfo = new Dictionary();
+ serializedInfo.Add("id", this.ItemInfo);
+ serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
+ return serializedInfo;
+ }
+
+ ///
+ /// Gets all of the data necessary for syncing.
+ ///
+ ///
+ public override Dictionary getSyncData()
+ {
+ Dictionary syncData = new Dictionary();
+ //syncData.Add("ID", this.ItemInfo);
+ //syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
+ syncData.Add("Greeting:", "Hello from: " + Game1.player.Name);
+ ModCore.log("Send off SYNC DATA!");
+ return syncData;
+ }
+
+ ///
+ /// Syncs all of the info to all players.
+ ///
+ ///
+ public override void sync(Dictionary syncData)
+ {
+ //Revitalize.ModCore.log("SYNC OBJECT DATA!");
+
+ //this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(syncData["BasicItemInfo"]);
+ //this.ItemInfo = syncData["ID"];
+ string greeting = syncData["Greeting"];
+ ModCore.log(greeting);
+ }
+ #endregion
}
}
diff --git a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs
index ed28709a..02646e2b 100644
--- a/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/Items/Resources/Ore.cs
@@ -107,10 +107,6 @@ namespace Revitalize.Framework.Objects.Items.Resources
return component;
}
- public override object getReplacement()
- {
- return base.getReplacement();
- }
public override ICustomObject recreate(Dictionary additionalSaveData, object replacement)
{
diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs
index 7296a47d..a43c5b0a 100644
--- a/GeneralMods/Revitalize/ModCore.cs
+++ b/GeneralMods/Revitalize/ModCore.cs
@@ -260,6 +260,7 @@ namespace Revitalize
Game1.currentMinigame = new Revitalize.Framework.Minigame.SeasideScrambleMinigame.SeasideScramble();
}
*/
+ /*
if (e.Button == SButton.Y)
{
//Game1.activeClickableMenu = new ItemGrabMenu(Game1.player.Items,false,true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems),);
@@ -270,6 +271,7 @@ namespace Revitalize
Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, newItems, 36);
}
+ */
}
private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e)
@@ -382,19 +384,21 @@ namespace Revitalize
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
{
this.loadContent();
-
+
+ /*
if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient)
{
throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!");
}
+ */
Serializer.afterLoad();
ShopHacks.AddOreToClintsShop();
// 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"));
//Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
//Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous));
@@ -408,9 +412,9 @@ namespace Revitalize
//Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne());
- Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19));
+ //Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19));
//Ore tin = ObjectManager.resources.getOre("Tin", 19);
-
+ Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot", 1));
//ModCore.log("Tin sells for: " + tin.sellToStorePrice());