mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-11-04 12:51:48 +00:00
Fixed deserialization of decimal script fields
This commit is contained in:
@@ -324,7 +324,9 @@ public class DeserializationObject
|
|||||||
return deserializedValue;
|
return deserializedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldType.IsPrimitive)
|
// Decimals are not actually primitives, but we treat them as if they were, because they are a built-in type
|
||||||
|
// and it makes more sense to send them over to the engine as a binary type than to serialize their underlying fields (which would happen when we treated them as a struct).
|
||||||
|
if (fieldType.IsPrimitive || fieldType == typeof(decimal))
|
||||||
{
|
{
|
||||||
return DeserializePrimitive(fieldName, fieldType);
|
return DeserializePrimitive(fieldName, fieldType);
|
||||||
}
|
}
|
||||||
@@ -364,7 +366,7 @@ public class DeserializationObject
|
|||||||
|
|
||||||
public object? DeserializePrimitive(string fieldName, Type fieldType)
|
public object? DeserializePrimitive(string fieldName, Type fieldType)
|
||||||
{
|
{
|
||||||
Debug.Assert(fieldType.IsPrimitive, $"{fieldType} is not a primitive type.");
|
Debug.Assert(fieldType.IsPrimitive || fieldType == typeof(decimal), $"{fieldType} is not a primitive type.");
|
||||||
|
|
||||||
SerializationType expectedType = SerializationType.None;
|
SerializationType expectedType = SerializationType.None;
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,8 @@ public class SerializedObject
|
|||||||
|
|
||||||
public void SerializeField(string fieldName, object? fieldValue, Type fieldType)
|
public void SerializeField(string fieldName, object? fieldValue, Type fieldType)
|
||||||
{
|
{
|
||||||
|
// Decimals are not actually primitives, but we treat them as if they were, because they are a built-in type
|
||||||
|
// and it makes more sense to send them over to the engine as a binary type than to serialize their underlying fields (which would happen when we treated them as a struct).
|
||||||
if (fieldType.IsPrimitive || fieldType == typeof(decimal))
|
if (fieldType.IsPrimitive || fieldType == typeof(decimal))
|
||||||
{
|
{
|
||||||
// Primitives can't be null
|
// Primitives can't be null
|
||||||
|
|||||||
Reference in New Issue
Block a user