// <auto-generated/>

//------------------------------------------------------------------------------------------------
//      This file has been programatically generated; DON´T EDIT!
//------------------------------------------------------------------------------------------------

#pragma warning disable SA1001
#pragma warning disable SA1027
#pragma warning disable SA1028
#pragma warning disable SA1121
#pragma warning disable SA1205
#pragma warning disable SA1309
#pragma warning disable SA1402
#pragma warning disable SA1505
#pragma warning disable SA1507
#pragma warning disable SA1508
#pragma warning disable SA1652

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Text.Json;

using JSONREADER = System.Text.Json.Utf8JsonReader;
using JSONWRITER = System.Text.Json.Utf8JsonWriter;
using FIELDINFO = SharpGLTF.Reflection.FieldInfo;


namespace SharpGLTF.Schema2
{
	using Collections;

	/// <summary>
	/// glTF extension that enables shifting and scaling UV coordinates on a per-texture basis
	/// </summary>
	#if NET6_0_OR_GREATER
	[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
	#endif
	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("SharpGLTF.CodeGen", "1.0.0.0")]
	partial class TextureTransform : ExtraProperties
	{
	
		#region reflection
	
		public new const string SCHEMANAME = "KHR_texture_transform";
		protected override string GetSchemaName() => SCHEMANAME;
	
		protected override IEnumerable<string> ReflectFieldsNames()
		{
			yield return "offset";
			yield return "rotation";
			yield return "scale";
			yield return "texCoord";
			foreach(var f in base.ReflectFieldsNames()) yield return f;
		}
		protected override bool TryReflectField(string name, out FIELDINFO value)
		{
			switch(name)
			{
				case "offset": value = FIELDINFO.From("offset",this, instance => instance._offset ?? Vector2.Zero); return true;
				case "rotation": value = FIELDINFO.From("rotation",this, instance => instance._rotation ?? 0); return true;
				case "scale": value = FIELDINFO.From("scale",this, instance => instance._scale ?? Vector2.One); return true;
				case "texCoord": value = FIELDINFO.From("texCoord",this, instance => instance._texCoord); return true;
				default: return base.TryReflectField(name, out value);
			}
		}
	
		#endregion
	
		#region data
	
		private static readonly Vector2 _offsetDefault = Vector2.Zero;
		private Vector2? _offset = _offsetDefault;
		
		private const Double _rotationDefault = 0;
		private Double? _rotation = _rotationDefault;
		
		private static readonly Vector2 _scaleDefault = Vector2.One;
		private Vector2? _scale = _scaleDefault;
		
		private const Int32 _texCoordMinimum = 0;
		private Int32? _texCoord;
		
		#endregion
	
		#region serialization
	
		protected override void SerializeProperties(JSONWRITER writer)
		{
			base.SerializeProperties(writer);
			SerializeProperty(writer, "offset", _offset, _offsetDefault);
			SerializeProperty(writer, "rotation", _rotation, _rotationDefault);
			SerializeProperty(writer, "scale", _scale, _scaleDefault);
			SerializeProperty(writer, "texCoord", _texCoord);
		}
	
		protected override void DeserializeProperty(string jsonPropertyName, ref JSONREADER reader)
		{
			switch (jsonPropertyName)
			{
				case "offset": DeserializePropertyValue<TextureTransform, Vector2?>(ref reader, this, out _offset); break;
				case "rotation": DeserializePropertyValue<TextureTransform, Double?>(ref reader, this, out _rotation); break;
				case "scale": DeserializePropertyValue<TextureTransform, Vector2?>(ref reader, this, out _scale); break;
				case "texCoord": DeserializePropertyValue<TextureTransform, Int32?>(ref reader, this, out _texCoord); break;
				default: base.DeserializeProperty(jsonPropertyName,ref reader); break;
			}
		}
	
		#endregion
	
	}

}
