fix: added missing types for new primitives

This commit is contained in:
2025-10-19 19:03:30 +03:00
parent f8096377b2
commit b42f1f1881
19 changed files with 526 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
using System;
using Engine.Core;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Serialization;
namespace Engine.Serializers.Yaml;
public class Vector2DIntConverter : EngineTypeYamlSerializerBase<Vector2DInt>
{
private static readonly int SUBSTRING_START_LENGTH = nameof(Vector2DInt).Length + 1;
public override Vector2DInt Read(IParser parser, Type type, ObjectDeserializer rootDeserializer)
{
string value = parser.Consume<Scalar>().Value;
string insideParenthesis = value[SUBSTRING_START_LENGTH..^1];
string[] values = insideParenthesis.Split(", ");
return new Vector2DInt(int.Parse(values[0]), int.Parse(values[1]));
}
public override void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer)
{
Vector2DInt vector2DInt = (Vector2DInt)value!;
emitter.Emit(new Scalar($"{nameof(Vector2DInt)}({vector2DInt.X}, {vector2DInt.Y})"));
}
}