It seems like project Revitalize will fail unforunately.
This commit is contained in:
parent
49f06533b3
commit
20c7ba8ad5
|
@ -357,6 +357,12 @@ namespace Revitalize.Framework.Objects
|
||||||
//base.drawWhenHeld(spriteBatch, objectPosition, f);
|
//base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InitNetFields()
|
||||||
|
{
|
||||||
|
this.initNetFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public string getDisplayNameFromStringsFile(string objectID)
|
public string getDisplayNameFromStringsFile(string objectID)
|
||||||
{
|
{
|
||||||
//Load in a file that has all object names referenced here or something.
|
//Load in a file that has all object names referenced here or something.
|
||||||
|
|
|
@ -56,13 +56,26 @@ namespace Revitalize.Framework.Objects.Furniture
|
||||||
|
|
||||||
public override Item getOne()
|
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)
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
{
|
{
|
||||||
BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]];
|
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)
|
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
@ -104,7 +105,11 @@ namespace Revitalize.Framework.Objects
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override object getReplacement()
|
||||||
|
{
|
||||||
|
return base.getReplacement();
|
||||||
|
}
|
||||||
|
|
||||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
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
|
//instead of using this.offsetkey.x use get additional save data function and store offset key there
|
||||||
|
@ -121,9 +126,10 @@ namespace Revitalize.Framework.Objects
|
||||||
|
|
||||||
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
|
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
|
||||||
{
|
{
|
||||||
//Get new container
|
//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 = (MultiTiledComponent)(obj as MultiTiledObject).objects[offsetKey];
|
||||||
|
self.containerObject = obj;
|
||||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], (MultiTiledObject)obj);
|
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], (MultiTiledObject)obj);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -132,19 +138,6 @@ namespace Revitalize.Framework.Objects
|
||||||
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]];
|
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;
|
return (ICustomObject)self;
|
||||||
BasicItemInformation data = Revitalize.ModCore.customObjects[additionalSaveData["id"]].info;
|
BasicItemInformation data = Revitalize.ModCore.customObjects[additionalSaveData["id"]].info;
|
||||||
return new MultiTiledComponent(data, (replacement as Chest).TileLocation)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -11,8 +12,6 @@ namespace Revitalize.Framework.Objects
|
||||||
public class MultiTiledObject : CustomObject
|
public class MultiTiledObject : CustomObject
|
||||||
{
|
{
|
||||||
public Dictionary<Vector2, MultiTiledComponent> objects;
|
public Dictionary<Vector2, MultiTiledComponent> objects;
|
||||||
[JsonIgnore]
|
|
||||||
public Dictionary<MultiTiledComponent, Vector2> offSets;
|
|
||||||
|
|
||||||
public Guid guid;
|
public Guid guid;
|
||||||
|
|
||||||
|
@ -36,7 +35,6 @@ namespace Revitalize.Framework.Objects
|
||||||
public MultiTiledObject()
|
public MultiTiledObject()
|
||||||
{
|
{
|
||||||
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
||||||
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
|
|
||||||
this.guid = Guid.NewGuid();
|
this.guid = Guid.NewGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +42,6 @@ namespace Revitalize.Framework.Objects
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
||||||
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
|
|
||||||
this.guid = Guid.NewGuid();
|
this.guid = Guid.NewGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +49,6 @@ namespace Revitalize.Framework.Objects
|
||||||
: base(info, TileLocation)
|
: base(info, TileLocation)
|
||||||
{
|
{
|
||||||
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
||||||
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
|
|
||||||
this.guid = Guid.NewGuid();
|
this.guid = Guid.NewGuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +56,6 @@ namespace Revitalize.Framework.Objects
|
||||||
: base(info, TileLocation)
|
: base(info, TileLocation)
|
||||||
{
|
{
|
||||||
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
this.objects = new Dictionary<Vector2, MultiTiledComponent>();
|
||||||
this.offSets = new Dictionary<MultiTiledComponent, Vector2>();
|
|
||||||
foreach (var v in ObjectsList)
|
foreach (var v in ObjectsList)
|
||||||
{
|
{
|
||||||
MultiTiledComponent component =(MultiTiledComponent) v.Value.getOne();
|
MultiTiledComponent component =(MultiTiledComponent) v.Value.getOne();
|
||||||
|
@ -75,8 +70,7 @@ namespace Revitalize.Framework.Objects
|
||||||
if (this.objects.ContainsKey(key))
|
if (this.objects.ContainsKey(key))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.objects.Add(key, (obj as MultiTiledComponent));
|
this.objects.Add(key, obj);
|
||||||
this.offSets.Add((obj as MultiTiledComponent), key);
|
|
||||||
if (key.X > this.width) this.width = (int)key.X;
|
if (key.X > this.width) this.width = (int)key.X;
|
||||||
if (key.Y > this.height) this.height = (int)key.Y;
|
if (key.Y > this.height) this.height = (int)key.Y;
|
||||||
(obj as MultiTiledComponent).containerObject = this;
|
(obj as MultiTiledComponent).containerObject = this;
|
||||||
|
@ -202,15 +196,20 @@ namespace Revitalize.Framework.Objects
|
||||||
|
|
||||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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"]))
|
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
|
||||||
{
|
{
|
||||||
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], self);
|
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj);
|
||||||
return self;
|
return obj;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Revitalize.Framework.Utilities.Serialization.ContractResolvers;
|
||||||
|
|
||||||
namespace Revitalize.Framework.Utilities
|
namespace Revitalize.Framework.Utilities
|
||||||
{
|
{
|
||||||
|
@ -25,8 +26,11 @@ namespace Revitalize.Framework.Utilities
|
||||||
this.serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
this.serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||||
this.serializer.NullValueHandling = NullValueHandling.Include;
|
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.RectangleConverter());
|
||||||
this.addConverter(new Framework.Utilities.Serialization.Converters.Texture2DConverter());
|
this.addConverter(new Framework.Utilities.Serialization.Converters.Texture2DConverter());
|
||||||
|
this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter());
|
||||||
//this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter());
|
//this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,6 +284,7 @@ namespace Revitalize
|
||||||
|
|
||||||
|
|
||||||
MultiTiledObject hello=Serializer.Deserialize<MultiTiledObject>(Path.Combine(this.Helper.DirectoryPath, (obj as MultiTiledObject).guid + ".json"));
|
MultiTiledObject hello=Serializer.Deserialize<MultiTiledObject>(Path.Combine(this.Helper.DirectoryPath, (obj as MultiTiledObject).guid + ".json"));
|
||||||
|
|
||||||
//(hello as MultiTiledObject).info.drawColor = Color.Blue;
|
//(hello as MultiTiledObject).info.drawColor = Color.Blue;
|
||||||
customObjects["Omegasis.BigTiledTest"].info.drawColor = hello.info.drawColor;
|
customObjects["Omegasis.BigTiledTest"].info.drawColor = hello.info.drawColor;
|
||||||
if (hello == null) log("WTF");
|
if (hello == null) log("WTF");
|
||||||
|
@ -292,9 +293,13 @@ namespace Revitalize
|
||||||
log("AHHHH" + hello.name);
|
log("AHHHH" + hello.name);
|
||||||
}
|
}
|
||||||
hello.info.drawColor = Color.Blue;
|
hello.info.drawColor = Color.Blue;
|
||||||
|
if (hello.objects == null)
|
||||||
foreach(KeyValuePair<Vector2,MultiTiledComponent> pair in hello.objects){
|
{
|
||||||
pair.Value.containerObject = hello;
|
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);
|
Game1.player.items.Add(hello);
|
||||||
|
|
|
@ -75,6 +75,8 @@
|
||||||
<Compile Include="Framework\Player\PlayerInfo.cs" />
|
<Compile Include="Framework\Player\PlayerInfo.cs" />
|
||||||
<Compile Include="Framework\Utilities\BoundingBoxInfo.cs" />
|
<Compile Include="Framework\Utilities\BoundingBoxInfo.cs" />
|
||||||
<Compile Include="Framework\Utilities\InventoryManager.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\RectangleConverter.cs" />
|
||||||
<Compile Include="Framework\Utilities\Serialization\Converters\Texture2DConverter.cs" />
|
<Compile Include="Framework\Utilities\Serialization\Converters\Texture2DConverter.cs" />
|
||||||
<Compile Include="Framework\Utilities\Serialization\Converters\Vector2Converter.cs" />
|
<Compile Include="Framework\Utilities\Serialization\Converters\Vector2Converter.cs" />
|
||||||
|
|
Loading…
Reference in New Issue