It seems like project Revitalize will fail unforunately.

This commit is contained in:
Joshua Navarro 2019-01-10 11:09:51 -08:00
parent 49f06533b3
commit 20c7ba8ad5
9 changed files with 123 additions and 33 deletions

View File

@ -357,6 +357,12 @@ namespace Revitalize.Framework.Objects
//base.drawWhenHeld(spriteBatch, objectPosition, f);
}
public void InitNetFields()
{
this.initNetFields();
}
public string getDisplayNameFromStringsFile(string objectID)
{
//Load in a file that has all object names referenced here or something.

View File

@ -56,13 +56,26 @@ namespace Revitalize.Framework.Objects.Furniture
public override Item getOne()
{
return new ChairMultiTiledObject(this.info, this.TileLocation, this.objects);
Dictionary<Vector2, MultiTiledComponent> objs = new Dictionary<Vector2, MultiTiledComponent>();
foreach (var pair in this.objects)
{
objs.Add(pair.Key, (MultiTiledComponent)pair.Value);
}
return new ChairMultiTiledObject(this.info, this.TileLocation, objs);
}
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
{
BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]];
return new ChairMultiTiledObject(data, (replacement as Chest).TileLocation, this.objects);
Dictionary<Vector2, MultiTiledComponent> objs = new Dictionary<Vector2, MultiTiledComponent>();
foreach (var pair in this.objects)
{
objs.Add(pair.Key, (MultiTiledComponent)pair.Value);
}
return new ChairMultiTiledObject(data, (replacement as Chest).TileLocation, objs);
}
public override bool canBePlacedHere(GameLocation l, Vector2 tile)

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@ -104,6 +105,10 @@ namespace Revitalize.Framework.Objects
return component;
}
public override object getReplacement()
{
return base.getReplacement();
}
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
{
@ -122,8 +127,9 @@ namespace Revitalize.Framework.Objects
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
//Get new container
CustomObject obj = (CustomObject)(Revitalize.ModCore.customObjects[additionalSaveData["ParentID"]].getOne());
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.Deserialize<MultiTiledObject>(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, additionalSaveData["GUID"] + ".json"));
self = (MultiTiledComponent)(obj as MultiTiledObject).objects[offsetKey];
self.containerObject = obj;
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], (MultiTiledObject)obj);
}
else
@ -132,19 +138,6 @@ namespace Revitalize.Framework.Objects
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]];
}
self.TileLocation = (replacement as Chest).TileLocation;
Enums.Direction facingDirection = (Enums.Direction)Convert.ToInt32(additionalSaveData["Rotation"]);
while (self.info.facingDirection != facingDirection)
{
self.rotate();
}
if (!string.IsNullOrEmpty(additionalSaveData["GameLocationName"]))
{
self.location = Game1.getLocationFromName(additionalSaveData["GameLocationName"]);
}
return (ICustomObject)self;
BasicItemInformation data = Revitalize.ModCore.customObjects[additionalSaveData["id"]].info;
return new MultiTiledComponent(data, (replacement as Chest).TileLocation)
@ -248,5 +241,10 @@ namespace Revitalize.Framework.Objects
}
}
public static implicit operator MultiTiledComponent(Chest chest)
{
return new MultiTiledComponent(new BasicItemInformation(),chest.TileLocation);
}
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Newtonsoft.Json;
@ -11,8 +12,6 @@ namespace Revitalize.Framework.Objects
public class MultiTiledObject : CustomObject
{
public Dictionary<Vector2, MultiTiledComponent> objects;
[JsonIgnore]
public Dictionary<MultiTiledComponent, Vector2> offSets;
public Guid guid;
@ -36,7 +35,6 @@ namespace Revitalize.Framework.Objects
public MultiTiledObject()
{
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
this.guid = Guid.NewGuid();
}
@ -44,7 +42,6 @@ namespace Revitalize.Framework.Objects
: base(info)
{
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
this.guid = Guid.NewGuid();
}
@ -52,7 +49,6 @@ namespace Revitalize.Framework.Objects
: base(info, TileLocation)
{
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
this.guid = Guid.NewGuid();
}
@ -60,7 +56,6 @@ namespace Revitalize.Framework.Objects
: base(info, TileLocation)
{
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
foreach (var v in ObjectsList)
{
MultiTiledComponent component =(MultiTiledComponent) v.Value.getOne();
@ -75,8 +70,7 @@ namespace Revitalize.Framework.Objects
if (this.objects.ContainsKey(key))
return false;
this.objects.Add(key, (obj as MultiTiledComponent));
this.offSets.Add((obj as MultiTiledComponent), key);
this.objects.Add(key, obj);
if (key.X > this.width) this.width = (int)key.X;
if (key.Y > this.height) this.height = (int)key.Y;
(obj as MultiTiledComponent).containerObject = this;
@ -205,12 +199,17 @@ namespace Revitalize.Framework.Objects
MultiTiledObject self=(MultiTiledObject)Revitalize.ModCore.customObjects[additionalSaveData["id"]].getOne();
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.Deserialize<MultiTiledObject>(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, additionalSaveData["GUID"] + ".json"));
foreach(KeyValuePair<Vector2,MultiTiledComponent> pair in this.objects)
{
pair.Value.containerObject = obj;
}
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], self);
return self;
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj);
return obj;
}
else
{

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Revitalize.Framework.Utilities.Serialization.ContractResolvers
{
public class NetFieldContract : DefaultContractResolver
{
public static NetFieldContract Instance { get; } = new NetFieldContract();
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
{
JsonProperty property = base.CreateProperty(member, memberSerialization);
if (member.Name == nameof(StardewValley.Item.NetFields))
{
property.Ignored = true;
}
return property;
}
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Revitalize.Framework.Utilities.Serialization.Converters
{
public class NetFieldConverter:JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue("NetFields");
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
JsonSerializer serializer)
{
string str = (string)reader.Value;
//string str=jsonObject.ToObject<string>(serializer);
return new Netcode.NetFields();
return null;
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(Netcode.NetFields);
}
public override bool CanRead => true;
public override bool CanWrite => true;
}
}

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Revitalize.Framework.Utilities.Serialization.ContractResolvers;
namespace Revitalize.Framework.Utilities
{
@ -25,8 +26,11 @@ namespace Revitalize.Framework.Utilities
this.serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
this.serializer.NullValueHandling = NullValueHandling.Include;
this.serializer.ContractResolver = new NetFieldContract();
this.addConverter(new Framework.Utilities.Serialization.Converters.RectangleConverter());
this.addConverter(new Framework.Utilities.Serialization.Converters.Texture2DConverter());
this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter());
//this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter());
}

