-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from SubnauticaModding/dev
SMLHelper 2.12.0
- Loading branch information
Showing
21 changed files
with
396 additions
and
34 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using UnityEngine; | ||
#if SUBNAUTICA_STABLE | ||
using Oculus.Newtonsoft.Json; | ||
#else | ||
using Newtonsoft.Json; | ||
#endif | ||
namespace SMLHelper.V2.Json.Converters | ||
{ | ||
/// <summary> | ||
/// A Vector2 json converter that simplifies the Vector2 to only x,y serialization. | ||
/// </summary> | ||
public class Vector2Converter : JsonConverter | ||
{ | ||
/// <summary> | ||
/// A method that determines when this converter should process. | ||
/// </summary> | ||
/// <param name="objectType">the current object type</param> | ||
/// <returns></returns> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(Vector2); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Serialize the current object. | ||
/// </summary> | ||
/// <param name="writer"></param> | ||
/// <param name="value"></param> | ||
/// <param name="serializer"></param> | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var vector2 = (Vector2)value; | ||
serializer.Serialize(writer, (Vector2Json)vector2); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Deserialize and read the current object. | ||
/// </summary> | ||
/// <param name="reader"></param> | ||
/// <param name="objectType"></param> | ||
/// <param name="existingValue"></param> | ||
/// <param name="serializer"></param> | ||
/// <returns></returns> | ||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
return (Vector2)serializer.Deserialize<Vector2Json>(reader); | ||
} | ||
} | ||
|
||
internal record Vector2Json(float X, float Y) | ||
{ | ||
public static explicit operator Vector2(Vector2Json v) => new(v.X, v.Y); | ||
public static explicit operator Vector2Json(Vector2 v) => new(v.x, v.y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using UnityEngine; | ||
#if SUBNAUTICA_STABLE | ||
using Oculus.Newtonsoft.Json; | ||
#else | ||
using Newtonsoft.Json; | ||
#endif | ||
namespace SMLHelper.V2.Json.Converters | ||
{ | ||
/// <summary> | ||
/// A Vector2Int json converter that simplifies the Vector2Int to only x,y serialization. | ||
/// </summary> | ||
public class Vector2IntConverter : JsonConverter | ||
{ | ||
/// <summary> | ||
/// A method that determines when this converter should process. | ||
/// </summary> | ||
/// <param name="objectType">the current object type</param> | ||
/// <returns></returns> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(Vector2Int); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Serialize the current object. | ||
/// </summary> | ||
/// <param name="writer"></param> | ||
/// <param name="value"></param> | ||
/// <param name="serializer"></param> | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var vector2Int = (Vector2Int)value; | ||
serializer.Serialize(writer, (Vector2IntJson)vector2Int); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Deserialize and read the current object. | ||
/// </summary> | ||
/// <param name="reader"></param> | ||
/// <param name="objectType"></param> | ||
/// <param name="existingValue"></param> | ||
/// <param name="serializer"></param> | ||
/// <returns></returns> | ||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
return (Vector2Int)serializer.Deserialize<Vector2IntJson>(reader); | ||
} | ||
} | ||
|
||
internal record Vector2IntJson(int X, int Y) | ||
{ | ||
public static explicit operator Vector2Int(Vector2IntJson v) => new(v.X, v.Y); | ||
public static explicit operator Vector2IntJson(Vector2Int v) => new(v.x, v.y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using UnityEngine; | ||
#if SUBNAUTICA_STABLE | ||
using Oculus.Newtonsoft.Json; | ||
#else | ||
using Newtonsoft.Json; | ||
#endif | ||
namespace SMLHelper.V2.Json.Converters | ||
{ | ||
/// <summary> | ||
/// A Vector3Int json converter that simplifies the Vector3Int to only x,y,z serialization. | ||
/// </summary> | ||
public class Vector3IntConverter : JsonConverter | ||
{ | ||
/// <summary> | ||
/// A method that determines when this converter should process. | ||
/// </summary> | ||
/// <param name="objectType">the current object type</param> | ||
/// <returns></returns> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(Vector3Int); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Serialize the current object. | ||
/// </summary> | ||
/// <param name="writer"></param> | ||
/// <param name="value"></param> | ||
/// <param name="serializer"></param> | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var vector3Int = (Vector3Int)value; | ||
serializer.Serialize(writer, (Vector3IntJson)vector3Int); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Deserialize and read the current object. | ||
/// </summary> | ||
/// <param name="reader"></param> | ||
/// <param name="objectType"></param> | ||
/// <param name="existingValue"></param> | ||
/// <param name="serializer"></param> | ||
/// <returns></returns> | ||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
return (Vector3Int)serializer.Deserialize<Vector3IntJson>(reader); | ||
} | ||
} | ||
|
||
internal record Vector3IntJson(int X, int Y, int Z) | ||
{ | ||
public static explicit operator Vector3Int(Vector3IntJson v) => new(v.X, v.Y, v.Z); | ||
public static explicit operator Vector3IntJson(Vector3Int v) => new(v.x, v.y, v.z); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using UnityEngine; | ||
#if SUBNAUTICA_STABLE | ||
using Oculus.Newtonsoft.Json; | ||
#else | ||
using Newtonsoft.Json; | ||
#endif | ||
namespace SMLHelper.V2.Json.Converters | ||
{ | ||
/// <summary> | ||
/// A Vector4 json converter that simplifies the Vector4 to only x,y,z,w serialization. | ||
/// </summary> | ||
public class Vector4Converter : JsonConverter | ||
{ | ||
/// <summary> | ||
/// A method that determines when this converter should process. | ||
/// </summary> | ||
/// <param name="objectType">the current object type</param> | ||
/// <returns></returns> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(Vector4); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Serialize the current object. | ||
/// </summary> | ||
/// <param name="writer"></param> | ||
/// <param name="value"></param> | ||
/// <param name="serializer"></param> | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var vector4 = (Vector4)value; | ||
serializer.Serialize(writer, (Vector4Json)vector4); | ||
} | ||
|
||
/// <summary> | ||
/// A method that tells Newtonsoft how to Deserialize and read the current object. | ||
/// </summary> | ||
/// <param name="reader"></param> | ||
/// <param name="objectType"></param> | ||
/// <param name="existingValue"></param> | ||
/// <param name="serializer"></param> | ||
/// <returns></returns> | ||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
return (Vector4)serializer.Deserialize<Vector4Json>(reader); | ||
} | ||
} | ||
|
||
internal record Vector4Json(float X, float Y, float Z, float W) | ||
{ | ||
public static explicit operator Vector4(Vector4Json v) => new(v.X, v.Y, v.Z, v.W); | ||
public static explicit operator Vector4Json(Vector4 v) => new(v.x, v.y, v.z, v.w); | ||
} | ||
} |
Oops, something went wrong.