<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
	version="1.0"
	elementFormDefault="qualified"
	targetNamespace="http://warpdrive.lemadec.org"
	xmlns:wd="http://warpdrive.lemadec.org"
	xmlns:xs="http://www.w3.org/2001/XMLSchema">
	
	<xs:complexType name="elementFor">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="import" type="wd:elementImport" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="filler" type="wd:elementFiller" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="metashell" type="wd:elementMetashell" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="replacement" type="wd:elementReplacement" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="shell" type="wd:elementShell" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="variable" type="xs:string" use="required" />
		<xs:attribute name="from" type="xs:string" use="optional" />
		<xs:attribute name="to" type="xs:string" use="optional" />
		<xs:attribute name="in" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementFillerSet">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="import" type="wd:elementImport" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="filler" type="wd:elementFiller" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="group" type="xs:string" use="required" />
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="weight" type="xs:string" use="optional" />
		<xs:attribute name="ratio" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementImport">
		<xs:attribute name="group" type="xs:string" use="required" />
		<xs:attribute name="name" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementFiller">
		<xs:attribute name="block" type="xs:string" use="required" />
		<xs:attribute name="metadata" type="xs:string" use="optional" />
		<xs:attribute name="nbt" type="xs:string" use="optional" />
		<xs:attribute name="weight" type="xs:string" use="optional" />
		<xs:attribute name="ratio" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementStructure">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="import" type="wd:elementImport" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="metashell" type="wd:elementMetashell" minOccurs="0" maxOccurs="1" />
			<xs:element name="schematic" type="wd:elementSchematic" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="shell" type="wd:elementShell" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="group" type="xs:string" use="required" />
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="weight" type="xs:string" use="optional" />
		<xs:attribute name="ratio" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
    <xs:complexType name="elementSchematic">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="replacement" type="wd:elementReplacement" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
        <xs:attribute name="group" type="xs:string" use="required" />
        <xs:attribute name="name" type="xs:string" use="optional" />
		<xs:attribute name="filename" type="xs:string" use="required" />
		<xs:attribute name="weight" type="xs:string" use="optional" />
		<xs:attribute name="ratio" type="xs:string" use="optional" />
        <xs:attribute name="mods" type="xs:string" use="optional" />
    </xs:complexType>
	
	<xs:complexType name="elementReplacement">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="import" type="wd:elementImport" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="filler" type="wd:elementFiller" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="block" type="xs:string" use="required" />
		<xs:attribute name="metadata" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementLootSet">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="loot" type="wd:elementLoot" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="group" type="xs:string" use="required" />
		<xs:attribute name="name" type="xs:string" use="optional" />
		<xs:attribute name="weight" type="xs:string" use="optional" />
		<xs:attribute name="ratio" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementLoot">
		<xs:attribute name="item" type="xs:string" use="required" />
		<xs:attribute name="damage" type="xs:string" use="optional" />
		<xs:attribute name="nbt" type="xs:string" use="optional" />
		<xs:attribute name="minQuantity" type="xs:string" use="optional" />
		<xs:attribute name="maxQuantity" type="xs:string" use="optional" />
		<xs:attribute name="weight" type="xs:string" use="optional" />
		<xs:attribute name="ratio" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementMetashell">
		<xs:attribute name="block" type="xs:string" use="optional" />
		<xs:attribute name="metadata" type="xs:string" use="optional" />
		<xs:attribute name="minCount" type="xs:string" use="required" />
		<xs:attribute name="maxCount" type="xs:string" use="required" />
		<xs:attribute name="minRadius" type="xs:string" use="required" />
		<xs:attribute name="relativeRadius" type="xs:string" use="required" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementShell">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="import" type="wd:elementImport" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="filler" type="wd:elementFiller" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="name" type="xs:string" use="required" />
		<xs:attribute name="minThickness" type="xs:string" use="required" />
		<xs:attribute name="maxThickness" type="xs:string" use="required" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	
	<xs:complexType name="elementCelestialObject">
		<xs:sequence>
			<xs:element name="parent" minOccurs="0" maxOccurs="1">
				<xs:complexType>
					<xs:annotation>
						<xs:documentation xml:lang="en">
							Coordinates in parent celestial object
							Optional: when not defined, current celestial object is an hyperspace dimension.
						</xs:documentation>
					</xs:annotation>
					<xs:sequence>
						<xs:element name="center" type="wd:elementPosition" minOccurs="1" maxOccurs="1" />
					</xs:sequence>
					<xs:attribute name="id" type="xs:string" use="optional" />
				</xs:complexType>
			</xs:element>
			
			<xs:element name="size" minOccurs="1" maxOccurs="1">
				<xs:complexType>
					<xs:attribute name="x" type="wd:typeWorldSize" use="required" />
					<xs:attribute name="z" type="wd:typeWorldSize" use="required" />
				</xs:complexType>
			</xs:element>
			
			<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
			<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" />
			
			<xs:element name="nbt" type="xs:string" minOccurs="0" maxOccurs="1" />
			
			<xs:element name="dimension" type="wd:elementDimension" minOccurs="0" maxOccurs="1" />
			
			<xs:element name="skybox" minOccurs="0" maxOccurs="1">
				<xs:complexType>
					<xs:annotation>
						<xs:documentation xml:lang="en">
							Sky rendering parameters
						</xs:documentation>
					</xs:annotation>
					<xs:sequence>
						<xs:element name="backgroundColor" type="wd:elementColor" minOccurs="0" maxOccurs="1" />
						<xs:element name="starBrightnessBase" type="xs:float" minOccurs="0" maxOccurs="1" />
						<xs:element name="starBrightnessVanilla" type="xs:float" minOccurs="0" maxOccurs="1" />
						<xs:element name="celestialObjectOpacity" type="xs:float" minOccurs="0" maxOccurs="1" />
						<xs:element name="fogColor" type="wd:elementColor" minOccurs="0" maxOccurs="1" />
						<xs:element name="fogFactor" type="wd:elementColor" minOccurs="0" maxOccurs="1" />
					</xs:sequence>
				</xs:complexType>
			</xs:element>
			
			<xs:element name="render" type="wd:elementRender" minOccurs="0" maxOccurs="unbounded" />
			
			<xs:choice minOccurs="0" maxOccurs="1">
				<xs:element name="for" type="wd:elementFor" minOccurs="0" maxOccurs="unbounded" />
				<xs:element name="celestialObject" type="wd:elementCelestialObject" minOccurs="0" maxOccurs="unbounded" />
			</xs:choice>
		</xs:sequence>
		
		<xs:attribute name="id" type="xs:string" use="required" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementDimension">
		<xs:annotation>
			<xs:documentation xml:lang="en">
				Defines the actual game world characteristics.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence minOccurs="1" maxOccurs="1">
			<xs:element name="center" type="wd:elementPosition" minOccurs="1" maxOccurs="1" />
			<xs:element name="provider" minOccurs="0" maxOccurs="1">
				<xs:complexType>
					<xs:attribute name="type" use="required">
						<xs:simpleType>
							<xs:union memberTypes="xs:double">
								<xs:simpleType>
									<xs:restriction base="xs:NMTOKEN">
										<xs:enumeration value="auto" />
										<xs:enumeration value="WarpDriveSpace" />
										<xs:enumeration value="WarpDriveHyperspace" />
										<xs:enumeration value="other" />
									</xs:restriction>
								</xs:simpleType>
							</xs:union>
						</xs:simpleType>
					</xs:attribute>
				</xs:complexType>
			</xs:element>
			<xs:element name="generate" type="wd:elementGenerate" minOccurs="0" maxOccurs="unbounded" />
			<!-- <xs:element name="effects" type="wd:effectElement" minOccurs="0" maxOccurs="unbounded" /> @TODO Not implemented -->
		</xs:sequence>
		
		<xs:attribute name="id" type="xs:int" use="required" />		
		<xs:attribute name="isBreathable" type="xs:boolean" use="required" />
		<xs:attribute name="isHyperspace" type="xs:boolean" use="optional" default="false" />
		<xs:attribute name="gravity" use="required">
			<xs:simpleType>
				<xs:union memberTypes="xs:double">
					<xs:simpleType>
						<xs:restriction base="xs:NMTOKEN">
							<xs:enumeration value="none" />
							<xs:enumeration value="legacySpace" />
							<xs:enumeration value="legacyHyperspace" />
							<xs:enumeration value="normal" />
						</xs:restriction>
					</xs:simpleType>
				</xs:union>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:complexType name="elementPosition">
		<xs:attribute name="x" type="wd:typeWorldPosition" use="required" />
		<xs:attribute name="z" type="wd:typeWorldPosition" use="required" />
	</xs:complexType>
	
	<xs:complexType name="elementColor">
		<xs:attribute name="red" type="xs:float" use="required" />
		<xs:attribute name="green" type="xs:float" use="required" />
		<xs:attribute name="blue" type="xs:float" use="required" />
	</xs:complexType>
	
	<xs:complexType name="elementRender">
		<xs:attribute name="red" type="xs:float" use="required" />
		<xs:attribute name="green" type="xs:float" use="required" />
		<xs:attribute name="blue" type="xs:float" use="required" />
		<xs:attribute name="alpha" type="xs:float" use="required" />
		<xs:attribute name="texture" type="xs:string" use="optional" />
		<xs:attribute name="periodU" type="xs:double" use="optional" default="0.0" />
		<xs:attribute name="periodV" type="xs:double" use="optional" default="0.0" />
		<xs:attribute name="additive" type="xs:boolean" use="optional" default="false" />
	</xs:complexType>
	
	<xs:complexType name="elementGenerate">
		<xs:attribute name="group" type="xs:string" use="required" />
		<xs:attribute name="ratio" type="xs:string" use="required" />
	</xs:complexType>
	
	
	<xs:simpleType name="typeWorldSize">
		<xs:restriction base="xs:unsignedInt">
			<xs:maxInclusive value="2000000" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="typeWorldPosition">
		<xs:annotation>
			<xs:documentation xml:lang="en">
				Vanilla block positions is limited to +/- 30000 km.
				Vanilla entities positions are computed on simple float precision, which is 6 digits precision => 1000 km.
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:int">
			<xs:minInclusive value="-1000000" />
			<xs:maxInclusive value="1000000" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:complexType name="elementForRoot">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="for" type="wd:elementForRoot" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="fillerSet" type="wd:elementFillerSet" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="lootSet" type="wd:elementLootSet" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="schematic" type="wd:elementSchematic" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="structure" type="wd:elementStructure" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="celestialObject" type="wd:elementCelestialObject" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="variable" type="xs:string" use="required" />
		<xs:attribute name="from" type="xs:string" use="optional" />
		<xs:attribute name="to" type="xs:string" use="optional" />
		<xs:attribute name="in" type="xs:string" use="optional" />
		<xs:attribute name="mods" type="xs:string" use="optional" />
	</xs:complexType>
	
	<xs:element name="worldGeneration">
		<xs:complexType>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="for" type="wd:elementForRoot" minOccurs="0" maxOccurs="unbounded" />
				<xs:element name="fillerSet" type="wd:elementFillerSet" minOccurs="0" maxOccurs="unbounded" />
				<xs:element name="lootSet" type="wd:elementLootSet" minOccurs="0" maxOccurs="unbounded" />
				<xs:element name="schematic" type="wd:elementSchematic" minOccurs="0" maxOccurs="unbounded" />
				<xs:element name="structure" type="wd:elementStructure" minOccurs="0" maxOccurs="unbounded" />
				<xs:element name="celestialObject" type="wd:elementCelestialObject" minOccurs="0" maxOccurs="unbounded" />
			</xs:choice>
			<xs:attribute name="version" type="xs:string" use="required" fixed="2" />
			<xs:attribute name="mods" type="xs:string" use="optional" />
		</xs:complexType>
	</xs:element>
</xs:schema>