View File

@ -284,6 +284,7 @@ namespace Revitalize
MultiTiledObject hello=Serializer.Deserialize<MultiTiledObject>(Path.Combine(this.Helper.DirectoryPath, (obj as MultiTiledObject).guid + ".json"));
//(hello as MultiTiledObject).info.drawColor = Color.Blue;
customObjects["Omegasis.BigTiledTest"].info.drawColor = hello.info.drawColor;
if (hello == null) log("WTF");
@ -292,9 +293,13 @@ namespace Revitalize
log("AHHHH" + hello.name);
}
hello.info.drawColor = Color.Blue;
foreach(KeyValuePair<Vector2,MultiTiledComponent> pair in hello.objects){
if (hello.objects == null)
{
log("NEVER MIND");
}
foreach(KeyValuePair<Vector2, MultiTiledComponent> pair in hello.objects){
pair.Value.containerObject = hello;
//log((pair.Value as CustomObject).name);
}
Game1.player.items.Add(hello);

View File

@ -75,6 +75,8 @@
<Compile Include="Framework\Player\PlayerInfo.cs" />
<Compile Include="Framework\Utilities\BoundingBoxInfo.cs" />
<Compile Include="Framework\Utilities\InventoryManager.cs" />
<Compile Include="Framework\Utilities\Serialization\ContractResolvers\NetFieldContract.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\NetFieldConverter.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\RectangleConverter.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\Texture2DConverter.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\Vector2Converter.cs" />