2024-08-09 23:12:45 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
2024-08-10 19:18:33 +02:00
|
|
|
using System.Numerics;
|
2024-08-09 23:12:45 +02:00
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
namespace DotTiled;
|
|
|
|
|
|
|
|
internal partial class Tmj
|
|
|
|
{
|
2024-08-10 19:18:33 +02:00
|
|
|
internal static BaseLayer ReadLayer(
|
|
|
|
JsonElement element,
|
|
|
|
Func<string, Template> externalTemplateResolver,
|
|
|
|
IReadOnlyCollection<CustomTypeDefinition> customTypeDefinitions)
|
2024-08-09 23:12:45 +02:00
|
|
|
{
|
|
|
|
var type = element.GetRequiredProperty<string>("type");
|
|
|
|
|
|
|
|
return type switch
|
|
|
|
{
|
2024-08-10 19:18:33 +02:00
|
|
|
"tilelayer" => ReadTileLayer(element, customTypeDefinitions),
|
|
|
|
"objectgroup" => ReadObjectLayer(element, externalTemplateResolver, customTypeDefinitions),
|
2024-08-11 17:02:16 +02:00
|
|
|
"imagelayer" => ReadImageLayer(element, customTypeDefinitions),
|
2024-08-10 19:18:33 +02:00
|
|
|
"group" => ReadGroup(element, externalTemplateResolver, customTypeDefinitions),
|
2024-08-09 23:12:45 +02:00
|
|
|
_ => throw new JsonException($"Unsupported layer type '{type}'.")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|