(include "sci.sh")
(use "Main")
(use "Section")
(use "n958")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 246)


(local
    local0[2]
    theSection
    theSection_2

)
(instance public rm226 of Rm
    (properties
        modNum 240
        noun 19
        picture 43
        style 100
    )

    (method (init param1)
        (super:init(rest param1))
        proc958_0(128 0 255 26 259 265 259)
        (dummyEgo:addToPic())
        (cliffy:addToPic())
        (wd40:addToPic())
        (chamber:addToPic())
        (northDoor:addToPic())
        (spike:addToPic())
        (self:setScript(activateViewer))
    )

)
(instance dummyEgo of View
    (properties
        x 225
        y 146
        noun 18
        modNum 0
        view 0
        loop 8
        cel 2
        signal 16384
        scaleSignal 1
        scaleX 142
        scaleY 142
    )
)
(instance activateViewer of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) = seconds 2  )
            )
            (case 1
                (= theSection 0 (send gSq5Music2:
                    number(106)
                    loop(1)
                    play()
                )
 (viewerTop:init(self)) (viewerBottom:init(self))  )
            )
            (case 2
                ( )
            )
            (case 3
                ((viewerTop:stopUpd()) (viewerBottom:stopUpd()) (viewerScreen:init()) (goliath:init()) (aft:init()) (wing:init()) (bridge:init()) (topsection:init()) (midSection:init()) (lowersection:init()) (tllight:init()) (trlight:init()) (lllight:init()) (lrlight:init()) (midsectp2:init()) (midsectp3:init()) = seconds 3  )
            )
            (case 4
                (
                (if (& global169 $0008)
                    = state (+ state 2)
                    = cycles 1
                )(else
                    = global169 (| global169 $0008)
                    (send gTestMessager:say(2 0 0 1 3 self 246))
                )
 )
            )
            (case 5
                ((aft:show()) (midSection:show()) (midsectp2:show()) (midsectp3:show()) = seconds 3  )
            )
            (case 6
                ((send gTestMessager:say(2 0 0 4 10 self 246))  )
            )
            (case 7
                ((aft:hide()) (midSection:hide()) (midsectp2:hide()) (midsectp3:hide()) = cycles 5  )
            )
            (case 8
                (= theSection 1 (send gSQ5:handsOn()) (exitSign:init()) (send gSq5IconBar:disable(0 3 2 4 5 6))  )
            )
            (case 9
                ((send gSQ5:handsOff()) (send gSq5Music2:
                    number(106)
                    loop(1)
                    play()
                )
 (send gCast:delete(gEgo)) (viewerTop:setMotion(MoveTo 94 65522 self)) (viewerBottom:setMotion(MoveTo 94 241 self)) (viewerScreen:dispose()) (goliath:dispose()) (aft:dispose()) (wing:dispose()) (bridge:dispose()) (topsection:dispose()) (midSection:dispose()) (lowersection:dispose()) (tllight:dispose()) (trlight:dispose()) (lllight:dispose()) (lrlight:dispose()) (midsectp2:dispose()) (midsectp3:dispose()) (exitSign:dispose())  )
            )
            (case 10
                ( )
            )
            (case 11
                ((send gRoom:newRoom(240)) )
            )
        )
    )

)
(class Section of View
    (properties
        x 0
        y 0
        z 100
        heading 0
        noun 0
        modNum 246
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck 26505
        state 0
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view 255
        loop 5
        cel 0
        priority 15
        underBits 0
        signal 20496
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal 0
        scaleX 128
        scaleY 128
        maxScale 128
    )

    (method (init param1)
        = y (+ y z)
        (super:init(rest param1))
        (self:hide())
    )


    (method (doit param1)
        (if (theSection)
            (if ((self:onMe(gPEventX (- gPEventY 10))))
                (if (not (self:isNotHidden()) and not theSection_2)
                    = theSection_2 self
                    (self:show())
                )
            )(else
                (if ((self:isNotHidden()) and (== theSection_2 self))
                    = theSection_2 0
                    (self:hide())
                )
            )
        )
        (super:doit(rest param1))
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 1
        )(else
            (if ((& (send pEvent:type) $4000) and (self:onMe(pEvent)))
                (send pEvent:claimed(1))
                (self:doVerb((send pEvent:message)))
            )
        )
        return (send pEvent:claimed)
    )


    (method (onMe param1 param2)
        (var temp0, temp1)
        (if (IsObject(param1))
            = temp0 (send param1:x)
            = temp1 (send param1:y)
        )(else
            = temp0 param1
            = temp1 param2
        )
        (if (not IsObject(onMeCheck) and (& signal $1000))
            (if (not 
            (if ((nsLeft or nsRight) or nsTop)
            )(else
                nsBottom
            )
 or ((((<= nsLeft temp0) and (<= temp0 nsRight)) and (<= nsTop temp1)) and (<= temp1 nsBottom)))
                not IsItSkip(view loop cel - temp1 nsTop - temp0 nsLeft)
            )
        )(else
            (super:onMe(temp0 temp1))
        )
    )

)
(instance viewerTop of Actor
    (properties
        x 94
        y 65522
        noun 13
        yStep 4
        view 255
        loop 2
        priority 14
        signal 28688
        moveSpeed 3
    )

    (method (init param1 param2)
        (super:init(rest param2))
        (self:
            posn(94 65522)
            setLoop(2)
            setMotion(MoveTo 94 48 param1)
        )
    )

)
(instance viewerBottom of Actor
    (properties
        x 94
        y 241
        noun 13
        yStep 4
        view 255
        loop 1
        priority 14
        signal 28688
        moveSpeed 3
    )

    (method (init param1 param2)
        (super:init(rest param2))
        (self:
            posn(94 241)
            setLoop(1)
            setMotion(MoveTo 94 177 param1)
        )
    )

)
(instance viewerScreen of View
    (properties
        x 84
        y 79
        noun rm226
        view 255
        priority 13
        signal 20496
    )

    (method (init param1 param2)
        (super:init(rest param2))
        (self:
            setLoop(0)
            stopUpd()
        )
    )

)
(instance goliath of View
    (properties
        x 84
        y 79
        view 255
        loop 4
        priority 14
        signal 16400
    )
)
(instance aft of Section
    (properties
        x 108
        y 99
        noun 3
    )
)
(instance midsectp2 of Section
    (properties
        x 129
        y 94
        noun 7
        cel 7
    )
)
(instance midsectp3 of Section
    (properties
        x 116
        y 94
        noun 9
        cel 6
    )
)
(instance wing of Section
    (properties
        x 108
        y 99
        noun 11
        cel 1
    )
)
(instance bridge of Section
    (properties
        x 108
        y 99
        noun 5
        cel 5
    )
)
(instance topsection of Section
    (properties
        x 108
        y 99
        noun 10
        cel 4
    )
)
(instance midSection of Section
    (properties
        x 108
        y 99
        noun 8
        cel 3
    )
)
(instance lowersection of Section
    (properties
        x 108
        y 99
        noun 6
        cel 2
    )
)
(instance tllight of View
    (properties
        x 29
        y 51
        noun 13
        view 255
        loop 1
        cel 1
        priority 15
        signal 16400
    )
)
(instance trlight of View
    (properties
        x 179
        y 39
        noun 13
        view 255
        loop 1
        cel 2
        priority 15
        signal 16400
    )
)
(instance lllight of View
    (properties
        x 29
        y 131
        noun 13
        view 255
        loop 1
        cel 1
        priority 15
        signal 16400
    )
)
(instance lrlight of View
    (properties
        x 179
        y 142
        noun 13
        view 255
        loop 1
        cel 2
        priority 15
        signal 16400
    )
)
(instance exitSign of View
    (properties
        x 115
        y 221
        z 100
        view 255
        loop 6
        priority 15
        signal 20496
    )

    (method (doVerb param1)
        (if (== param1 1)
            (activateViewer:cue())
        )
    )

)
(instance cliffy of View
    (properties
        x 238
        y 162
        noun 5
        modNum 240
        view 26
        signal 24576
        scaleSignal 1
        scaleX 148
        scaleY 148
    )
)
(instance chamber of View
    (properties
        x 202
        y 132
        noun 8
        modNum 240
        view 259
        loop 2
        priority 9
        signal 22544
    )
)
(instance wd40 of View
    (properties
        x 124
        y 107
        noun 28
        modNum 240
        view 265
        signal 24576
    )

    (method (init param1)
        (extraView:addToPic())
        (super:init(rest param1))
    )

)
(instance extraView of View
    (properties
        x 124
        y 107
        noun 28
        modNum 240
        view 265
        loop 1
        priority 1
        signal 16400
    )
)
(instance northDoor of View
    (properties
        x 23
        y 95
        noun 20
        modNum 240
        view 259
        priority 5
        signal 20496
    )
)
(instance spike of View
    (properties
        x 253
        y 101
        noun 25
        modNum 240
        view 244
        loop 2
        priority 11
        signal 16400
    )
)
