Fixed serilaization issues with not properly reserializing files back into the world.
This commit is contained in:
parent
bfb0194a66
commit
b24420d368
|
@ -5,11 +5,23 @@ using StardewValley;
|
|||
|
||||
namespace Revitalize.Framework.Crafting
|
||||
{
|
||||
/// <summary>
|
||||
/// A crafting recipe.
|
||||
/// </summary>
|
||||
public class Recipe
|
||||
{
|
||||
/// <summary>
|
||||
/// The ingredients necessary to craft this recipe.
|
||||
/// </summary>
|
||||
public Dictionary<Item, int> ingredients;
|
||||
/// <summary>
|
||||
/// The items produced by this recipe.
|
||||
/// </summary>
|
||||
public Dictionary<Item, int> outputs;
|
||||
|
||||
/// <summary>
|
||||
/// The item that is displayed for the crafting recipe.
|
||||
/// </summary>
|
||||
private Item displayItem;
|
||||
|
||||
public Item DisplayItem
|
||||
|
@ -18,9 +30,18 @@ namespace Revitalize.Framework.Crafting
|
|||
set => this.displayItem = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The description for the crafting recipe.
|
||||
/// </summary>
|
||||
public string outputDescription;
|
||||
/// <summary>
|
||||
/// The name for the crafting recipe.
|
||||
/// </summary>
|
||||
public string outputName;
|
||||
|
||||
/// <summary>
|
||||
/// The stats that this recipe costs. Magic, HP, stamina, gold, etc.
|
||||
/// </summary>
|
||||
public StatCost statCost;
|
||||
|
||||
public Recipe() { }
|
||||
|
@ -91,6 +112,10 @@ namespace Revitalize.Framework.Crafting
|
|||
&& self.GetType() == other.GetType();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Consumes all of the ingredients for the recipe.
|
||||
/// </summary>
|
||||
/// <param name="from"></param>
|
||||
public void consume(ref List<Item> from)
|
||||
{
|
||||
if (this.InventoryContainsAllIngredient(from)==false)
|
||||
|
@ -119,6 +144,12 @@ namespace Revitalize.Framework.Crafting
|
|||
from = manager.items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Produces outputs for the crafting recipe.
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
/// <param name="dropToGround"></param>
|
||||
/// <param name="isPlayerInventory"></param>
|
||||
public void produce(ref List<Item> to, bool dropToGround = false, bool isPlayerInventory = false)
|
||||
{
|
||||
var manager = isPlayerInventory
|
||||
|
@ -135,7 +166,15 @@ namespace Revitalize.Framework.Crafting
|
|||
to = manager.items;
|
||||
}
|
||||
|
||||
public void craft(ref List<Item> from, ref List<Item> to, bool dropToGround = false, bool isPlayerInventory = false)
|
||||
|
||||
/// <summary>
|
||||
/// Consumes all ingredients in given inventory and adds in outputs to the other given inventory.
|
||||
/// </summary>
|
||||
/// <param name="from">The inventory to take ingredients from.</param>
|
||||
/// <param name="to">The inventory to put outputs into.</param>
|
||||
/// <param name="dropToGround">Should this item be dropped to the ground when crafted?</param>
|
||||
/// <param name="isPlayerInventory">Checks to see if the invventory is the player's</param>
|
||||
private void craft(ref List<Item> from, ref List<Item> to, bool dropToGround = false, bool isPlayerInventory = false)
|
||||
{
|
||||
InventoryManager manager = new InventoryManager(to);
|
||||
if (manager.ItemCount + this.outputs.Count >= manager.capacity)
|
||||
|
@ -148,6 +187,9 @@ namespace Revitalize.Framework.Crafting
|
|||
this.produce(ref to, dropToGround, isPlayerInventory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Actually crafts the recipe.
|
||||
/// </summary>
|
||||
public void craft()
|
||||
{
|
||||
List<Item> playerItems = Game1.player.Items.ToList();
|
||||
|
|
|
@ -10,14 +10,28 @@ using StardewValley.Menus;
|
|||
|
||||
namespace Revitalize.Framework.Hacks
|
||||
{
|
||||
/// <summary>
|
||||
/// Deals with hijacking menus for custom logic.
|
||||
/// </summary>
|
||||
public class MenuHacks
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks to see if the mod has had it's custom object processed at the end of the day.
|
||||
/// </summary>
|
||||
public static bool EndOfDay_HasProcessedModdedItems;
|
||||
/// <summary>
|
||||
/// Checks to see if the end of day menus are up and running.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool EndOfDay_IsShowingEndOfNightMenus()
|
||||
{
|
||||
return Game1.showingEndOfNightStuff;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the current end of day menu is the shippping menu.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool EndOfDay_IsEndOfDayMenuShippingMenu()
|
||||
{
|
||||
if (EndOfDay_IsShowingEndOfNightMenus())
|
||||
|
@ -36,6 +50,10 @@ namespace Revitalize.Framework.Hacks
|
|||
else return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shipping menu from the end of day menus.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ShippingMenu EndOfDay_GetShippingMenu()
|
||||
{
|
||||
if (EndOfDay_IsEndOfDayMenuShippingMenu())
|
||||
|
@ -49,6 +67,9 @@ namespace Revitalize.Framework.Hacks
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hijacks the shipping menu to process modded items.
|
||||
/// </summary>
|
||||
public static void EndOfDay_HackShipping()
|
||||
{
|
||||
if (EndOfDay_GetShippingMenu() != null)
|
||||
|
@ -101,7 +122,12 @@ namespace Revitalize.Framework.Hacks
|
|||
}
|
||||
}
|
||||
|
||||
public static void EndOfDay_OnMenuChanged(object o, StardewModdingAPI.Events.RenderedEventArgs sender)
|
||||
/// <summary>
|
||||
/// Triggers
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <param name="sender"></param>
|
||||
public static void EndOfDay_RenderCheck(object o, StardewModdingAPI.Events.RenderedEventArgs sender)
|
||||
{
|
||||
if (EndOfDay_IsShowingEndOfNightMenus() && EndOfDay_HasProcessedModdedItems==false)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using StardewValley;
|
||||
using SObject = StardewValley.Object;
|
||||
namespace Revitalize.Framework.Hacks
|
||||
{
|
||||
public class ObjectInteractionHacks
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Returns the object underneath the mouse's position.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static SObject GetItemAtMouseTile()
|
||||
{
|
||||
Vector2 mouseTilePosition = Game1.currentCursorTile;
|
||||
if (Game1.player.currentLocation.isObjectAtTile((int)mouseTilePosition.X, (int)mouseTilePosition.Y))
|
||||
{
|
||||
return Game1.player.currentLocation.getObjectAtTile((int)mouseTilePosition.X, (int)mouseTilePosition.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the given object is a SDV vanilla furnace.
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsObjectFurnace(SObject obj)
|
||||
{
|
||||
if (obj.ParentSheetIndex == 13 && obj.bigCraftable.Value && obj.Category == -9 && obj.Name == "Furnace")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
public static void Input_CheckForObjectInteraction(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e)
|
||||
{
|
||||
if(e.Button== StardewModdingAPI.SButton.MouseRight)
|
||||
{
|
||||
SObject obj= GetItemAtMouseTile();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ namespace Revitalize.Framework.Objects
|
|||
public bool canBeSetIndoors;
|
||||
public bool canBeSetOutdoors;
|
||||
public bool isLamp;
|
||||
public string locationName;
|
||||
|
||||
|
||||
public AnimationManager animationManager;
|
||||
|
|
|
@ -29,7 +29,29 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
|
||||
public BasicItemInformation info;
|
||||
public GameLocation location;
|
||||
private GameLocation _location;
|
||||
[JsonIgnore]
|
||||
public GameLocation location
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._location == null)
|
||||
{
|
||||
this._location = Game1.getLocationFromName(this.info.locationName);
|
||||
return this._location;
|
||||
}
|
||||
return this._location;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._location = value;
|
||||
if (this._location == null) this.info.locationName = "";
|
||||
else
|
||||
{
|
||||
this.info.locationName = this._location.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Guid guid;
|
||||
|
@ -443,7 +465,18 @@ namespace Revitalize.Framework.Objects
|
|||
}
|
||||
|
||||
|
||||
public virtual void replaceAfterLoad()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.info.locationName) == false)
|
||||
{
|
||||
ModCore.log("Replace an object!");
|
||||
this.location.removeObject(this.TileLocation, false);
|
||||
this.placementAction(this.location, (int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize);
|
||||
|
||||
ModCore.log("Do I ingnore BB? " + this.info.ignoreBoundingBox);
|
||||
ModCore.log("This is my BB: " + this.boundingBox.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string getDisplayNameFromStringsFile(string objectID)
|
||||
|
|
|
@ -133,39 +133,40 @@ namespace Revitalize.Framework.Objects.Extras
|
|||
|
||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
//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"]));
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
ArcadeCabinetTile self = Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetTile>(additionalSaveData["GUID"]);
|
||||
if (self == null)
|
||||
if (ModCore.IsNullOrDefault<ArcadeCabinetTile>(self)) return null;
|
||||
try
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
//Get new container
|
||||
ArcadeCabinetOBJ obj = (ArcadeCabinetOBJ)Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetOBJ>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
obj.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return (ICustomObject)self;
|
||||
return self;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -98,39 +98,40 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
|
||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
//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"]));
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
ChairTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(additionalSaveData["GUID"]);
|
||||
if (self == null)
|
||||
if (ModCore.IsNullOrDefault<ChairTileComponent>(self)) return null;
|
||||
try
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
//Get new container
|
||||
ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<ChairMultiTiledObject>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
obj.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return (ICustomObject)self;
|
||||
return self;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -135,36 +135,39 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
//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"]));
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
LampTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID<LampTileComponent>(additionalSaveData["GUID"]);
|
||||
if (self == null)
|
||||
if (ModCore.IsNullOrDefault<LampTileComponent>(self)) return null;
|
||||
try
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
//Get new container
|
||||
LampMultiTiledObject obj = (LampMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<LampMultiTiledObject>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
obj.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return (ICustomObject)self;
|
||||
return self;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -54,39 +54,40 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
|
||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
//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"]));
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
RugTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID<RugTileComponent>(additionalSaveData["GUID"]);
|
||||
if (self == null)
|
||||
if (ModCore.IsNullOrDefault<RugTileComponent>(self)) return null;
|
||||
try
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
//Get new container
|
||||
RugMultiTiledObject obj = (RugMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<RugMultiTiledObject>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
obj.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return (ICustomObject)self;
|
||||
return self;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -117,39 +117,40 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
|
||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
//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"]));
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
StorageFurnitureTile self = Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureTile>(additionalSaveData["GUID"]);
|
||||
if (self == null)
|
||||
if (ModCore.IsNullOrDefault<StorageFurnitureTile>(self)) return null;
|
||||
try
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
//Get new container
|
||||
StorageFurnitureOBJ obj = (StorageFurnitureOBJ)Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureOBJ>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
obj.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return (ICustomObject)self;
|
||||
return self;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -191,38 +191,52 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
//instead of using this.offsetkey.x use get additional save data function and store offset key there
|
||||
|
||||
//ModCore.log("Recreate a table tile component!");
|
||||
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
|
||||
//ModCore.log("Got the offset key!");
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
//ModCore.log("This tile has a parent guid of: " + additionalSaveData["ParentGUID"]);
|
||||
TableTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID<TableTileComponent>(additionalSaveData["GUID"]);
|
||||
if (self == null)
|
||||
|
||||
if (ModCore.IsNullOrDefault<TableTileComponent>(self))
|
||||
{
|
||||
//ModCore.log("SELF IS NULL");
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
//ModCore.log("Load in the parent!");
|
||||
//Get new container
|
||||
TableMultiTiledObject obj = (TableMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<TableMultiTiledObject>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
obj.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModCore.log("Parent already exists!");
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||
}
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return (ICustomObject)self;
|
||||
return self;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
|
|||
/// <param name="SpawnAmountLuckFactor"></param>
|
||||
/// <param name="DropChanceLuckFactor"></param>
|
||||
/// <param name="DropAmountLuckFactor"></param>
|
||||
public OreResourceInformation(Item I, List<IntRange> FloorsToSpawnOn, List<IntRange> FloorsToExclude,Func<int,bool> CanSpawnOnGivenFloor,Func<int,bool> FloorsToExcludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, double ChanceToSpawn = 1f, double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes, ChanceToSpawn, ChanceToDrop, SpawnChanceLuckFactor, SpawnAmountLuckFactor, DropChanceLuckFactor, DropAmountLuckFactor)
|
||||
public OreResourceInformation(StardewValley.Object I, List<IntRange> FloorsToSpawnOn, List<IntRange> FloorsToExclude,Func<int,bool> CanSpawnOnGivenFloor,Func<int,bool> FloorsToExcludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, double ChanceToSpawn = 1f, double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes, ChanceToSpawn, ChanceToDrop, SpawnChanceLuckFactor, SpawnAmountLuckFactor, DropChanceLuckFactor, DropAmountLuckFactor)
|
||||
{
|
||||
this.spawnsOnFarm = false;
|
||||
this.spawnsInQuarry = false;
|
||||
|
@ -172,7 +172,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
|
|||
/// <param name="SpawnAmountLuckFactor"></param>
|
||||
/// <param name="DropChanceLuckFactor"></param>
|
||||
/// <param name="DropAmountLuckFactor"></param>
|
||||
public OreResourceInformation(Item I,bool SpawnsOnFarm, bool SpawnsInQuarry, bool SpawnInRegularMine, bool SpawnInSkullCave,List<IntRange> FloorsToSpawnOn,List<IntRange>FloorsToExclude,Func<int,bool> CanSpawnOnGivenFloor,Func<int,bool> FloorsToExludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, IntRange FarmSpawnAmount,IntRange QuarrySpawnAmount,IntRange SkullCaveSpawnAmount,List<IntRange> FloorsToSpawnOnSkullCave,List<IntRange>FloorsToExludeSkullCave,Func<int,bool> CanSpawnOnGivenFloorSkullCave,Func<int,bool>FloorsToExludeFunSkullCave,double ChanceToSpawn = 1f,double FarmSpawnChance=1f,double QuarrySpawnChance=1f,double SkullCaveSpawnChance=1f,double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes,ChanceToSpawn,ChanceToDrop,SpawnChanceLuckFactor,SpawnAmountLuckFactor,DropChanceLuckFactor,DropAmountLuckFactor)
|
||||
public OreResourceInformation(StardewValley.Object I,bool SpawnsOnFarm, bool SpawnsInQuarry, bool SpawnInRegularMine, bool SpawnInSkullCave,List<IntRange> FloorsToSpawnOn,List<IntRange>FloorsToExclude,Func<int,bool> CanSpawnOnGivenFloor,Func<int,bool> FloorsToExludeFun,int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes, IntRange FarmSpawnAmount,IntRange QuarrySpawnAmount,IntRange SkullCaveSpawnAmount,List<IntRange> FloorsToSpawnOnSkullCave,List<IntRange>FloorsToExludeSkullCave,Func<int,bool> CanSpawnOnGivenFloorSkullCave,Func<int,bool>FloorsToExludeFunSkullCave,double ChanceToSpawn = 1f,double FarmSpawnChance=1f,double QuarrySpawnChance=1f,double SkullCaveSpawnChance=1f,double ChanceToDrop = 1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f, double DropChanceLuckFactor = 0f, double DropAmountLuckFactor = 0f) : base(I, MinDropAmount, MaxDropAmount, MinNumberOfNodes, MaxNumberOfNodes,ChanceToSpawn,ChanceToDrop,SpawnChanceLuckFactor,SpawnAmountLuckFactor,DropChanceLuckFactor,DropAmountLuckFactor)
|
||||
{
|
||||
// Deals with setting where this ore can spawn.
|
||||
this.spawnsOnFarm = SpawnsOnFarm;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
|
|||
/// <summary>
|
||||
/// The item to drop.
|
||||
/// </summary>
|
||||
public Item droppedItem;
|
||||
public StardewValley.Object droppedItem;
|
||||
|
||||
/// <summary>
|
||||
/// The min amount of resources to drop given the getNumberOfDrops function.
|
||||
|
@ -79,7 +79,7 @@ namespace Revitalize.Framework.Objects.InformationFiles
|
|||
/// <param name="SpawnAmountLuckFactor"></param>
|
||||
/// <param name="DropChanceLuckFactor"></param>
|
||||
/// <param name="DropAmountLuckFactor"></param>
|
||||
public ResourceInformaton(Item I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,double ChanceToSpawn=1f,double ChanceToDrop=1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f,double DropChanceLuckFactor=0f, double DropAmountLuckFactor = 0f)
|
||||
public ResourceInformaton(StardewValley.Object I, int MinDropAmount, int MaxDropAmount, int MinNumberOfNodes, int MaxNumberOfNodes,double ChanceToSpawn=1f,double ChanceToDrop=1f, double SpawnChanceLuckFactor = 0f, double SpawnAmountLuckFactor = 0f,double DropChanceLuckFactor=0f, double DropAmountLuckFactor = 0f)
|
||||
{
|
||||
this.droppedItem = I;
|
||||
this.minResourcePerDrop = MinDropAmount;
|
||||
|
|
|
@ -95,6 +95,14 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
this.performDropDownAction(who);
|
||||
location.objects.Add(this.TileLocation, this);
|
||||
|
||||
|
||||
if(this.getBoundingBox(this.TileLocation).Width==0&& this.getBoundingBox(this.TileLocation).Height == 0)
|
||||
{
|
||||
this.boundingBox.Value = new Rectangle(this.boundingBox.X, this.boundingBox.Y, Game1.tileSize, Game1.tileSize);
|
||||
}
|
||||
ModCore.log(this.getBoundingBox(this.TileLocation));
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -181,7 +189,7 @@ namespace Revitalize.Framework.Objects
|
|||
saveData.Add("ParentGUID", this.containerObject.guid.ToString());
|
||||
saveData.Add("GUID", this.guid.ToString());
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(),this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,11 @@ namespace Revitalize.Framework.Objects
|
|||
}
|
||||
|
||||
this.objects.Add(key, obj);
|
||||
this.childrenGuids.Add(key, new Guid());
|
||||
if (this.childrenGuids.ContainsKey(key)==false)
|
||||
{
|
||||
this.childrenGuids.Add(key, obj.guid);
|
||||
}
|
||||
|
||||
|
||||
if (key.X > this.width) this.width = (int)key.X;
|
||||
if (key.Y > this.height) this.height = (int)key.Y;
|
||||
|
@ -92,11 +96,8 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public bool removeComponent(Vector2 key)
|
||||
{
|
||||
|
||||
|
||||
if (!this.objects.ContainsKey(key))
|
||||
return false;
|
||||
|
||||
this.objects.Remove(key);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -241,40 +241,40 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins
|
|||
|
||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||
{
|
||||
//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"]));
|
||||
string GUID = additionalSaveData["GUID"];
|
||||
OreVeinTile self = Revitalize.ModCore.Serializer.DeserializeGUID<OreVeinTile>(additionalSaveData["GUID"]);
|
||||
if (self == null)
|
||||
if (ModCore.IsNullOrDefault<OreVeinTile>(self)) return null;
|
||||
try
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||
{
|
||||
//Get new container
|
||||
OreVeinObj obj = (OreVeinObj)Revitalize.ModCore.Serializer.DeserializeGUID<OreVeinObj>(additionalSaveData["ParentGUID"]);
|
||||
self.containerObject = obj;
|
||||
obj.addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||
self.containerObject.removeComponent(offsetKey);
|
||||
self.containerObject.addComponent(offsetKey, self);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.log(err);
|
||||
}
|
||||
|
||||
return (ICustomObject)self;
|
||||
|
||||
//throw new Exception("Why am I trying to recreate an ore vein?");
|
||||
return self;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PyTK.CustomElementHandler;
|
||||
|
||||
namespace Revitalize.Framework.Utilities.Serialization.Converters
|
||||
{
|
||||
public class CustomObjectDataConverter: JsonConverter
|
||||
{
|
||||
JsonSerializerSettings settings;
|
||||
|
||||
public CustomObjectDataConverter()
|
||||
{
|
||||
this.settings = new JsonSerializerSettings()
|
||||
{
|
||||
Converters = new List<JsonConverter>()
|
||||
{
|
||||
new Framework.Utilities.Serialization.Converters.RectangleConverter(),
|
||||
new Framework.Utilities.Serialization.Converters.Texture2DConverter(),
|
||||
new Vector2Converter(),
|
||||
},
|
||||
Formatting = Formatting.Indented,
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Include
|
||||
};
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
List<PropertyInfo> properties = value.GetType().GetProperties().ToList();
|
||||
List<FieldInfo> fields = value.GetType().GetFields().ToList();
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
for (int i = 0; i < properties.Count; i++)
|
||||
{
|
||||
PropertyInfo p = properties[i];
|
||||
writer.WritePropertyName(p.Name);
|
||||
serializer.Serialize(writer, p.GetValue(value) != null ? ModCore.Serializer.ToJSONString(p.GetValue(value)) : null);
|
||||
}
|
||||
|
||||
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
writer.WritePropertyName(f.Name);
|
||||
serializer.Serialize(writer, f.GetValue(value) != null ? ModCore.Serializer.ToJSONString(f.GetValue(value)) : null);
|
||||
}
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
{
|
||||
|
||||
throw new JsonSerializationException("Cant convert to item!");
|
||||
return null;
|
||||
}
|
||||
|
||||
JObject jo = JObject.Load(reader);
|
||||
|
||||
string id = jo["id"].Value<string>();
|
||||
string texture = jo["texture"].Value<string>();
|
||||
string type = jo["type"].Value<string>();
|
||||
string color = jo["color"].Value<string>();
|
||||
string bigcraftable = jo["bigCraftable"].Value<string>();
|
||||
|
||||
Texture2D tex=ModCore.Serializer.DeserializeFromJSONString<Texture2D>(texture);
|
||||
Type t = Type.GetType(type);
|
||||
Color c = ModCore.Serializer.DeserializeFromJSONString<Color>(color);
|
||||
bool craftable = ModCore.Serializer.DeserializeFromJSONString<bool>(bigcraftable);
|
||||
|
||||
return PyTKHelper.CreateOBJData(id, tex, t, c, craftable);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(CustomObjectData);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
|||
{
|
||||
new Framework.Utilities.Serialization.Converters.RectangleConverter(),
|
||||
new Framework.Utilities.Serialization.Converters.Texture2DConverter(),
|
||||
new Vector2Converter()
|
||||
},
|
||||
Formatting = Formatting.Indented,
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
|
@ -40,30 +39,8 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
|||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("Type");
|
||||
serializer.Serialize(writer, value.GetType().FullName.ToString());
|
||||
|
||||
List<PropertyInfo> properties=value.GetType().GetProperties().ToList();
|
||||
List<FieldInfo> fields=value.GetType().GetFields().ToList();
|
||||
|
||||
writer.WritePropertyName("Item");
|
||||
writer.WriteStartObject();
|
||||
|
||||
for(int i = 0; i < properties.Count; i++) {
|
||||
PropertyInfo p = properties[i];
|
||||
writer.WritePropertyName(p.Name);
|
||||
serializer.Serialize(writer, p.GetValue(value)!=null? p.GetValue(value).ToString():null);
|
||||
}
|
||||
|
||||
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
writer.WritePropertyName(f.Name);
|
||||
serializer.Serialize(writer, f.GetValue(value) != null ? f.GetValue(value).ToString() : null);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
|
||||
//writer.WritePropertyName("Item");
|
||||
|
||||
//serializer.Serialize(writer, convertedString);
|
||||
serializer.Serialize(writer, convertedString);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
@ -101,14 +78,12 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
|||
|
||||
type = asm.GetType(t);
|
||||
|
||||
//Check if the type exists in the SDV assembly. If not then try to load it from revitalize.
|
||||
if (type == null)
|
||||
{
|
||||
asm = typeof(Revitalize.ModCore).Assembly;
|
||||
type = asm.GetType(t);
|
||||
}
|
||||
|
||||
//If the type doesn't exist from revitalize look through ALL loded assemblies and try to load it.
|
||||
if (type == null)
|
||||
{
|
||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
|
@ -121,7 +96,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
|||
|
||||
if (type == null)
|
||||
{
|
||||
throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can't deserialize this thing!: " + t);
|
||||
throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can;t deserialize this thing!: " + t);
|
||||
}
|
||||
|
||||
//Cache the newly found type.
|
||||
|
@ -141,17 +116,13 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
|||
Revitalize.ModCore.log("DESERIALIZE Multi Tile Object!!!");
|
||||
return JsonConvert.DeserializeObject<Revitalize.Framework.Objects.MultiTiledObject>(jo["Item"].ToString(), this.settings);
|
||||
// return jo["Item"].Value<Revitalize.Framework.Objects.MultiTiledObject>();
|
||||
|
||||
}
|
||||
else if (t == typeof(Revitalize.Framework.Objects.MultiTiledComponent).FullName.ToString())
|
||||
{
|
||||
|
||||
Revitalize.ModCore.log("DESERIALIZE Multi Tile Component!!!");
|
||||
return JsonConvert.DeserializeObject<Revitalize.Framework.Objects.MultiTiledComponent>(jo["Item"].ToString(), this.settings);
|
||||
// return jo["Item"].Value<Revitalize.Framework.Objects.MultiTiledObject>();
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
|
|
@ -44,10 +44,11 @@ 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.ItemCoverter());
|
||||
//this.addConverter(new Framework.Utilities.Serialization.Converters.CustomObjectDataConverter());
|
||||
//this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter());
|
||||
//this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter());
|
||||
|
||||
this.gatherAllFilesForCleanup();
|
||||
//this.gatherAllFilesForCleanup();
|
||||
|
||||
this.settings = new JsonSerializerSettings();
|
||||
foreach(JsonConverter converter in this.serializer.Converters)
|
||||
|
@ -91,6 +92,27 @@ namespace Revitalize.Framework.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
private void deleteFilesBeforeSave()
|
||||
{
|
||||
if (!Directory.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"))) Directory.CreateDirectory(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
|
||||
this.filesToDelete.Clear();
|
||||
string[] directories = Directory.GetDirectories(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
|
||||
foreach (string playerData in directories)
|
||||
{
|
||||
string objectPath = Path.Combine(playerData, "SavedObjectInformation");
|
||||
string[] objectFiles = Directory.GetFiles(objectPath);
|
||||
foreach (string file in objectFiles)
|
||||
{
|
||||
string playerName = new DirectoryInfo(objectPath).Parent.Name;
|
||||
if (playerName != this.getUniqueCharacterString()) return;
|
||||
else
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after load to deal with internal file cleanUp
|
||||
/// </summary>
|
||||
|
@ -102,7 +124,7 @@ namespace Revitalize.Framework.Utilities
|
|||
|
||||
public void returnToTitle()
|
||||
{
|
||||
this.gatherAllFilesForCleanup();
|
||||
//this.gatherAllFilesForCleanup();
|
||||
}
|
||||
|
||||
private void removeNullObjects()
|
||||
|
@ -257,15 +279,15 @@ namespace Revitalize.Framework.Utilities
|
|||
public T DeserializeGUID<T>(string fileName)
|
||||
{
|
||||
string path = Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData", Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID, "SavedObjectInformation", fileName + ".json");
|
||||
this.removeFileFromDeletion((Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID),path);
|
||||
//this.removeFileFromDeletion((Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID),path);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
|
||||
//ModCore.log("Deseralizing file:" + path);
|
||||
return this.Deserialize<T>(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
throw new Exception("Can't deserialize file. Default returned. " + path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,6 +352,20 @@ namespace Revitalize.Framework.Utilities
|
|||
this.Serialize(path, obj);
|
||||
}
|
||||
|
||||
public void DayEnding_CleanUpFilesForDeletion(object o, StardewModdingAPI.Events.DayEndingEventArgs sender)
|
||||
{
|
||||
//ModCore.log("Day ending now delete files!");
|
||||
this.deleteFilesBeforeSave();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique character path string.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string getUniqueCharacterString()
|
||||
{
|
||||
return Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// https://stackoverflow.com/questions/2742276/how-do-i-check-if-a-type-is-a-subtype-or-the-type-of-an-object
|
||||
|
|
|
@ -31,10 +31,11 @@ namespace Revitalize
|
|||
// -Chair tops cut off objects
|
||||
// -load content MUST be enabled for the table to be placed?????? WTF
|
||||
// TODO:
|
||||
/*
|
||||
/* Add in crafting menu.
|
||||
* Add in crafting table.
|
||||
* Find way to hack vanilla furnace for more recipes.
|
||||
*
|
||||
*
|
||||
// -Add in object pool class to handle the multitudes of objects I'll be making. (WIP)
|
||||
// -Make this mod able to load content packs for easier future modding
|
||||
//
|
||||
// -Multiple Lights On Object
|
||||
|
@ -49,6 +50,8 @@ namespace Revitalize
|
|||
// -fun interactables
|
||||
// -Arcade machines
|
||||
// -More crafting tables
|
||||
// -Baths (see chairs but swimming)
|
||||
//
|
||||
// -Machines
|
||||
// !=Energy
|
||||
// Generators:
|
||||
|
@ -56,7 +59,7 @@ namespace Revitalize
|
|||
-burnable
|
||||
-watermill
|
||||
-windmill
|
||||
-crank
|
||||
-crank (costs stamina)
|
||||
Storage:
|
||||
-Batery Pack
|
||||
-
|
||||
|
@ -66,6 +69,8 @@ namespace Revitalize
|
|||
// -Stone Quarry
|
||||
// -Mayo Maker
|
||||
// -Cheese Maker
|
||||
-Yogurt Maker
|
||||
-Fruit yogurts (artisan good)
|
||||
// -Auto fisher
|
||||
// -Auto Preserves
|
||||
// -Auto Keg
|
||||
|
@ -237,7 +242,9 @@ namespace Revitalize
|
|||
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.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion;
|
||||
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
|
||||
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
|
||||
}
|
||||
|
@ -335,7 +342,7 @@ namespace Revitalize
|
|||
|
||||
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet);
|
||||
|
||||
ModCore.log("Added in SSC!");
|
||||
//ModCore.log("Added in SSC!");
|
||||
}
|
||||
|
||||
private void createDirectories()
|
||||
|
@ -380,10 +387,19 @@ namespace Revitalize
|
|||
{
|
||||
throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!");
|
||||
}
|
||||
|
||||
foreach(var v in ObjectGroups)
|
||||
{
|
||||
foreach(var obj in v.Value.objects.Values)
|
||||
{
|
||||
(obj as CustomObject).replaceAfterLoad();
|
||||
}
|
||||
}
|
||||
|
||||
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
|
||||
//Game1.player.addItemToInventory(GetObjectFromPool("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(GetObjectFromPool("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));
|
||||
|
@ -398,11 +414,12 @@ namespace Revitalize
|
|||
|
||||
|
||||
Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin",19));
|
||||
Ore tin = ObjectManager.resources.getOre("Tin", 19);
|
||||
//Ore tin = ObjectManager.resources.getOre("Tin", 19);
|
||||
|
||||
ModCore.log("Tin sells for: " + tin.sellToStorePrice());
|
||||
|
||||
ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7));
|
||||
//ModCore.log("Tin sells for: " + tin.sellToStorePrice());
|
||||
|
||||
//ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -426,7 +443,35 @@ namespace Revitalize
|
|||
/// <param name="message"></param>
|
||||
public static void log(object message)
|
||||
{
|
||||
ModMonitor.Log(message.ToString());
|
||||
ModMonitor.Log(message.ToString()+" "+getFileDebugInfo());
|
||||
}
|
||||
|
||||
public static string getFileDebugInfo()
|
||||
{
|
||||
string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(2).GetFileName();
|
||||
int currentLine = new System.Diagnostics.StackTrace(true).GetFrame(2).GetFileLineNumber();
|
||||
return currentFile + " line:" + currentLine;
|
||||
}
|
||||
|
||||
public static bool IsNullOrDefault<T>(T argument)
|
||||
{
|
||||
// deal with normal scenarios
|
||||
if (argument == null) return true;
|
||||
if (object.Equals(argument, default(T))) return true;
|
||||
|
||||
// deal with non-null nullables
|
||||
Type methodType = typeof(T);
|
||||
if (Nullable.GetUnderlyingType(methodType) != null) return false;
|
||||
|
||||
// deal with boxed value types
|
||||
Type argumentType = argument.GetType();
|
||||
if (argumentType.IsValueType && argumentType != methodType)
|
||||
{
|
||||
object obj = Activator.CreateInstance(argument.GetType());
|
||||
return obj.Equals(argument);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<Compile Include="Framework\Factories\Objects\Furniture\TableFactoryInfo.cs" />
|
||||
<Compile Include="Framework\Factories\Objects\Resources\OreFactoryInfo.cs" />
|
||||
<Compile Include="Framework\Hacks\MenuHacks.cs" />
|
||||
<Compile Include="Framework\Hacks\ObjectInteractionHacks.cs" />
|
||||
<Compile Include="Framework\Illuminate\ColorExtensions.cs" />
|
||||
<Compile Include="Framework\Illuminate\FakeLightSource.cs" />
|
||||
<Compile Include="Framework\Illuminate\LightManager.cs" />
|
||||
|
@ -144,6 +145,7 @@
|
|||
<Compile Include="Framework\Utilities\PyTKHelper.cs" />
|
||||
<Compile Include="Framework\Utilities\RotationUtilities.cs" />
|
||||
<Compile Include="Framework\Utilities\Serialization\ContractResolvers\NetFieldContract.cs" />
|
||||
<Compile Include="Framework\Utilities\Serialization\Converters\CustomObjectDataConverter.cs" />
|
||||
<Compile Include="Framework\Utilities\Serialization\Converters\ItemCoverter.cs" />
|
||||
<Compile Include="Framework\Utilities\Serialization\Converters\NetFieldConverter.cs" />
|
||||
<Compile Include="Framework\Utilities\Serialization\Converters\RectangleConverter.cs" />
|
||||
|
|
|
@ -6,6 +6,7 @@ using Microsoft.Xna.Framework;
|
|||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.MenuComponents;
|
||||
using StardustCore.UIUtilities.MenuComponents.ComponentsV1;
|
||||
|
||||
namespace Vocalization.Framework.Menus
|
||||
{
|
||||
|
@ -34,19 +35,19 @@ namespace Vocalization.Framework.Menus
|
|||
|
||||
public void setUpButtons()
|
||||
{
|
||||
Texture2DExtended buttonTexture = new Texture2DExtended(Vocalization.ModHelper, Path.Combine("Content", "Graphics", "SliderButton.png"));
|
||||
Button bar = new Button(new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 200, 40), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("Content", "Graphics", "SliderBar.png")), new Rectangle(0, 0, 100, 10), 2f);
|
||||
Texture2DExtended buttonTexture = new Texture2DExtended(Vocalization.ModHelper,Vocalization.Manifest,Path.Combine("Content", "Graphics", "SliderButton.png"));
|
||||
Button bar = new Button(new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 200, 40), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png")), new Rectangle(0, 0, 100, 10), 2f);
|
||||
//Texture2DExtended barTexture = new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "SliderBar.png"));
|
||||
Rectangle sourceRect = new Rectangle(0, 0, 4, 16);
|
||||
this.sliderButton = new SliderButton("Slider", "Volume", new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 4, 16), buttonTexture, bar, sourceRect, 2f, new SliderInformation(SliderStyle.Horizontal, (int)(Vocalization.config.voiceVolume * 100), 1), new StardustCore.Animations.Animation(sourceRect), Color.White, Color.Black, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, null, true);
|
||||
|
||||
Button english = new Button(LanguageName.English.ToString(), "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f);
|
||||
Button spanish = new Button(LanguageName.Spanish.ToString(), "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f);
|
||||
Button portuguese = new Button(LanguageName.Portuguese.ToString(), "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f);
|
||||
Button russian = new Button(LanguageName.Russian.ToString(), "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f);
|
||||
Button chinese = new Button(LanguageName.Chinese.ToString(), "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f);
|
||||
Button japanese = new Button(LanguageName.Japanese.ToString(), "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f);
|
||||
Button german = new Button(LanguageName.German.ToString(), "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f);
|
||||
Button english = new Button(LanguageName.English.ToString(), "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f);
|
||||
Button spanish = new Button(LanguageName.Spanish.ToString(), "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f);
|
||||
Button portuguese = new Button(LanguageName.Portuguese.ToString(), "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f);
|
||||
Button russian = new Button(LanguageName.Russian.ToString(), "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f);
|
||||
Button chinese = new Button(LanguageName.Chinese.ToString(), "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f);
|
||||
Button japanese = new Button(LanguageName.Japanese.ToString(), "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f);
|
||||
Button german = new Button(LanguageName.German.ToString(), "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Vocalization.Manifest, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f);
|
||||
List<Button> buttons = new List<Button>
|
||||
{
|
||||
english,
|
||||
|
|
|
@ -13,6 +13,7 @@ using StardewValley.Menus;
|
|||
using StardustCore.Menus;
|
||||
using StardustCore.UIUtilities;
|
||||
using StardustCore.UIUtilities.MenuComponents;
|
||||
using StardustCore.UIUtilities.MenuComponents.ComponentsV1;
|
||||
using Vocalization.Framework;
|
||||
using Vocalization.Framework.Menus;
|
||||
|
||||
|
@ -301,7 +302,7 @@ namespace Vocalization
|
|||
new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(speech, ExtraTextureDrawOrder.after)
|
||||
};
|
||||
|
||||
Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null)), false, components);
|
||||
Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper,this.ModManifest ,Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null)), false, components);
|
||||
|
||||
//Change this to take the vocalization menu instead
|
||||
var modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>
|
||||
|
@ -339,7 +340,7 @@ namespace Vocalization
|
|||
components.Add(new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(c, ExtraTextureDrawOrder.after));
|
||||
components.Add(new KeyValuePair<ClickableTextureComponent, ExtraTextureDrawOrder>(speech, ExtraTextureDrawOrder.after));
|
||||
|
||||
Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, components);
|
||||
Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, Vocalization.Manifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, components);
|
||||
|
||||
//Change this to take the vocalization menu instead
|
||||
List<KeyValuePair<Button, IClickableMenuExtended>> modTabs = new List<KeyValuePair<Button, IClickableMenuExtended>>();
|
||||
|
|
Loading…
Reference in New Issue