예제 #1
0
        private static void DeserializeFormat1(ref MessagePackReader reader, MessagePackSerializerOptions options, ref Type type, ref object value)
        {
            int count = reader.ReadArrayHeader();

            for (int i = 0; i < count; i++)
            {
                switch (i)
                {
                case 0:
                    type = LevelEditorSerializer.GetType(reader.ReadInt32());
                    break;

                case 1:
                    if (type == null)
                    {
                        Debug.LogWarning("Can't deserialize some custom data because no type for it was found.");
                        reader.Skip();
                        break;
                    }

                    ((LevelEditorResolver)LevelEditorResolver.instance).DeserializeDynamic(type, ref reader, out value, options);
                    break;
                }
            }
        }
        private static void DeserializeFormat1(ref MessagePackReader reader, MessagePackSerializerOptions options, ref Type type, ref IExposedWrapper wrapper)
        {
            int count = reader.ReadArrayHeader();

            for (int i = 0; i < count; i++)
            {
                switch (i)
                {
                case 0:
                    var typeHash = reader.ReadInt32();
                    type = LevelEditorSerializer.GetType(typeHash);
                    break;

                case 1:
                    if (type == null)
                    {
                        reader.Skip();
                        continue;
                    }

                    ((LevelEditorResolver)LevelEditorResolver.instance).DeserializeWrapper(type, ref reader, options, out wrapper);
                    break;
                }
            }
        }
        private static void DeserializeFormat0(ref MessagePackReader reader, MessagePackSerializerOptions options, ref Type type, ref IExposedWrapper wrapper)
        {
            int count    = reader.ReadMapHeader();
            int typeHash = 0;

            for (int i = 0; i < count; i++)
            {
                ReadOnlySpan <byte> stringKey = CodeGenHelpers.ReadStringSpan(ref reader);

                switch (stringKey.Length)
                {
                default:
FAIL:
                    reader.Skip();
                    continue;

                case 4:
                    if (AutomataKeyGen.GetKey(ref stringKey) != 1701869940UL)
                    {
                        goto FAIL;
                    }

                    typeHash = reader.ReadInt32();
                    type     = LevelEditorSerializer.GetType(typeHash);
                    continue;

                case 10:
                    if (!stringKey.SequenceEqual(SpanProperties.Slice(1)))
                    {
                        goto FAIL;
                    }

                    if (type == null)
                    {
                        Debug.LogWarning($"Couldn't find a wrapper for type hash {typeHash}.");
                        reader.Skip();
                        continue;
                    }

                    ((LevelEditorResolver)LevelEditorResolver.instance).DeserializeWrapper(type, ref reader, options, out wrapper);
                    continue;
                }
            }
        }
예제 #4
0
        private static void DeserializeFormat0(ref MessagePackReader reader, MessagePackSerializerOptions options, ref Type type, ref object value)
        {
            int count    = reader.ReadMapHeader();
            int typeHash = 0;

            for (int i = 0; i < count; i++)
            {
                ReadOnlySpan <byte> stringKey = CodeGenHelpers.ReadStringSpan(ref reader);
                switch (stringKey.Length)
                {
                default:
FAIL:
                    reader.Skip();
                    continue;

                case 4:
                    if (AutomataKeyGen.GetKey(ref stringKey) != 1701869940UL)
                    {
                        goto FAIL;
                    }

                    typeHash = reader.ReadInt32();
                    type     = LevelEditorSerializer.GetType(typeHash);
                    continue;

                case 5:
                    if (AutomataKeyGen.GetKey(ref stringKey) != 435761734006UL)
                    {
                        goto FAIL;
                    }

                    if (type == null)
                    {
                        Debug.LogWarning($"Can't deserialize some custom data because there's no type with hash {typeHash}.");
                        reader.Skip();
                        break;
                    }

                    ((LevelEditorResolver)LevelEditorResolver.instance).DeserializeDynamic(type, ref reader, out value, options);
                    continue;
                }
            }
        }