<?xml version="1.0"?>
<xs:schema version="1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified" targetNamespace="outlaw" xmlns:tns="outlaw" attributeFormDefault="unqualified">
    <xs:complexType name="namedEntity">
        <xs:attribute name="name" use="required" type="xs:NCName"/>
        <xs:attribute name="comment" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="image">
        <xs:complexContent>
            <xs:extension base="tns:namedEntity">
                <xs:sequence>
                    <xs:element name="displayData" type="tns:platformData" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
                <xs:attribute name="category" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="tile">            
        <xs:complexContent>
            <xs:extension base="tns:image">
                <xs:attribute name="id" type="xs:string" use="required"/>
                <xs:attribute name="obstruction" type="xs:boolean"/>
                <xs:attribute name="sprite" type="xs:boolean"/>
                <xs:attribute name="blocker" type="xs:boolean"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="platformData">
        <xs:simpleContent>
            <xs:extension base="xs:hexBinary">
                <xs:attribute name="platform" type="xs:string" use="required"/>
                <xs:attribute name="width" type="xs:int" use="required"/>
                <xs:attribute name="height" type="xs:int" use="required"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:complexType name="script">
        <xs:complexContent>
            <xs:extension base="tns:namedEntity">
                <xs:sequence>
                    <xs:element name="description" type="xs:string" minOccurs="0"/>
                    <xs:element name="category" type="xs:string" minOccurs="0"/>
                    <xs:element name="block" type="tns:block"/>
                    <xs:element name="locationTrigger" minOccurs="0" maxOccurs="unbounded">
                        <xs:complexType>
                            <xs:attribute name="x" type="xs:int"/>
                            <xs:attribute name="y" type="xs:int"/>
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="intervalTrigger" minOccurs="0" maxOccurs="unbounded">
                        <xs:complexType>
                            <xs:attribute name="start" type="xs:int" use="optional"/>
                            <xs:attribute name="end" type="xs:int" use="optional"/>
                            <xs:attribute name="period" type="xs:int" use="optional"/>
                            <xs:attribute name="ifTrue" type="xs:string" use="optional"/>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="scripts">
        <xs:sequence>
            <xs:element name="script" type="tns:script" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="variable">
        <xs:complexContent>
            <xs:extension base="tns:namedEntity">
                <xs:attribute name="type" use="required" type="xs:NMTOKEN"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="variables">
        <xs:sequence>
            <xs:element name="variable" minOccurs="0" maxOccurs="unbounded" type="tns:variable"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="map">
        <xs:complexContent>
            <xs:extension base="tns:scope">
                <xs:sequence>
                    <xs:element name="chunk" maxOccurs="unbounded">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="row" maxOccurs="unbounded" type="xs:NMTOKENS"/>
                            </xs:sequence>
                            <xs:attribute name="x" type="xs:int"/>
                            <xs:attribute name="y" type="xs:int"/>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="name" type="xs:string"/>
                <xs:attribute name="width" type="xs:int"/>
                <xs:attribute name="height" type="xs:int"/>
                <xs:attribute name="category" type="xs:string"/>
                <xs:attribute name="wrap" type="xs:boolean" default="false"/>
                <xs:attribute name="startX" type="xs:int" default="0"/>
                <xs:attribute name="startY" type="xs:int" default="0"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="global">
        <xs:complexContent>
            <xs:extension base="tns:scope">
                <xs:sequence>
                    <xs:element name="userTypes" minOccurs="0" maxOccurs="1">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="userType" minOccurs="0" maxOccurs="unbounded" type="tns:userType"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="userType">
        <xs:complexContent>
            <xs:extension base="tns:namedEntity">
                <xs:sequence>
                    <xs:element name="attribute" minOccurs="1" maxOccurs="unbounded" type="tns:variable"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="scope">
        <xs:sequence>
            <xs:element name="scripts" type="tns:scripts"/>
            <xs:element name="variables" type="tns:variables"/>
        </xs:sequence>        
    </xs:complexType>
    <xs:complexType name="block">
        <xs:sequence>
            <xs:element minOccurs="0" name="next" type="tns:next"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="field" type="tns:field"/>
                <xs:element name="mutation" type="tns:mutation"/>
                <xs:element name="statement" type="tns:statement"/>
                <xs:element name="value" type="tns:value"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="inline" type="xs:boolean"/>
        <xs:attribute name="type" use="required" type="xs:NCName"/>
        <xs:attribute name="id" type="xs:integer"/>
        <xs:attribute name="uri" type="xs:string"/>
        <xs:attribute name="local" type="xs:string"/>
        <xs:attribute name="x" type="xs:integer"/>
        <xs:attribute name="y" type="xs:integer"/>
    </xs:complexType>
    <xs:complexType name="next">
        <xs:sequence>
            <xs:element name="block" type="tns:block"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="field">
        <xs:simpleContent>
            <xs:extension base="xs:NMTOKEN">
                <xs:attribute name="name" use="required" type="xs:NCName"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:complexType name="mutation">
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="arg" type="tns:arg"/>
        </xs:sequence>
        <xs:attribute name="name" type="xs:NCName"/>
        <xs:anyAttribute/>
    </xs:complexType>
    <xs:complexType name="arg">
        <xs:attribute name="name" use="required" type="xs:NCName"/>
    </xs:complexType>
    <xs:complexType name="statement">
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="block" type="tns:block"/>
        </xs:sequence>
        <xs:attribute name="name" use="required" type="xs:NCName"/>
    </xs:complexType>
    <xs:complexType name="value">
        <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="block" type="tns:block"/>
        </xs:sequence>
        <xs:attribute name="name" use="required" type="xs:NCName"/>
    </xs:complexType>
    <xs:element name="gameData">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="global" minOccurs="0" maxOccurs="1" type="tns:global"/>
                <xs:element name="image" minOccurs="0" maxOccurs="unbounded" type="tns:image"/>
                <xs:element name="tile" minOccurs="0" maxOccurs="unbounded" type="tns:tile"/>
                <xs:element name="map" minOccurs="0" maxOccurs="unbounded" type="tns:map"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>    
</xs:schema>
