# Expected vars:
# NS (str), e.g. "spider_"
# EYESPIDER (bool)


import "data/_spider_parts.fus"


label "label:head": default $PREFIX NS "head"
label "label:crawl_head": default $PREFIX NS "crawl_head"
label "label:sleep_head": default $PREFIX NS "sleep_head"
label "label:fleg": default $PREFIX NS "fleg"
label "label:bleg": default $PREFIX NS "bleg"


shapes:

    $PREFIX NS "stand":
        labels:
            : "label:head" ( 0  1  3  1)  0 f
            : "label:bleg"  ( 0  1  1  1)  0 f
            : "label:fleg"  ( 2  1  1  1)  6 t

    $PREFIX NS "look_up":
        # "stand" -> "looking_up"
        animation: cycle 1
        labels:
            : "label:head" ( 0  1  3  1)  1 f
            : "label:bleg"  ( 0  1  1  1)  0 f
            : "label:fleg"  ( 2  1  1  1)  6 t

    $PREFIX NS "unlook_up":
        # "looking_up" -> "stand"
        animation: cycle $PREFIX NS "look_up"
        shapes:
            : $PREFIX NS "look_up" (0 0 0 0) 0 f 0+r

    $PREFIX NS "looking_up":
        labels:
            : "label:head" ( 0  1  3  1)  2 f
            : "label:bleg"  ( 0  1  1  1)  0 f
            : "label:fleg"  ( 2  1  1  1)  6 t

    $PREFIX NS "step":
        animation: cycle 3
        labels:
            : "label:head" (-1  0  3  1)  0 f  (0 1)
            : "label:head" ( 0  0  3  1)  0 f  (1 1)
            : "label:head" ( 0  1  3  1)  0 f  (2 1)
            : "label:bleg"  (-1  1  1  1)  0 f
            : "label:fleg"  ( 2  1  1  1)  6 t

    $PREFIX NS "turn":
        animation: cycle $PREFIX NS "step"
        $IF EYESPIDER:
            shapes:
                : "_eye_open"        (-1  0  3  1)  0 f 0 ( 0  1)
                : "_eye_open"        ( 0  0  3  1)  0 f 0 ( 1  1)
                : "_eye_open"        ( 1  0  3  1)  0 f 0 ( 2  1)
            labels:
                : "label:bleg"  (-1  1  1  1)  0 f
                : "label:fleg"  ( 2  1  1  1)  6 t
        $IF !EYESPIDER:
            shapes:
                : $PREFIX NS "step" (0 0 0 0) 0 f

    $PREFIX NS "spit":
        animation: cycle 10
        labels:
            # Player stand:
            #: "label:head" ( 0  1  3  1)  0 f  (6 1)
            #: "label:bleg"  ( 0  1  1  1)  0 f  (6 1)
            #: "label:fleg"  ( 2  1  1  1)  6 t  (6 1)

            # Head
            : "label:head" (-2  1  3  1)  0 f  (0 1)
            : "label:head" (-2  0  3  1)  0 f  (1 4)
            : "label:head" (-2  1  3  1)  0 f  (5 1)
            : "label:head" (-1  1  3  1)  0 f  (6 1)
            : "label:head" ( 0  1  3  1)  0 f  (7 3)

            # Back leg
            : "label:bleg"  (-1  1  1  1)  0 f  (0 1)
            : "label:bleg"  (-2  1  1  1)  1 f  (1 5)
            : "label:bleg"  (-1  1  1  1)  0 f  (6 1)
            : "label:bleg"  ( 0  1  1  1)  0 f  (7 3)

            # Front leg
            : "label:fleg"  ( 1  1  1  1)  7 t  (0 1)
            : "label:fleg"  ( 0  1  1  1)  7 t  (1 1)
            : "label:fleg"  ( 0  1  1  1)  6 t  (2 7)
            : "label:fleg"  ( 1  1  1  1)  6 t  (9 1)

    $PREFIX NS "looking_up_spit":
        animation: cycle 10
        labels:
            # Player stand:
            #: "label:head" ( 0  1  3  1)  0 f  (6 1)
            #: "label:bleg"  ( 0  1  1  1)  0 f  (6 1)
            #: "label:fleg"  ( 2  1  1  1)  6 t  (6 1)

            # Head
            : "label:head" (-2  1  3  1)  2 f  (0 1)
            : "label:head" (-2  0  3  1)  2 f  (1 4)
            : "label:head" (-2  1  3  1)  2 f  (5 1)
            : "label:head" (-1  1  3  1)  2 f  (6 1)
            : "label:head" ( 0  1  3  1)  2 f  (7 3)

            # Back leg
            : "label:bleg"  (-1  1  1  1)  0 f  (0 1)
            : "label:bleg"  (-2  1  1  1)  1 f  (1 5)
            : "label:bleg"  (-1  1  1  1)  0 f  (6 1)
            : "label:bleg"  ( 0  1  1  1)  0 f  (7 3)

            # Front leg
            : "label:fleg"  ( 1  1  1  1)  7 t  (0 1)
            : "label:fleg"  ( 0  1  1  1)  7 t  (1 1)
            : "label:fleg"  ( 0  1  1  1)  6 t  (2 7)
            : "label:fleg"  ( 1  1  1  1)  6 t  (9 1)

    $PREFIX NS "crawl_spit":
        animation: cycle 10
        labels:
            # Player crawl:
            #: "label:crawl_head" ( 0  1  2  0)  0 f
            #: "label:bleg"  (-1  1  1  1)  0 f
            #: "label:fleg"  ( 2  1  1  1)  6 t

            # Head
            : "label:crawl_head" (-2  1  2  0)  0 f  (0 1)
            : "label:crawl_head" (-2  0  2  0)  0 f  (1 4)
            : "label:crawl_head" (-2  1  2  0)  0 f  (5 1)
            : "label:crawl_head" (-1  1  2  0)  0 f  (6 1)
            : "label:crawl_head" ( 0  1  2  0)  0 f  (7 3)

            # Back leg
            : "label:bleg"  (-2  1  1  1)  0 f  (0 1)
            : "label:bleg"  (-3  1  1  1)  1 f  (1 5)
            : "label:bleg"  (-2  1  1  1)  0 f  (6 1)
            : "label:bleg"  (-1  1  1  1)  0 f  (7 3)

            # Front leg
            : "label:fleg"  ( 1  1  1  1)  7 t  (0 1)
            : "label:fleg"  ( 0  1  1  1)  7 t  (1 1)
            : "label:fleg"  ( 0  1  1  1)  6 t  (2 7)
            : "label:fleg"  ( 1  1  1  1)  6 t  (9 1)

    $PREFIX NS "crawl_looking_up_spit":
        animation: cycle 10
        labels:
            # spider_crawl_looking_up:
            #: "label:crawl_head" ( 3  1  1  1)  2 f
            #: "label:bleg"  ( 1  1  1  1)  0 f
            #: "label:fleg"  ( 4  2  0  0)  5 t

            # Head
            : "label:crawl_head" ( 1  1  1  1)  2 f  (0 1)
            : "label:crawl_head" ( 1  0  1  1)  2 f  (1 4)
            : "label:crawl_head" ( 1  1  1  1)  2 f  (5 1)
            : "label:crawl_head" ( 2  1  1  1)  2 f  (6 1)
            : "label:crawl_head" ( 3  1  1  1)  2 f  (7 3)

            # Back leg
            : "label:bleg"  ( 1  1  1  1)  0 f  (0 1)
            : "label:bleg"  (-1  2  1  1)  1 f  (1 5)
            : "label:bleg"  ( 0  2  1  1)  0 f  (6 1)
            : "label:bleg"  ( 1  1  1  1)  0 f  (7 3)

            # Front leg
            : "label:fleg"  ( 2  2  1  0)  7 t  (0 1)
            : "label:fleg"  ( 1  2  1  0)  7 t  (1 1)
            : "label:fleg"  ( 1  2  1  0)  6 t  (2 7)
            : "label:fleg"  ( 2  2  1  0)  6 t  (9 1)

    $PREFIX NS "_swim_spit_leg":
        animation: cycle 10
        labels:
            # Used for back *and* front leg
            : "label:fleg"  ( 0  2  1  0)  7 t  (0 1)
            : "label:fleg"  ( 0  1  1  0)  8 t  (1 1)
            : "label:fleg"  ( 0  0  1  0)  8 t  (2 1)
            : "label:fleg"  ( 0  0  1  0)  7 t  (3 1)
            : "label:fleg"  ( 0  0  1  0)  6 t  (4 1)
            : "label:fleg"  ( 0  0  1  0)  5 t  (5 1)
            : "label:fleg"  ( 1  0  1  0)  4 t  (6 1)
            : "label:fleg"  ( 1  1  1  0)  4 t  (7 1)
            : "label:fleg"  ( 1  2  1  0)  4 t  (8 1)
            : "label:fleg"  ( 1  3  1  0)  5 t  (9 1)

    $PREFIX NS "swim_spit":
        animation: cycle 10
        labels:
            # Head
            : "label:head" (-2  1  3  0)  1 f  (0 1)
            : "label:head" (-2  0  3  0)  1 f  (1 1)
            : "label:head" (-2 -1  3  0)  1 f  (2 2)
            : "label:head" (-1 -1  3  0)  1 f  (4 1)
            : "label:head" ( 0 -1  3  0)  0 f  (5 1)
            : "label:head" ( 0  0  3  0)  0 f  (6 1)
            : "label:head" ( 0  1  3  0)  0 f  (7 1)
            : "label:head" ( 0  1  4  0)  0 f  (8 1)
            : "label:head" ( 0  2  3  1)  0 f  (9 1)

        shapes:
            # Back leg
            : $PREFIX NS "_swim_spit_leg" (-1 -1 0 1) 0 f

            # Front leg
            : $PREFIX NS "_swim_spit_leg" ( 0  0 0 0) 0 f

    $PREFIX NS "_jump":
        labels:
            : "label:head" ( 0  1  3  1)  0 f
            : "label:bleg"  ( 0  1  1  1) 10 f
            : "label:fleg"  ( 2  1  1  1)  7 t

    $PREFIX NS "jump":
        animation: cycle 2
        shapes:
            : $PREFIX NS "_jump" (-2 0 0  0) 0 f  0 (0 1)
            : $PREFIX NS "_jump" ( 0 0 0  0) 0 f  0 (1 1)

    $PREFIX NS "swim_jump":
        animation: cycle 5
        shapes:
            : $PREFIX NS "_jump" (-2 0 0  0) 0 f  0 (0 1)
            : $PREFIX NS "_jump" (-1 0 0  0) 0 f  0 (1 2)
            : $PREFIX NS "_jump" ( 0 0 0  0) 0 f  0 (3 2)

    $PREFIX NS "crawl":
        labels:
            : "label:crawl_head" ( 0  1  2  0)  0 f
            : "label:bleg"  (-1  1  1  1)  0 f
            : "label:fleg"  ( 2  1  1  1)  6 t

    $PREFIX NS "crawl_flip":
        animation: cycle 3
        labels:
            : "label:crawl_head" (-1  1  3 -4)  2 f (0 1)
            : "label:crawl_head" (-1  1  3 -3)  2 f (1 1)
            : "label:crawl_head" (-1  1  3 -2)  1 f (2 1)
            : "label:bleg"  ( 1  0  1 -1) 10 f (0 1)
            : "label:bleg"  ( 0  1  1  0) 11 f (1 1)
            : "label:bleg"  (-1  1  1  1)  0 f (2 1)
            : "label:fleg"  ( 2  0  1 -1)  8 t (0 1)
            : "label:fleg"  ( 1  1  1  0)  7 t (1 1)
            : "label:fleg"  ( 2  1  1  1)  6 t (2 1)

    $PREFIX NS "crawl_look_up":
        # "crawl" -> "crawl_looking_up"
        animation: cycle 1
        labels:
            : "label:crawl_head" ( 1  1  2  0)  1 f (0 1)
            : "label:bleg"  ( 0  1  1  1) 11 f (0 1)
            : "label:fleg"  ( 3  2  0  2)  5 t (0 1)

    $PREFIX NS "crawl_unlook_up":
        # "crawl_looking_up" -> "crawl"
        animation: cycle $PREFIX NS "crawl_look_up"
        shapes:
            : $PREFIX NS "crawl_look_up" (0 0 0 0) 0 f 0+r

    $PREFIX NS "crawl_looking_up":
        labels:
            : "label:crawl_head" ( 3  1  1  1)  2 f
            : "label:bleg"  ( 1  1  1  1)  0 f
            : "label:fleg"  ( 5  1  1  1)  4 t

    $PREFIX NS "crawling":
        # "stand" -> "crawl"
        animation: cycle 2
        labels:
            : "label:crawl_head" ( 0  1  3  1) 0 f (0 1)
            : "label:crawl_head" (-1  2  3  0) 0 f (1 1)
            : "label:bleg"  ( 0  1  1  1)  0 f (0 1)
            : "label:bleg"  ( 0  1  1  1) 11 f (1 1)

            : "label:fleg"  ( 2  1  1  1)  6 t

    $PREFIX NS "uncrawling":
        # "crawl" -> "stand"
        animation: cycle $PREFIX NS "crawling"
        shapes:
            : $PREFIX NS "crawling" (0 0 0 0) 0 f 0+r

    $PREFIX NS "crawling_looking_up":
        # "looking_up" -> "crawl_looking_up"
        animation: cycle 2
        labels:
            : "label:crawl_head" ( 0  2  3  0) 2 f (0 1)
            : "label:crawl_head" ( 2  2  1  1) 2 f (1 1)
            : "label:bleg"  ( 0  1  1  1)  0 f (0 1)
            : "label:bleg"  ( 1  1  1  1) 11 f (1 1)
            : "label:fleg"  ( 3  2  0  2)  5 t (0 1)
            : "label:fleg"  ( 5  1  1  1)  4 t (1 1)

    $PREFIX NS "uncrawling_looking_up":
        # "crawl_looking_up" -> "looking_up"
        animation: cycle $PREFIX NS "crawling_looking_up"
        shapes:
            : $PREFIX NS "crawling_looking_up" (0 0 0 0) 0 f 0+r


    $PREFIX NS "crawl_step":
        animation: cycle 3
        labels:
            : "label:crawl_head" (-1  0  2  1)  1 f  (0 1)
            : "label:crawl_head" ( 0  0  2  1)  1 f  (1 1)
            : "label:crawl_head" ( 0  1  2  0)  1 f  (2 1)
            : "label:bleg"  (-1  1  1  1)  0 f
            : "label:fleg"  ( 2  1  1  2)  7 t  (0 1)
            : "label:fleg"  ( 3  1  1  2)  6 t  (1 1)
            : "label:fleg"  ( 3  1  1  1)  6 t  (2 1)

    $PREFIX NS "crawl_turn":
        animation: cycle $PREFIX NS "crawl_step"
        $IF EYESPIDER:
            shapes:
                : "_eye_open" (-1  0  2  1)  1 f  0 (0 1)
                : "_eye_open" ( 0  0  2  1)  1 f  0 (1 1)
                : "_eye_open" ( 0  1  2  0)  1 f  0 (2 1)
            labels:
                : "label:bleg"  (-1  1  1  1)  0 f
                : "label:fleg"  ( 2  1  1  2)  7 t  (0 1)
                : "label:fleg"  ( 3  1  1  2)  6 t  (1 1)
                : "label:fleg"  ( 3  1  1  1)  6 t  (2 1)
        $IF !EYESPIDER:
            shapes:
                : $PREFIX NS "crawl_step" (0 0 0 0) 0 f

    $PREFIX NS "crawl_shielding":
        animation: cycle 5
        labels:
            : "label:crawl_head" ( 2  1  2  0)  0 f (0 1)
            : "label:bleg"  ( 1  1  1  1)  0 f (0 1)
            : "label:fleg"  ( 4  1  1  1)  6 t (0 1)

            : "label:crawl_head" (-1  1  2  0)  0 f (1 1)
            : "label:bleg"  (-2  1  1  1)  0 f (1 1)
            : "label:fleg"  ( 1  1  1  1)  6 t (1 1)

            : "label:crawl_head" ( 1  1  2  0)  0 f (2 1)
            : "label:bleg"  ( 0  1  1  1)  0 f (2 1)
            : "label:fleg"  ( 3  1  1  1)  6 t (2 1)

            : "label:crawl_head" ( 0  1  2  0)  0 f (3 2)
            : "label:bleg"  (-1  1  1  1)  0 f (3 2)
            : "label:fleg"  ( 2  1  1  1)  6 t (3 2)

    $PREFIX NS "sleep":
        labels:
            : "label:sleep_head" ( 0  1  2  0)  0 f
            : "label:bleg"  (-1  1  1  1)  0 f
            : "label:fleg"  ( 2  1  1  1)  6 t

    $PREFIX NS "swim":
        animation: cycle 12
        labels:
            : "label:head" ( 0  1  3  2)  0 f ( 0 2)
            : "label:bleg"  ( 0  1  1  2)  1 f ( 0 2)
            : "label:fleg"  ( 2  1  1  2)  5 t ( 0 2)

            : "label:head" ( 0  1  3  3)  0 f ( 2 2)
            : "label:bleg"  ( 0  1  1  3)  1 f ( 2 2)
            : "label:fleg"  ( 2  1  1  3)  5 t ( 2 2)

            : "label:head" ( 0  1  3  3)  0 f ( 4 2)
            : "label:bleg"  ( 0  1  1  3)  0 f ( 4 2)
            : "label:fleg"  ( 2  1  1  3)  6 t ( 4 2)

            : "label:head" ( 0  1  3  2)  0 f ( 6 2)
            : "label:bleg"  ( 0  1  1  2)  0 f ( 6 2)
            : "label:fleg"  ( 2  1  1  2)  6 t ( 6 2)

            : "label:head" ( 0  1  3  1)  0 f ( 8 2)
            : "label:bleg"  ( 0  1  1  1) -1 f ( 8 2)
            : "label:fleg"  ( 2  1  1  1)  7 t ( 8 2)

            : "label:head" ( 0  1  3  0)  0 f (10 2)
            : "label:bleg"  ( 0  1  1  0) -2 f (10 2)
            : "label:fleg"  ( 2  1  1  0)  8 t (10 2)


    $PREFIX NS "run_stand":
        labels:
            : "label:head"  ( 1  1  3  1)  0 f
            : "label:bleg"  ( 2  2  1  1)  0 f
            : "label:fleg"  ( 3  1  1  1)  5 t

    $PREFIX NS "run_step":
        animation: cycle 2
        labels:
            : "label:head" ( 0  0  3  1)  0 f  (0 1)
            : "label:head" ( 1  0  3  1)  0 f  (1 1)

            : "label:bleg" (-1  1  1  1) 10 f  (0 1)
            : "label:fleg" ( 1  1  1  1)  7 t  (0 1)

            : "label:bleg" ( 1  1  1  1) 11 f  (1 1)
            : "label:fleg" ( 2  1  1  1)  6 t  (1 1)

        shapes:
            #: $PREFIX NS "run_stand" (0 0 0 0) 0 f 0 (2 1)

    $PREFIX NS "run_jump":
        animation: cycle $PREFIX NS "jump"
        shapes:
            : $PREFIX NS "jump" (0 0 0 0) 0 f

    $IF EYESPIDER:
        # eyespider-specific rgraphs

        $PREFIX NS "eye_closing":
            animation: cycle 6
            shapes:
                : "_eye_looking_1"   ( 0  1  3  1) 11 f 0 ( 0  1)
                : "_eye_open"        ( 0  1  3  1)  0 f 0 ( 1  1)
                : "_eye_opening_3"   ( 0  1  3  1)  0 f 0 ( 2  1)
                : "_eye_opening_2"   ( 0  1  3  1)  0 f 0 ( 3  1)
                : "_eye_opening_1"   ( 0  1  3  1)  0 f 0 ( 4  1)
                : "_eye_closed"      ( 0  1  3  1)  0 f 0 ( 5  1)
            labels:
                : "label:bleg"  ( 0  1  1  1)  0 f
                : "label:fleg"  ( 2  1  1  1)  6 t

        $PREFIX NS "eye_unclosing":
            animation: cycle $PREFIX NS "eye_closing"
            shapes:
                : $PREFIX NS "eye_closing" (0 0 0 0) 0 f 0+r

        $PREFIX NS "eye_closed":
            shapes:
                : "_eye_closed"      ( 0  1  3  1)  0 f
            labels:
                : "label:bleg"  ( 0  1  1  1)  0 f
                : "label:fleg"  ( 2  1  1  1)  6 t