(version 2)
(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Feature")
(use "Cycle")
(use "Obj")
(script 998)



(class PicView of Feature
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 0
        sightAngle 90
        closeRangeDist 50
        longRangeDist 100
        shiftClick -32767
        contClick 7
        actions 0
        control 0
        verbChecks1 -17483
        verbChecks2 -17477
        verbChecks3 -17477
        view 0
        loop 0
        cel 0
        priority -1
        signal $0000
        palette 0
    )

    (method (init)
        (send gAddToPics:add(self))
        SetNowSeen(self nsTop)
        (super:init())
    )


    (method (dispose)
        DisposeClone(self)
    )


    (method (showSelf)
        proc255_0(name 82 view loop cel)
    )

)
(class View of Feature
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 0
        sightAngle 90
        closeRangeDist 50
        longRangeDist 100
        shiftClick -32767
        contClick 7
        actions 0
        control 0
        verbChecks1 -17483
        verbChecks2 -17477
        verbChecks3 -17477
        yStep 2
        view 0
        loop 0
        cel 0
        priority 0
        underBits 0
        signal $0101
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
    )

    (method (init)
        = signal (& signal $7fff)
        (if (not (send gCast:contains(self)))
            = lsRight (= lsBottom (= lsLeft (= lsTop 0)))
            = signal (& signal $ff77)
        )
        BaseSetter(self)
        (send gCast:add(self))
        (if (not description)
            = description name
        )
    )


    (method (dispose)
        (self:
            startUpd()
            hide()
        )
        = signal (| signal $8000)
    )


    (method (showSelf)
        proc255_0(name 82 view loop cel)
    )


    (method (isNotHidden)
        return not & signal $0080
    )


    (method (posn theX theY theZ)
        (if (>= paramTotal 1)
            = x theX
            (if (>= paramTotal 2)
                = y theY
                (if (>= paramTotal 3)
                    = z theZ
                )
            )
        )
        BaseSetter(self)
        (self:forceUpd())
    )


    (method (stopUpd)
        = signal (| signal $0001)
        = signal (& signal $fffd)
    )


    (method (forceUpd)
        = signal (| signal $0040)
    )


    (method (startUpd)
        = signal (| signal $0002)
        = signal (& signal $fffe)
    )


    (method (setPri thePriority)
        (if (== paramTotal 0)
            = signal (| signal $0010)
        )(else
            (if (== thePriority -1)
                = signal (& signal $ffef)
            )(else
                = priority thePriority
                = signal (| signal $0010)
            )
        )
        (self:forceUpd())
    )


    (method (setLoop theLoop)
        (if (== paramTotal 0)
            = signal (| signal $0800)
        )(else
            (if (== theLoop -1)
                = signal (& signal $f7ff)
            )(else
                = loop theLoop
                = signal (| signal $0800)
            )
        )
        (self:forceUpd())
    )


    (method (setCel param1)
        (if (== paramTotal 0)
            = signal (| signal $1000)
        )(else
            (if (== param1 -1)
                = signal (& signal $efff)
            )(else
                = signal (| signal $1000)
                = cel 
                    (if (>= param1 (self:lastCel()))
                        (self:lastCel())
                    )(else
                        param1
                    )
            )
        )
        (self:forceUpd())
    )


    (method (ignoreActors param1)
        (if ((== 0 paramTotal) or param1)
            = signal (| signal $4000)
        )(else
            = signal (& signal $bfff)
        )
    )


    (method (hide)
        = signal (| signal $0008)
    )


    (method (show)
        = signal (& signal $fff7)
    )


    (method (delete)
        (if (& signal $8000)
            (if (& signal $0020)
                (send gAddToPics:add((send ((PicView:new())):
                        view(view)
                        loop(loop)
                        cel(cel)
                        x(x)
                        y(y)
                        z(z)
                        priority(priority)
                        signal(signal)
                        yourself()
                    )
))
            )
            = signal (& signal $7fff)
            (send gCast:delete(self))
            (if (underBits)
                UnLoad(133 underBits)
                = underBits 0
            )
            DisposeClone(self)
        )
    )


    (method (addToPic)
        (if (not (send gCast:contains(self)))
            (self:init())
        )
        (self:signal((| signal $8021)))
    )


    (method (lastCel)
        return - NumCels(self) 1
    )


    (method (isExtra param1)
        (var temp0)
        = temp0 (& signal $0200)
        (if (paramTotal)
            (if (param1)
                = signal (| signal $0200)
            )(else
                = signal (& signal $fdff)
            )
        )
        return temp0
    )


    (method (motionCue)
    )

)
(class Prop of View
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 0
        sightAngle 90
        closeRangeDist 50
        longRangeDist 100
        shiftClick -32767
        contClick 7
        actions 0
        control 0
        verbChecks1 -17483
        verbChecks2 -17477
        verbChecks3 -17477
        yStep 2
        view 0
        loop 0
        cel 0
        priority 0
        underBits 0
        signal $0000
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
    )

    (method (doit)
        (var temp0)
        SetNowSeen(self nsTop)
        (if (& signal $8000)
            return 
        )
        (if (script)
            (send script:doit())
        )
        (if ((& signal $0004) and not (& signal $0002))
            return 
        )
        (if (cycler)
            (send cycler:doit())
        )
    )


    (method (handleEvent pEvent)
        (if (script)
            (send script:handleEvent(pEvent))
        )
        (super:handleEvent(pEvent))
    )


    (method (delete)
        (if (& signal $8000)
            (self:
                setScript(0)
                setCycle(0)
            )
            (if (timer)
                (send timer:dispose())
            )
            (super:delete())
        )
    )


    (method (motionCue)
        (if (cycler and (send cycler:completed))
            (send cycler:motionCue())
        )
    )


    (method (setCycle theCycler sendParams)
        (if (cycler)
            (send cycler:dispose())
        )
        (if (theCycler)
            (self:setCel(-1))
            (self:startUpd())
            = cycler 
                (if (& (send theCycler:{-info-}) $8000)
                    (send theCycler:new())
                )(else
                    theCycler
                )
            (send cycler:init(self rest sendParams))
        )(else
            = cycler 0
        )
    )


    (method (setScript theScript sendParams)
        (if (IsObject(script))
            (send script:dispose())
        )
        (if (theScript)
            (send theScript:init(self rest sendParams))
        )
    )


    (method (cue)
        (if (script)
            (send script:cue())
        )
    )

)
(class Actor of Prop
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 0
        sightAngle 90
        closeRangeDist 50
        longRangeDist 100
        shiftClick -32767
        contClick 7
        actions 0
        control 0
        verbChecks1 -17483
        verbChecks2 -17477
        verbChecks3 -17477
        yStep 2
        view 0
        loop 0
        cel 0
        priority 0
        underBits 0
        signal $0000
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
        illegalBits $8000
        xLast 0
        yLast 0
        xStep 3
        moveSpeed 0
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
    )

    (method (init)
        (super:init())
        = xLast x
        = yLast y
    )


    (method (doit)
        (var temp0, theBrLeft, theBrRight)
        (if (& signal $8000)
            return 
        )
        = signal (& signal $fbff)
        (if (script)
            (send script:doit())
        )
        (if (code)
            (send code:doit(self))
        )
        (if ((& signal $0004) and not (& signal $0002))
            return 
        )
        (if (viewer)
            (send viewer:doit(self))
        )
        (if (avoider)
            (send avoider:doit())
        )(else
            (if (mover)
                (send mover:doit())
            )
        )
        (if (cycler)
            = theBrLeft brLeft
            = theBrRight brRight
            (send cycler:doit())
            (if (baseSetter)
                (send baseSetter:doit(self))
            )(else
                BaseSetter(self)
            )
            (if (((<> theBrLeft brLeft) or (<> theBrRight brRight)) and not (self:canBeHere()))
                (self:findPosn())
            )
        )
        = xLast x
        = yLast y
    )


    (method (posn theXLast theYLast param3)
        (super:posn(theXLast theYLast rest param3))
        = xLast theXLast
        = yLast theYLast
        (if (not (self:canBeHere()))
            (self:findPosn())
        )
    )


    (method (setLoop param1 param2)
        (var theLooper)
        = theLooper 
            (if (== paramTotal 0)
                (super:setLoop())
                0
            )(else
                (if (not IsObject(param1))
                    (super:setLoop(param1 rest param2))
                    0
                )(else
                    (if (& (send param1:{-info-}) $8000)
                        (send param1:new())
                    )(else
                        param1
                    )
                )
            )
        (if (theLooper)
            (if (looper)
                (send looper:dispose())
            )
            (send (= looper theLooper):init(self rest param2))
        )
    )


    (method (delete)
        (if (& signal $8000)
            (if (<> mover -1)
                (self:setMotion(0))
            )
            (self:setAvoider(0))
            (if (baseSetter)
                (send baseSetter:dispose())
                = baseSetter 0
            )
            (if (looper)
                (send looper:dispose())
                = looper 0
            )
            (if (viewer)
                (send viewer:dispose())
                = viewer 0
            )
            (if (blocks)
                (send blocks:dispose())
                = blocks 0
            )
            (if (code)
                (send code:dispose())
                = code 0
            )
            (if (actions)
                (send actions:dispose())
                = actions 0
            )
            (super:delete())
        )
    )


    (method (motionCue)
        (if (mover and (send mover:completed))
            (send mover:motionCue())
        )
        (super:motionCue())
    )


    (method (setMotion theMover sendParams)
        (var temp0[40])
        (if (mover and (<> mover -1))
            (send mover:dispose())
        )
        (if (theMover)
            (self:startUpd())
            = mover 
                (if (& (send theMover:{-info-}) $8000)
                    (send theMover:new())
                )(else
                    theMover
                )
            (send mover:init(self rest sendParams))
        )(else
            = mover 0
        )
    )


    (method (setAvoider theAvoider sendParams)
        (if (avoider)
            (send avoider:dispose())
        )
        = avoider 
            (if (IsObject(theAvoider) and (& (send theAvoider:{-info-}) $8000))
                (send theAvoider:new())
            )(else
                theAvoider
            )
        (if (avoider)
            (send avoider:init(self rest sendParams))
        )
    )


    (method (ignoreHorizon param1)
        (if (not paramTotal or param1)
            = signal (| signal $2000)
        )(else
            = signal (& signal $dfff)
        )
    )


    (method (observeControl bits)
        (var temp0)
        = temp0 0
        (while (< temp0 paramTotal)
            = illegalBits (| illegalBits bits[temp0])
            ++temp0
        )
    )


    (method (ignoreControl bits)
        (var temp0)
        = temp0 0
        (while (< temp0 paramTotal)
            = illegalBits (& illegalBits bnot bits[temp0])
            ++temp0
        )
    )


    (method (observeBlocks param1)
        (if (not blocks)
            = blocks (Set:new())
        )
        (send blocks:add(rest param1))
    )


    (method (ignoreBlocks param1)
        (send blocks:delete(rest param1))
        (if ((send blocks:isEmpty()))
            (send blocks:dispose())
            = blocks 0
        )
    )


    (method (isStopped)
        return 
            (if (not not IsObject(mover) and (== x (send mover:xLast)))
                == y (send mover:yLast)
            )(else
                0
            )
    )


    (method (isBlocked)
        return & signal $0400
    )


    (method (findPosn)
        (var temp0, temp1, theX, theY, temp4)
        = theX x
        = theY y
        = temp4 0
        = temp1 1
        (while (not temp4)
            = temp0 0
            (while (not temp4 and (< temp0 8))
                = x (+ theX (* temp1 proc999_0(CosMult((* temp0 45) 100))))
                = y (- theY (* temp1 proc999_0(SinMult((* temp0 45) 100))))
                = temp4 
                    (if ((self:canBeHere()))
                        (self:onControl())
                    )(else
                        0
                    )
                ++temp0
            )
            ++temp1
        )
        (self:posn(x y))
    )


    (method (inRect param1 param2 param3 param4)
        return 
            (if (((<= param1 x) and (< x param3)) and (<= param2 y))
                < y param4
            )(else
                0
            )
    )


    (method (onControl fUsePoint)
        (if (paramTotal and fUsePoint)
            OnControl(4 x y)
        )(else
            OnControl(4 brLeft brTop brRight brBottom)
        )
    )


    (method (distanceTo pObj)
        GetDistance(x y (send pObj:x) (send pObj:y) gPicAngle)
    )


    (method (canBeHere)
        (if (baseSetter)
            (send baseSetter:doit(self))
        )(else
            BaseSetter(self)
        )
        (if ((not (((== illegalBits 0) and (& signal {--UNKNOWN-PROP-NAME--})) or CanBeHere(self (send gCast:elements))) or not (((& signal $2000) or not IsObject(global2)) or (>= y (send global2:horizon)))) or (== blocks 0))
        )(else
            (send blocks:allTrue(60 self))
        )
    )


    (method (setStep newX newY)
        (if ((>= paramTotal 1) and (<> newX -1))
            = xStep newX
        )
        (if ((>= paramTotal 2) and (<> newY -1))
            = yStep newY
        )
        (if ((mover and (<> -1 mover)) and (send mover:isMemberOf(MoveTo)))
            (send ((self:mover)):init())
        )
    )


    (method (setDirection newDirection)
        (var temp0, temp1, temp2, temp3, temp4, temp5)
        = temp1 (send global2:vanishingY)
        = temp0 
            (if (== temp1 -30000)
                x
            )(else
                (send global2:vanishingX)
            )
        (if ((== xStep 0) and (== yStep 0))
            return 
        )
        = temp5 (/ 32000 proc999_3(xStep yStep))
        (switch (newDirection)
            (case 0
                (self:setMotion(0))
                return 
            )
            (case 1
                = temp2 (- temp0 x)
                = temp3 (- temp1 y)
            )
            (case 5
                = temp2 (- x temp0)
                = temp3 (- y temp1)
            )
            (case 3
                = temp2 temp5
                = temp3 0
            )
            (case 7
                = temp2 neg temp5
                = temp3 0
            )
            (default 
                = temp4 GetAngle(x y temp0 temp1)
                (if (< 180 temp4)
                    = temp4 (- temp4 360)
                )
                = temp4 (+ (/ (+ temp4 90) 2) (* 45 (- newDirection 2)))
                = temp2 SinMult(temp4 100)
                = temp3 neg CosMult(temp4 100)
            )
        )
        = temp5 (/ temp5 5)
        (while ((< Abs(temp3) temp5) and (< Abs(temp2) temp5))
            = temp2 (* temp2 5)
            = temp3 (* temp3 5)
        )
        (self:setMotion(MoveTo (+ x temp2) (+ y temp3)))
    )


    (method (setHeading theHeading param2)
        (if (paramTotal)
            = heading theHeading
        )
        (if (looper)
            (send looper:doit(self heading 
                (if (>= paramTotal 2)
                    param2
                )(else
                    0
                )
))
        )(else
            DirLoop(self heading)
            Animate((send gCast:elements) 0)
            (if ((>= paramTotal 2) and IsObject(param2))
                (send param2:cue())
            )
        )
        return heading
    )

)
