Upgraded the serializer to have function pointers to parse and serialize code as well as added in quarries! Woo!
This commit is contained in:
parent
6128c1e1a9
commit
905ef3a8d0
|
@ -21,30 +21,45 @@ using Revitalize.Objects.Machines;
|
|||
|
||||
namespace Revitalize
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// Get Time lapse code working so that machines propperly work though the night since I technically remove them.
|
||||
/// Art. Lots of Art.
|
||||
/// Clean up the freaking code. Geeze it's messy.
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
|
||||
public class Class1 :Mod
|
||||
{
|
||||
public static string key_binding="P";
|
||||
public static string key_binding2 = "L";
|
||||
public static string path;
|
||||
bool hasCleanedUp;
|
||||
|
||||
const int range = 1;
|
||||
|
||||
public override void Entry(IModHelper helper)
|
||||
{
|
||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ShopCall;
|
||||
StardewModdingAPI.Events.GameEvents.UpdateTick += BedCleanUpCheck;
|
||||
StardewModdingAPI.Events.GameEvents.GameLoaded += GameEvents_GameLoaded;
|
||||
|
||||
hasCleanedUp = true;
|
||||
path = Helper.DirectoryPath;
|
||||
Util.acceptedTypes = new Dictionary<string, Util.del>();
|
||||
Util.addAllAcceptedTypes();
|
||||
|
||||
}
|
||||
|
||||
private void GameEvents_GameLoaded(object sender, EventArgs e)
|
||||
{
|
||||
Dictionaries.initializeDictionaries();
|
||||
}
|
||||
|
||||
private void BedCleanUpCheck(object sender, EventArgs e)
|
||||
{
|
||||
const int range = 1;
|
||||
|
||||
|
||||
if (Game1.hasLoadedGame == false) return;
|
||||
if (Game1.player == null) return;
|
||||
//Log.Info(Game1.activeClickableMenu.GetType());
|
||||
if (Game1.player.currentLocation.name == "FarmHouse")
|
||||
{
|
||||
|
@ -71,27 +86,24 @@ namespace Revitalize
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ShopCall(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
||||
{
|
||||
Game1.timeOfDay = 2500;
|
||||
//Game1.timeOfDay = 2500;
|
||||
if (Game1.activeClickableMenu != null) return;
|
||||
if (e.KeyPressed.ToString() == key_binding)
|
||||
{
|
||||
|
||||
List<Item> objShopList = new List<Item>();
|
||||
|
||||
objShopList.Add(new Light(3, Vector2.Zero, LightColors.DeepSkyBlue));
|
||||
objShopList.Add(new Quarry(3,Vector2.Zero,9,"copper"));
|
||||
// objShopList.Add(new Spawner(3, Vector2.Zero, 9));
|
||||
|
||||
|
||||
List<Item> my_shop_list = new List<Item>();
|
||||
string texturePath = "TileSheets\\furniture";
|
||||
var I = new Objects.shopObject(3, Vector2.Zero,objShopList,texturePath);
|
||||
I.name = "Shop Chair";
|
||||
my_shop_list.Add((I));
|
||||
objShopList.Add(new Light(3, Vector2.Zero, LightColors.Aquamarine));
|
||||
|
||||
// my_shop_list.Add((new Decoration(1120, Vector2.Zero)));
|
||||
Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(my_shop_list, 0, null);
|
||||
Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(objShopList, 0, null);
|
||||
|
||||
if (Game1.player == null) return;
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Revitalize;
|
||||
using Revitalize.Objects;
|
||||
using Revitalize.Resources;
|
||||
using Revitalize.Resources.DataNodes;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Objects;
|
||||
|
@ -64,24 +66,17 @@ namespace Revitalize
|
|||
}
|
||||
string s = Convert.ToString((d.GetType()));
|
||||
|
||||
if (s.Contains("Decoration"))
|
||||
if (Dictionaries.acceptedTypes.ContainsKey(s))
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(InvPath,d.Name+".json"),(Decoration)d);
|
||||
SerializerDataNode t;
|
||||
|
||||
bool works= Dictionaries.acceptedTypes.TryGetValue(s, out t);
|
||||
if (works == true)
|
||||
{
|
||||
t.serialize.Invoke(d);
|
||||
removalList.Add(d);
|
||||
}
|
||||
|
||||
if (s.Contains("Light"))
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (Light)d);
|
||||
removalList.Add(d);
|
||||
}
|
||||
|
||||
if (s.Contains("shopObject"))
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (shopObject)d);
|
||||
removalList.Add(d);
|
||||
}
|
||||
|
||||
}
|
||||
foreach(var i in removalList)
|
||||
{
|
||||
|
@ -132,14 +127,14 @@ namespace Revitalize
|
|||
string s = b.ElementAt(0);
|
||||
// Log.AsyncC(s);
|
||||
|
||||
if (Util.acceptedTypes.ContainsKey(s))
|
||||
if (Dictionaries.acceptedTypes.ContainsKey(s))
|
||||
{
|
||||
// Log.AsyncC("FUUUUU");
|
||||
foreach (KeyValuePair<string, Util.del> pair in Util.acceptedTypes)
|
||||
foreach (KeyValuePair<string, SerializerDataNode> pair in Dictionaries.acceptedTypes)
|
||||
{
|
||||
if (pair.Key == s)
|
||||
{
|
||||
var cObj=pair.Value.Invoke(data);
|
||||
var cObj = pair.Value.parse.Invoke(data);
|
||||
Log.AsyncC("NEED TO HANDLE PUTTING OBJECTS BACK INTO A LOCATION!!!!");
|
||||
if (cObj.thisLocation == null)
|
||||
{
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace Revitalize
|
|||
// Game1.player.removeItemFromInventory(heldObject);
|
||||
}
|
||||
//this.minutesUntilReady = 30;
|
||||
Log.AsyncC("placed item!");
|
||||
// Log.AsyncC("placed item!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -399,12 +399,12 @@ namespace Revitalize
|
|||
this.heldObject.tileLocation = this.tileLocation;
|
||||
this.heldObject.boundingBox.X = this.boundingBox.X;
|
||||
this.heldObject.boundingBox.Y = this.boundingBox.Y;
|
||||
Log.AsyncO(getDefaultBoundingBoxForType((dropIn as CoreObject).Decoration_type));
|
||||
// Log.AsyncO(getDefaultBoundingBoxForType((dropIn as CoreObject).Decoration_type));
|
||||
this.heldObject.performDropDownAction(who);
|
||||
if (!probe)
|
||||
{
|
||||
Game1.playSound("woodyStep");
|
||||
Log.AsyncC("HUH?");
|
||||
// Log.AsyncC("HUH?");
|
||||
if (who != null)
|
||||
{
|
||||
who.reduceActiveItemByOne();
|
||||
|
@ -430,7 +430,7 @@ namespace Revitalize
|
|||
Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
Game1.currentLightSources.Add(this.lightSource);
|
||||
Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
// Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ namespace Revitalize
|
|||
this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, c, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
// this.lightSource.lightTexture = Game1.content.Load<Texture2D>("LooseSprites\\Lighting\\BlueLight");
|
||||
Game1.currentLightSources.Add(this.lightSource);
|
||||
Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
// Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -801,8 +801,8 @@ namespace Revitalize
|
|||
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
Log.AsyncC(x);
|
||||
Log.AsyncM(y);
|
||||
// Log.AsyncC(x);
|
||||
// Log.AsyncM(y);
|
||||
|
||||
if (location is FarmHouse)
|
||||
{
|
||||
|
@ -874,9 +874,9 @@ namespace Revitalize
|
|||
}
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
Log.AsyncO(this.boundingBox);
|
||||
Log.AsyncO(x);
|
||||
Log.AsyncY(y);
|
||||
// Log.AsyncO(this.boundingBox);
|
||||
// Log.AsyncO(x);
|
||||
// Log.AsyncY(y);
|
||||
for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++)
|
||||
{
|
||||
base.placementAction(location, x + 1, y, who);
|
||||
|
@ -1235,8 +1235,8 @@ namespace Revitalize
|
|||
|
||||
public virtual bool isInventoryFull()
|
||||
{
|
||||
Log.AsyncC("Count" + inventory.Count);
|
||||
Log.AsyncC("size" + inventoryMaxSize);
|
||||
// Log.AsyncC("Count" + inventory.Count);
|
||||
// Log.AsyncC("size" + inventoryMaxSize);
|
||||
if (inventory.Count >= inventoryMaxSize)
|
||||
{
|
||||
|
||||
|
@ -1320,7 +1320,7 @@ namespace Revitalize
|
|||
if (lightsOn == false)
|
||||
{
|
||||
|
||||
Log.AsyncG("ADD LIGHTS");
|
||||
// Log.AsyncG("ADD LIGHTS");
|
||||
this.Decoration_type = 7;
|
||||
this.type = "Lamp";
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ namespace Revitalize.Objects.Machines
|
|||
// Game1.player.removeItemFromInventory(heldObject);
|
||||
}
|
||||
//this.minutesUntilReady = 30;
|
||||
Log.AsyncC("placed item!");
|
||||
// Log.AsyncC("placed item!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -351,12 +351,12 @@ namespace Revitalize.Objects.Machines
|
|||
this.heldObject.tileLocation = this.tileLocation;
|
||||
this.heldObject.boundingBox.X = this.boundingBox.X;
|
||||
this.heldObject.boundingBox.Y = this.boundingBox.Y;
|
||||
Log.AsyncO(getDefaultBoundingBoxForType((dropIn as Machine).Decoration_type));
|
||||
// Log.AsyncO(getDefaultBoundingBoxForType((dropIn as Machine).Decoration_type));
|
||||
this.heldObject.performDropDownAction(who);
|
||||
if (!probe)
|
||||
{
|
||||
Game1.playSound("woodyStep");
|
||||
Log.AsyncC("HUH?");
|
||||
// Log.AsyncC("HUH?");
|
||||
if (who != null)
|
||||
{
|
||||
who.reduceActiveItemByOne();
|
||||
|
@ -382,7 +382,7 @@ namespace Revitalize.Objects.Machines
|
|||
Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
Game1.currentLightSources.Add(this.lightSource);
|
||||
Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
// Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ namespace Revitalize.Objects.Machines
|
|||
this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, c, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
|
||||
// this.lightSource.lightTexture = Game1.content.Load<Texture2D>("LooseSprites\\Lighting\\BlueLight");
|
||||
Game1.currentLightSources.Add(this.lightSource);
|
||||
Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
// Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -753,8 +753,8 @@ namespace Revitalize.Objects.Machines
|
|||
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
Log.AsyncC(x);
|
||||
Log.AsyncM(y);
|
||||
// Log.AsyncC(x);
|
||||
// Log.AsyncM(y);
|
||||
if (location is FarmHouse)
|
||||
{
|
||||
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
|
||||
|
@ -825,9 +825,9 @@ namespace Revitalize.Objects.Machines
|
|||
}
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
Log.AsyncO(this.boundingBox);
|
||||
Log.AsyncO(x);
|
||||
Log.AsyncY(y);
|
||||
// Log.AsyncO(this.boundingBox);
|
||||
// Log.AsyncO(x);
|
||||
// Log.AsyncY(y);
|
||||
for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++)
|
||||
{
|
||||
base.placementAction(location, x + 1, y, who);
|
||||
|
@ -1186,8 +1186,8 @@ namespace Revitalize.Objects.Machines
|
|||
|
||||
public virtual bool isInventoryFull()
|
||||
{
|
||||
Log.AsyncC("Count" + inventory.Count);
|
||||
Log.AsyncC("size" + inventoryMaxSize);
|
||||
// Log.AsyncC("Count" + inventory.Count);
|
||||
// Log.AsyncC("size" + inventoryMaxSize);
|
||||
if (inventory.Count >= inventoryMaxSize)
|
||||
{
|
||||
|
||||
|
@ -1210,7 +1210,7 @@ namespace Revitalize.Objects.Machines
|
|||
else return false;
|
||||
}
|
||||
|
||||
public virtual void spillInventoryEverywhere()
|
||||
public virtual void showUI()
|
||||
{
|
||||
Game1.activeClickableMenu = new StorageContainer(this.inventory, this.inventoryMaxSize,3);
|
||||
this.itemReadyForHarvest = false;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
using StardewValley;
|
||||
namespace Revitalize.Resources.DataNodes
|
||||
{
|
||||
class QuarryDataNode
|
||||
{
|
||||
public string Name;
|
||||
public StardewValley.Object Output;
|
||||
public int TimeToProcess;
|
||||
|
||||
|
||||
|
||||
public QuarryDataNode(string name, Object output, int timeToProcess)
|
||||
{
|
||||
Name = name;
|
||||
Output = output;
|
||||
TimeToProcess = timeToProcess;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using StardewValley;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Revitalize.Resources.DataNodes
|
||||
{
|
||||
class SerializerDataNode
|
||||
{
|
||||
public Dictionaries.ser serialize;
|
||||
public Dictionaries.par parse;
|
||||
|
||||
public SerializerDataNode(Dictionaries.ser ser, Dictionaries.par par)
|
||||
{
|
||||
serialize = ser;
|
||||
parse = par;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StardewValley;
|
||||
using Revitalize.Resources.DataNodes;
|
||||
|
||||
namespace Revitalize.Resources
|
||||
{
|
||||
|
||||
class Dictionaries
|
||||
{
|
||||
|
||||
public delegate CoreObject par(string data);
|
||||
public delegate void ser(Item item);
|
||||
public static Dictionary<string, SerializerDataNode> acceptedTypes;
|
||||
|
||||
|
||||
|
||||
public static Dictionary<string, QuarryDataNode> quarryList;
|
||||
|
||||
|
||||
public static void initializeDictionaries()
|
||||
{
|
||||
acceptedTypes = new Dictionary<string, SerializerDataNode>();
|
||||
quarryList = new Dictionary<string, QuarryDataNode>();
|
||||
|
||||
fillAllDictionaries();
|
||||
}
|
||||
|
||||
public static void fillAllDictionaries()
|
||||
{
|
||||
addAllAcceptedTypes();
|
||||
fillQuaryList();
|
||||
}
|
||||
|
||||
|
||||
public static void addAllAcceptedTypes()
|
||||
{
|
||||
acceptedTypes.Add("Revitalize.Objects.Decoration", new SerializerDataNode(new ser(Serialize.serializeDecoration) ,new par(Serialize.parseDecoration)));
|
||||
acceptedTypes.Add("Revitalize.Objects.Light", new SerializerDataNode(new ser(Serialize.serializeLight), new par(Serialize.parseLight)));
|
||||
acceptedTypes.Add("Revitalize.Objects.shopObject", new SerializerDataNode(new ser(Serialize.serializeShopObject), new par(Serialize.parseShopObject)));
|
||||
acceptedTypes.Add("Revitalize.Objects.Machines.Quarry", new SerializerDataNode(new ser(Serialize.serializeQuarry), new par(Serialize.parseQuarry)));
|
||||
|
||||
}
|
||||
public static void fillQuaryList()
|
||||
{
|
||||
quarryList.Add("clay", new QuarryDataNode("clay", new StardewValley.Object(330, 1, false), 60));
|
||||
quarryList.Add("stone", new QuarryDataNode("stone", new StardewValley.Object(390, 1, false), 60));
|
||||
quarryList.Add("coal", new QuarryDataNode("coal", new StardewValley.Object(382, 1, false), 240));
|
||||
quarryList.Add("copper", new QuarryDataNode("copper",new StardewValley.Object(378,1,false),120));
|
||||
quarryList.Add("iron", new QuarryDataNode("iron", new StardewValley.Object(380, 1, false), 480));
|
||||
quarryList.Add("gold", new QuarryDataNode("gold", new StardewValley.Object(384, 1, false), 1440));
|
||||
quarryList.Add("irridium", new QuarryDataNode("irridium", new StardewValley.Object(386, 1, false), 4320));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -52,11 +52,15 @@
|
|||
<Compile Include="Objects\Decoration.cs" />
|
||||
<Compile Include="Objects\Light.cs" />
|
||||
<Compile Include="Objects\Machines\Machine.cs" />
|
||||
<Compile Include="Objects\Machines\Quarry.cs" />
|
||||
<Compile Include="Objects\Machines\Spawner.cs" />
|
||||
<Compile Include="Menus\LightCustomizer.cs" />
|
||||
<Compile Include="Objects\shopObject.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resources\DataNodes\SerializerDataNode.cs" />
|
||||
<Compile Include="Resources\Dictionaries.cs" />
|
||||
<Compile Include="Resources\LightColors.cs" />
|
||||
<Compile Include="Resources\DataNodes\QuarryDataNode.cs" />
|
||||
<Compile Include="Serialize.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -3,6 +3,9 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Revitalize.Objects;
|
||||
using Revitalize.Objects.Machines;
|
||||
using Revitalize.Resources;
|
||||
using Revitalize.Resources.DataNodes;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using System;
|
||||
|
@ -70,6 +73,11 @@ namespace Revitalize
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static Item parseItemFromJson(string data)
|
||||
{
|
||||
|
||||
|
@ -78,13 +86,13 @@ namespace Revitalize
|
|||
string[] b = a.Split(',');
|
||||
string s = b.ElementAt(0);
|
||||
|
||||
if (Util.acceptedTypes.ContainsKey(s))
|
||||
if (Dictionaries.acceptedTypes.ContainsKey(s))
|
||||
{
|
||||
foreach (KeyValuePair<string, Util.del> pair in Util.acceptedTypes)
|
||||
foreach (KeyValuePair<string, SerializerDataNode> pair in Dictionaries.acceptedTypes)
|
||||
{
|
||||
if (pair.Key == s)
|
||||
{
|
||||
var cObj = pair.Value.Invoke(data);
|
||||
var cObj = pair.Value.parse.Invoke(data);
|
||||
return cObj;
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +103,6 @@ namespace Revitalize
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Decoration parseDecoration(string data)
|
||||
{
|
||||
|
||||
|
@ -186,7 +192,10 @@ namespace Revitalize
|
|||
|
||||
|
||||
}
|
||||
|
||||
public static void serializeDecoration(Item d)
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(CleanUp.InvPath, d.Name + ".json"), (Decoration)d);
|
||||
}
|
||||
|
||||
public static Light parseLight(string data)
|
||||
{
|
||||
|
@ -276,8 +285,107 @@ namespace Revitalize
|
|||
|
||||
|
||||
|
||||
}
|
||||
public static void serializeLight(Item d)
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(CleanUp.InvPath, d.Name + ".json"), (Light)d);
|
||||
}
|
||||
|
||||
public static Quarry parseQuarry(string data)
|
||||
{
|
||||
|
||||
dynamic obj = JObject.Parse(data);
|
||||
|
||||
|
||||
// Log.AsyncC(obj.thisType);
|
||||
|
||||
|
||||
Quarry d = new Quarry(false);
|
||||
|
||||
d.price = obj.price;
|
||||
d.Decoration_type = obj.Decoration_type;
|
||||
d.rotations = obj.rotations;
|
||||
d.currentRotation = obj.currentRotation;
|
||||
string s1 = Convert.ToString(obj.sourceRect);
|
||||
d.sourceRect = Util.parseRectFromJson(s1);
|
||||
string s2 = Convert.ToString(obj.defaultSourceRect);
|
||||
d.defaultSourceRect = Util.parseRectFromJson(s2);
|
||||
string s3 = Convert.ToString(obj.defaultBoundingBox);
|
||||
d.defaultBoundingBox = Util.parseRectFromJson(s3);
|
||||
d.description = obj.description;
|
||||
d.flipped = obj.flipped;
|
||||
d.flaggedForPickUp = obj.flaggedForPickUp;
|
||||
d.tileLocation = obj.tileLocation;
|
||||
d.parentSheetIndex = obj.parentSheetIndex;
|
||||
d.owner = obj.owner;
|
||||
d.name = obj.name;
|
||||
d.type = obj.type;
|
||||
d.canBeSetDown = obj.canBeSetDown;
|
||||
d.canBeGrabbed = obj.canBeGrabbed;
|
||||
d.isHoedirt = obj.isHoedirt;
|
||||
d.isSpawnedObject = obj.isSpawnedObject;
|
||||
d.questItem = obj.questItem;
|
||||
d.isOn = obj.isOn;
|
||||
d.fragility = obj.fragility;
|
||||
d.edibility = obj.edibility;
|
||||
d.stack = obj.stack;
|
||||
d.quality = obj.quality;
|
||||
d.bigCraftable = obj.bigCraftable;
|
||||
d.setOutdoors = obj.setOutdoors;
|
||||
d.setIndoors = obj.setIndoors;
|
||||
d.readyForHarvest = obj.readyForHarvest;
|
||||
d.showNextIndex = obj.showNextIndex;
|
||||
d.hasBeenPickedUpByFarmer = obj.hasBeenPickedUpByFarmer;
|
||||
d.isRecipe = obj.isRecipe;
|
||||
d.isLamp = obj.isLamp;
|
||||
d.heldObject = obj.heldObject;
|
||||
d.minutesUntilReady = obj.minutesUntilReady;
|
||||
string s4 = Convert.ToString(obj.boundingBox);
|
||||
d.boundingBox = Util.parseRectFromJson(s4);
|
||||
d.scale = obj.scale;
|
||||
d.lightSource = obj.lightSource;
|
||||
d.shakeTimer = obj.shakeTimer;
|
||||
d.internalSound = obj.internalSound;
|
||||
d.specialVariable = obj.specialVariable;
|
||||
d.category = obj.category;
|
||||
d.specialItem = obj.specialItem;
|
||||
d.hasBeenInInventory = obj.hasBeenInInventory;
|
||||
string t = obj.texturePath;
|
||||
|
||||
// Log.AsyncC(t);
|
||||
|
||||
d.TextureSheet = Game1.content.Load<Texture2D>(t);
|
||||
d.texturePath = t;
|
||||
JArray array = obj.inventory;
|
||||
d.inventory = array.ToObject<List<Item>>();
|
||||
d.inventoryMaxSize = obj.inventoryMaxSize;
|
||||
d.itemReadyForHarvest = obj.itemReadyForHarvest;
|
||||
d.lightsOn = obj.lightsOn;
|
||||
d.thisLocation = obj.thisLocation;
|
||||
d.lightColor = obj.lightColor;
|
||||
d.thisType = obj.thisType;
|
||||
d.removable = obj.removable;
|
||||
|
||||
d.ResourceName = obj.ResourceName;
|
||||
d.dataNode = obj.dataNode;
|
||||
try
|
||||
{
|
||||
return d;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.AsyncM(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public static void serializeQuarry(Item d)
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(CleanUp.InvPath, d.Name + ".json"), (Quarry)d);
|
||||
}
|
||||
|
||||
public static shopObject parseShopObject(string data)
|
||||
{
|
||||
|
@ -370,7 +478,10 @@ namespace Revitalize
|
|||
|
||||
|
||||
}
|
||||
|
||||
public static void serializeShopObject(Item d)
|
||||
{
|
||||
Serialize.WriteToJsonFile(Path.Combine(CleanUp.InvPath, d.Name + ".json"), (shopObject)d);
|
||||
}
|
||||
|
||||
public static List<Item> parseInventoryList(JArray array)
|
||||
{
|
||||
|
|
|
@ -12,19 +12,8 @@ namespace Revitalize
|
|||
class Util
|
||||
{
|
||||
|
||||
public delegate CoreObject del(string data);
|
||||
|
||||
public static Dictionary<string, del> acceptedTypes;
|
||||
|
||||
|
||||
public static void addAllAcceptedTypes()
|
||||
{
|
||||
acceptedTypes.Add("Revitalize.Objects.Decoration", new del(Serialize.parseDecoration));
|
||||
acceptedTypes.Add("Revitalize.Objects.Light", new del(Serialize.parseLight));
|
||||
acceptedTypes.Add("Revitalize.Objects.shopObject", new del(Serialize.parseShopObject));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static Microsoft.Xna.Framework.Rectangle parseRectFromJson(string s){
|
||||
|
||||
|
@ -46,7 +35,7 @@ namespace Revitalize
|
|||
{
|
||||
if (Game1.player.isInventoryFull() == false)
|
||||
{
|
||||
Game1.player.addItemToInventory(I);
|
||||
Game1.player.addItemToInventoryBool(I, false);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue